comparison src/video/x11/SDL_x11shape.c @ 4832:0c82f20327ec

Correcting minor bugs and adding assertions to help me track down a NULL pointer bug in Cocoa code.
author egottlieb
date Thu, 05 Aug 2010 00:53:38 -0400
parents c68e7490e4cf
children 34fb492cefe3
comparison
equal deleted inserted replaced
4831:8dabd625079f 4832:0c82f20327ec
18 18
19 Eli Gottlieb 19 Eli Gottlieb
20 eligottlieb@gmail.com 20 eligottlieb@gmail.com
21 */ 21 */
22 22
23 #include <assert.h> 23 #include "SDL_assert.h"
24 #include "SDL_malloc.h"
24 #include "SDL_x11video.h" 25 #include "SDL_x11video.h"
25 #include "SDL_x11shape.h" 26 #include "SDL_x11shape.h"
26 #include "SDL_x11window.h" 27 #include "SDL_x11window.h"
27 28
28 SDL_Window* X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) { 29 SDL_Window* X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) {
37 result = malloc(sizeof(SDL_WindowShaper)); 38 result = malloc(sizeof(SDL_WindowShaper));
38 result->window = window; 39 result->window = window;
39 result->mode.mode = ShapeModeDefault; 40 result->mode.mode = ShapeModeDefault;
40 result->mode.parameters.binarizationCutoff = 1; 41 result->mode.parameters.binarizationCutoff = 1;
41 result->usershownflag = 0; 42 result->usershownflag = 0;
42 SDL_ShapeData* data = malloc(sizeof(SDL_ShapeData)); 43 SDL_ShapeData* data = SDL_malloc(sizeof(SDL_ShapeData));
43 result->driverdata = data; 44 result->driverdata = data;
44 data->bitmapsize = 0; 45 data->bitmapsize = 0;
45 data->bitmap = NULL; 46 data->bitmap = NULL;
46 window->shaper = result; 47 window->shaper = result;
47 int resized_properly = X11_ResizeWindowShape(window); 48 int resized_properly = X11_ResizeWindowShape(window);
48 assert(resized_properly == 0); 49 SDL_assert(resized_properly == 0);
49 } 50 }
50 #endif 51 #endif
51 52
52 return result; 53 return result;
53 } 54 }
54 55
55 int X11_ResizeWindowShape(SDL_Window* window) { 56 int X11_ResizeWindowShape(SDL_Window* window) {
56 SDL_ShapeData* data = window->shaper->driverdata; 57 SDL_ShapeData* data = window->shaper->driverdata;
57 assert(data != NULL); 58 SDL_assert(data != NULL);
58 59
59 unsigned int bitmapsize = window->w / 8; 60 unsigned int bitmapsize = window->w / 8;
60 if(window->w % 8 > 0) 61 if(window->w % 8 > 0)
61 bitmapsize += 1; 62 bitmapsize += 1;
62 bitmapsize *= window->h; 63 bitmapsize *= window->h;