# HG changeset patch # User egottlieb # Date 1281049125 14400 # Node ID fd5bb97ec05d9831ac6e4a344bf20812ba5c8ae2 # Parent 34fb492cefe3392da7397175d4df8b1beb3296c8 Improving Cocoa implementation and fixed a small bug in SDL_shape.c. diff -r 34fb492cefe3 -r fd5bb97ec05d VisualC/SDL_VS2010.sdf Binary file VisualC/SDL_VS2010.sdf has changed diff -r 34fb492cefe3 -r fd5bb97ec05d src/video/SDL_shape.c --- a/src/video/SDL_shape.c Thu Aug 05 01:03:24 2010 -0400 +++ b/src/video/SDL_shape.c Thu Aug 05 18:58:45 2010 -0400 @@ -242,7 +242,7 @@ } SDL_bool SDL_WindowHasAShape(SDL_Window *window) { - if (window == NULL && !SDL_IsShapedWindow(window)) + if (window == NULL || !SDL_IsShapedWindow(window)) return SDL_FALSE; return window->shaper->hasshape; } diff -r 34fb492cefe3 -r fd5bb97ec05d src/video/cocoa/SDL_cocoashape.m --- a/src/video/cocoa/SDL_cocoashape.m Thu Aug 05 01:03:24 2010 -0400 +++ b/src/video/cocoa/SDL_cocoashape.m Thu Aug 05 18:58:45 2010 -0400 @@ -29,8 +29,8 @@ SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window) { SDL_WindowData* data = (SDL_WindowData*)window->driverdata; - [data->nswindow setAlphaValue:1.0]; - [data->nswindow setOpaque:YES]; + [data->nswindow setOpaque:NO]; + [data->nswindow setBackgroundColor:[NSColor clearColor]]; [data->nswindow setStyleMask:NSBorderlessWindowMask]; SDL_WindowShaper* result = SDL_malloc(sizeof(SDL_WindowShaper)); result->window = window; @@ -42,6 +42,7 @@ SDL_ShapeData* shape_data = SDL_malloc(sizeof(SDL_ShapeData)); result->driverdata = shape_data; shape_data->context = [data->nswindow graphicsContext]; + SDL_assert(shape_data->context != NULL); shape_data->saved = SDL_FALSE; shape_data->shape = NULL; @@ -70,26 +71,32 @@ int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) { SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata; - if(data->saved == SDL_TRUE) { + /* if(data->saved == SDL_TRUE) { [data->context restoreGraphicsState]; data->saved = SDL_FALSE; - } + }*/ - [data->context saveGraphicsState]; - data->saved = SDL_TRUE; + /*[data->context saveGraphicsState]; + data->saved = SDL_TRUE;*/ + + [NSGraphicsContext saveGraphicsState]; - //[[NSColor clearColor] set]; - //NSRectFill([[((SDL_WindowData*)shaper->window->driverdata)->nswindow contentView] frame]); - /* TODO: It looks like Cocoa can set a clipping path based on a list of rectangles. That's what we get from the - Windoze shape-calculation code: a list of rectangles. This will work... I think. */ + [NSGraphicsContext setCurrentContext:data->context]; + SDL_WindowData* window_data = (SDL_WindowData*)shaper->window->driverdata; + data->shape = SDL_CalculateShapeTree(*shapeMode,shape,SDL_FALSE); - NSBezierPath* clipPath = [NSBezierPath bezierPath]; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSBezierPath* clipPath = [[NSBezierPath bezierPath] autorelease]; SDL_PathConglomeration cong = {clipPath,shaper->window}; SDL_TraverseShapeTree(data->shape,(SDL_TraversalFunction)&ConglomerateShapeTree,(void*)&cong); + SDL_assert([NSGraphicsContext currentContext] != NULL); [clipPath addClip]; + + [NSGraphicsContext restoreGraphicsState]; + [pool release]; } int Cocoa_ResizeWindowShape(SDL_Window *window) { diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p01_shape24.png Binary file test/shapes/p01_shape24.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p01_shape32alpha.png Binary file test/shapes/p01_shape32alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p01_shape8.png Binary file test/shapes/p01_shape8.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p01_shape8alpha.png Binary file test/shapes/p01_shape8alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p02_shape24.png Binary file test/shapes/p02_shape24.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p02_shape32alpha.png Binary file test/shapes/p02_shape32alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p02_shape8.png Binary file test/shapes/p02_shape8.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p02_shape8alpha.png Binary file test/shapes/p02_shape8alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p03_shape24.png Binary file test/shapes/p03_shape24.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p03_shape8.png Binary file test/shapes/p03_shape8.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p04_shape1.png Binary file test/shapes/p04_shape1.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p04_shape24.png Binary file test/shapes/p04_shape24.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p04_shape32alpha.png Binary file test/shapes/p04_shape32alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p04_shape8.png Binary file test/shapes/p04_shape8.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p05_shape8.png Binary file test/shapes/p05_shape8.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p06_shape1alpha.png Binary file test/shapes/p06_shape1alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p06_shape24.png Binary file test/shapes/p06_shape24.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p06_shape32alpha.png Binary file test/shapes/p06_shape32alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p06_shape8.png Binary file test/shapes/p06_shape8.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p06_shape8alpha.png Binary file test/shapes/p06_shape8alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p07_shape1alpha.png Binary file test/shapes/p07_shape1alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p07_shape24.png Binary file test/shapes/p07_shape24.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p07_shape32alpha.png Binary file test/shapes/p07_shape32alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p07_shape8.png Binary file test/shapes/p07_shape8.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p07_shape8alpha.png Binary file test/shapes/p07_shape8alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p08_shape1alpha.png Binary file test/shapes/p08_shape1alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p08_shape24.png Binary file test/shapes/p08_shape24.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p08_shape32alpha.png Binary file test/shapes/p08_shape32alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p08_shape8.png Binary file test/shapes/p08_shape8.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p08_shape8alpha.png Binary file test/shapes/p08_shape8alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p09_shape24.png Binary file test/shapes/p09_shape24.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p09_shape32alpha.png Binary file test/shapes/p09_shape32alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p09_shape8.png Binary file test/shapes/p09_shape8.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p09_shape8alpha.png Binary file test/shapes/p09_shape8alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p10_shape1.png Binary file test/shapes/p10_shape1.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p10_shape1alpha.png Binary file test/shapes/p10_shape1alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p10_shape24.png Binary file test/shapes/p10_shape24.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p10_shape32alpha.png Binary file test/shapes/p10_shape32alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p10_shape8.png Binary file test/shapes/p10_shape8.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p10_shape8alpha.png Binary file test/shapes/p10_shape8alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p11_shape24.png Binary file test/shapes/p11_shape24.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p11_shape32alpha.png Binary file test/shapes/p11_shape32alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p11_shape8.png Binary file test/shapes/p11_shape8.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p11_shape8alpha.png Binary file test/shapes/p11_shape8alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p12_shape24.png Binary file test/shapes/p12_shape24.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p12_shape8.png Binary file test/shapes/p12_shape8.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p13_shape24.png Binary file test/shapes/p13_shape24.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p13_shape32alpha.png Binary file test/shapes/p13_shape32alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p13_shape8.png Binary file test/shapes/p13_shape8.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p13_shape8alpha.png Binary file test/shapes/p13_shape8alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p14_shape24.png Binary file test/shapes/p14_shape24.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p14_shape8.png Binary file test/shapes/p14_shape8.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p15_shape24.png Binary file test/shapes/p15_shape24.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p15_shape32alpha.png Binary file test/shapes/p15_shape32alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p15_shape8.png Binary file test/shapes/p15_shape8.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p15_shape8alpha.png Binary file test/shapes/p15_shape8alpha.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p16_shape1.png Binary file test/shapes/p16_shape1.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p16_shape24.png Binary file test/shapes/p16_shape24.png has changed diff -r 34fb492cefe3 -r fd5bb97ec05d test/shapes/p16_shape8.png Binary file test/shapes/p16_shape8.png has changed