diff src/video/win32/SDL_win32shape.c @ 4822:55f32099a4b5

Worked on Windows implementation and the quad-trees.
author egottlieb
date Mon, 02 Aug 2010 01:54:59 -0400
parents 93402b9dd20c
children 2e446923c9fb 1f9915666afd
line wrap: on
line diff
--- a/src/video/win32/SDL_win32shape.c	Sun Aug 01 23:27:22 2010 -0400
+++ b/src/video/win32/SDL_win32shape.c	Mon Aug 02 01:54:59 2010 -0400
@@ -20,7 +20,7 @@
     eligottlieb@gmail.com
 */
 
-#include "SDL_win32shape.h"
+#include "SDL_win32shape.h"
 #include "SDL_win32video.h"
 
 SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window) {
@@ -30,6 +30,8 @@
 	result->mode.mode = ShapeModeDefault;
 	result->mode.parameters.binarizationCutoff = 1;
 	result->usershownflag = 0;
+	result->driverdata = (SDL_ShapeData*)SDL_malloc(sizeof(SDL_ShapeData));
+	((SDL_ShapeData*)result->driverdata)->mask_tree = NULL;
 	//Put some driver-data here.
 	window->shaper = result;
 	resized_properly = Win32_ResizeWindowShape(window);
@@ -51,15 +53,17 @@
 int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
 	SDL_ShapeData *data;
 	HRGN mask_region;
-    SDL_WindowData *windowdata;
+    SDL_WindowData *windowdata;
     HWND hwnd;
 
 	if (shaper == NULL || shape == NULL)
 		return SDL_INVALID_SHAPE_ARGUMENT;
-	if(!SDL_ISPIXELFORMAT_ALPHA(SDL_MasksToPixelFormatEnum(shape->format->BitsPerPixel,shape->format->Rmask,shape->format->Gmask,shape->format->Bmask,shape->format->Amask)) && shapeMode->mode != ShapeModeColorKey || shape->w != shaper->window->w || shape->h != shaper->window->h)
+	if(shape->format->Amask == 0 && shapeMode->mode != ShapeModeColorKey || shape->w != shaper->window->w || shape->h != shaper->window->h)
 		return SDL_INVALID_SHAPE_ARGUMENT;
 	
 	data = (SDL_ShapeData*)shaper->driverdata;
+	if(data->mask_tree != NULL)
+		SDL_FreeShapeTree(&data->mask_tree);
 	data->mask_tree = SDL_CalculateShapeTree(*shapeMode,shape,SDL_FALSE);
 	
 	/*
@@ -72,7 +76,7 @@
 	/*
 	 * Set the new region mask for the window 
 	 */
-	windowdata=(SDL_WindowData *)(shaper->window->driverdata);
+	windowdata=(SDL_WindowData *)(shaper->window->driverdata);
 	hwnd = windowdata->hwnd;
 	SetWindowRgn(hwnd, mask_region, TRUE);