Mercurial > sdl-ios-xcode
comparison src/video/cocoa/SDL_cocoashape.m @ 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 | 8dabd625079f |
children | 34fb492cefe3 |
comparison
equal
deleted
inserted
replaced
4831:8dabd625079f | 4832:0c82f20327ec |
---|---|
26 #include "SDL_cocoashape.h" | 26 #include "SDL_cocoashape.h" |
27 #include "../SDL_sysvideo.h" | 27 #include "../SDL_sysvideo.h" |
28 | 28 |
29 SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window) { | 29 SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window) { |
30 SDL_WindowData* data = (SDL_WindowData*)window->driverdata; | 30 SDL_WindowData* data = (SDL_WindowData*)window->driverdata; |
31 [data->nswindow setAlpha:1.0]; | 31 [data->nswindow setAlphaValue:1.0]; |
32 [data->nswindow setOpaque:YES]; | 32 [data->nswindow setOpaque:YES]; |
33 [data->nswindow setStyleMask:NSBorderlessWindowMask]; | 33 [data->nswindow setStyleMask:NSBorderlessWindowMask]; |
34 SDL_WindowShaper* result = SDL_malloc(sizeof(SDL_WindowShaper)); | 34 SDL_WindowShaper* result = SDL_malloc(sizeof(SDL_WindowShaper)); |
35 result->window = window; | 35 result->window = window; |
36 result->mode.mode = ShapeModeDefault; | 36 result->mode.mode = ShapeModeDefault; |
43 shape_data->context = [data->nswindow graphicsContext]; | 43 shape_data->context = [data->nswindow graphicsContext]; |
44 shape_data->saved = SDL_FALSE; | 44 shape_data->saved = SDL_FALSE; |
45 shape_data->shape = NULL; | 45 shape_data->shape = NULL; |
46 | 46 |
47 int resized_properly = Cocoa_ResizeWindowShape(window); | 47 int resized_properly = Cocoa_ResizeWindowShape(window); |
48 assert(resized_properly == 0); | 48 SDL_assert(resized_properly == 0); |
49 return result; | 49 return result; |
50 } | 50 } |
51 | 51 |
52 typedef struct { | 52 typedef struct { |
53 NSBezierPath* clipPath; | 53 NSBezierPath* clipPath; |
58 NSRect nsrect = NSMakeRect(rect.x,window->h-(rect.y+rect.h),rect.w,rect.h); | 58 NSRect nsrect = NSMakeRect(rect.x,window->h-(rect.y+rect.h),rect.w,rect.h); |
59 return [[((SDL_WindowData*)window->driverdata)->nswindow contentView] convertRectFromBase:nsrect]; | 59 return [[((SDL_WindowData*)window->driverdata)->nswindow contentView] convertRectFromBase:nsrect]; |
60 } | 60 } |
61 | 61 |
62 void ConglomerateShapeTree(SDL_ShapeTree* tree,SDL_PathConglomeration* cong) { | 62 void ConglomerateShapeTree(SDL_ShapeTree* tree,SDL_PathConglomeration* cong) { |
63 SDL_assert(tree != NULL); | |
63 if(tree->kind == OpaqueShape) { | 64 if(tree->kind == OpaqueShape) { |
64 NSRect rect = convert_rect(tree->data.shape,cong->window); | 65 NSRect rect = convert_rect(tree->data.shape,cong->window); |
65 [cong->clipPath appendBezierPathWithRect:rect]; | 66 [cong->clipPath appendBezierPathWithRect:rect]; |
66 } | 67 } |
67 } | 68 } |
89 [clipPath addClip]; | 90 [clipPath addClip]; |
90 } | 91 } |
91 | 92 |
92 int Cocoa_ResizeWindowShape(SDL_Window *window) { | 93 int Cocoa_ResizeWindowShape(SDL_Window *window) { |
93 SDL_ShapeData* data = window->shaper->driverdata; | 94 SDL_ShapeData* data = window->shaper->driverdata; |
94 assert(data != NULL); | 95 SDL_assert(data != NULL); |
95 | 96 |
96 if(data->shape != NULL) | 97 if(data->shape != NULL) |
97 SDL_FreeShapeTree(&data->shape); | 98 SDL_FreeShapeTree(&data->shape); |
98 | 99 |
99 return 0; | 100 return 0; |