comparison src/video/win32/SDL_win32shape.c @ 4807:c9eb95f29770

Added color-key mode and redid the code to work with it.
author Eli Gottlieb <eligottlieb@gmail.com>
date Thu, 22 Jul 2010 23:11:01 -0400
parents f14a8c05f5bb
children 329708ffe2a7
comparison
equal deleted inserted replaced
4806:007567dbb8c1 4807:c9eb95f29770
24 #include "SDL_win32shape.h" 24 #include "SDL_win32shape.h"
25 25
26 SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window) { 26 SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window) {
27 SDL_WindowShaper* result = malloc(sizeof(SDL_WindowShaper)); 27 SDL_WindowShaper* result = malloc(sizeof(SDL_WindowShaper));
28 result->window = window; 28 result->window = window;
29 result->alphacutoff = 0; 29 result->mode.mode = ShapeModeDefault;
30 result->mode.parameters.binarizationCutoff = 1;
30 result->usershownflag = 0; 31 result->usershownflag = 0;
31 //Put some driver-data here. 32 //Put some driver-data here.
32 window->shaper = result; 33 window->shaper = result;
33 int resized_properly = X11ResizeWindowShape(window); 34 int resized_properly = X11ResizeWindowShape(window);
34 assert(resized_properly == 0); 35 assert(resized_properly == 0);
40 if(!SDL_ISPIXELFORMAT_ALPHA(SDL_MasksToPixelFormatEnum(shape->format->BitsPerPixel,shape->format->Rmask,shape->format->Gmask,shape->format->Bmask,shape->format->Amask))) 41 if(!SDL_ISPIXELFORMAT_ALPHA(SDL_MasksToPixelFormatEnum(shape->format->BitsPerPixel,shape->format->Rmask,shape->format->Gmask,shape->format->Bmask,shape->format->Amask)))
41 return -2; 42 return -2;
42 if(shape->w != shaper->window->w || shape->h != shaper->window->h) 43 if(shape->w != shaper->window->w || shape->h != shaper->window->h)
43 return -3; 44 return -3;
44 45
45 /* Assume that shaper->alphacutoff already has a value, because SDL_SetWindowShape() should have given it one. */
46 /* 46 /*
47 * Start with empty region 47 * Start with empty region
48 */ 48 */
49 HRGN MaskRegion = CreateRectRgn(0, 0, 0, 0); 49 HRGN MaskRegion = CreateRectRgn(0, 0, 0, 0);
50 50
55 55
56 SDL_ShapeData *data = (SDL_ShapeData*)shaper->driverdata; 56 SDL_ShapeData *data = (SDL_ShapeData*)shaper->driverdata;
57 /* 57 /*
58 * Transfer binarized mask image into workbuffer 58 * Transfer binarized mask image into workbuffer
59 */ 59 */
60 SDL_CalculateShapeBitmap(shaper->alphacutoff,shape,data->shapebuffer,1,0xff); 60 SDL_CalculateShapeBitmap(shaper->mode,shape,data->shapebuffer,1,0xff);
61 61
62 //Move code over to here from AW_windowShape.c 62 //Move code over to here from AW_windowShape.c
63 Uint8 *pos1 = data->shapebuffer + width - 1; 63 Uint8 *pos1 = data->shapebuffer + width - 1;
64 Uint8 *pos2 = (Uint8*) pos1 + 1; 64 Uint8 *pos2 = (Uint8*) pos1 + 1;
65 int x = 0,y = 0; 65 int x = 0,y = 0;
336 if(data->shapebuffer == NULL) { 336 if(data->shapebuffer == NULL) {
337 SDL_SetError("Could not allocate memory for shaped-window bitmap."); 337 SDL_SetError("Could not allocate memory for shaped-window bitmap.");
338 return -1; 338 return -1;
339 } 339 }
340 } 340 }
341 else
342 memset(data->shapebuffer,0,data->buffersize);
341 343
342 window->shaper->usershownflag |= window->flags & SDL_WINDOW_SHOWN; 344 window->shaper->usershownflag |= window->flags & SDL_WINDOW_SHOWN;
343 345
344 return 0; 346 return 0;
345 } 347 }