comparison src/video/win32/SDL_win32shape.c @ 4785:ef8b32ef9793

Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
author Eli Gottlieb <eligottlieb@gmail.com>
date Tue, 06 Jul 2010 22:05:22 -0400
parents 6e03d73054d7
children e25ad8d97027
comparison
equal deleted inserted replaced
4784:2878650e0dc9 4785:ef8b32ef9793
18 18
19 Eli Gottlieb 19 Eli Gottlieb
20 eligottlieb@gmail.com 20 eligottlieb@gmail.com
21 */ 21 */
22 22
23 #include "SDL_shape.h" 23 #include <windows.h>
24 #include "SDL_win32shape.h"
24 25
25 /* Functions implementing shaped windows for Win32 will be implemented when the API is set. */ 26 SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window) {
27 SDL_WindowShaper* result = malloc(sizeof(SDL_WindowShaper));
28 result->window = window;
29 result->alphacutoff = 0;
30 result->usershownflag = 0;
31 //Put some driver-data here.
32 window->shaper = result;
33 int resized_properly = X11ResizeWindowShape(window);
34 assert(resized_properly == 0);
35 return result;
36 }
37
38 int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
39 assert(shaper != NULL && shape != NULL);
40 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 if(shape->w != shaper->window->w || shape->h != shaper->window->h)
43 return -3;
44
45 /* Assume that shaper->alphacutoff already has a value, because SDL_SetWindowShape() should have given it one. */
46 /*
47 * Start with empty region
48 */
49 HRGN MaskRegion = CreateRectRgn(0, 0, 0, 0);
50
51 unsigned int pitch = shape->pitch;
52 unsigned int width = shape->width;
53 unsigned int height = shape->height;
54 unsigned int dy = pitch - width;
55
56 SDL_ShapeData *data = (SDL_ShapeData*)shaper->driverdata;
57 /*
58 * Transfer binarized mask image into workbuffer
59 */
60 SDL_CalculateShapeBitmap(shaper->alphacutoff,shape,data->shapebuffer,1,0xff);
61 //Move code over to here from AW_windowShape.c
62
63 }
64
65 int Win32_ResizeWindowShape(SDL_Window *window) {
66 SDL_ShapeData* data = window->shaper->driverdata;
67 assert(data != NULL);
68
69 unsigned int buffersize = window->w * window->h;
70 if(data->buffersize != buffersize || data->shapebuffer == NULL) {
71 data->buffersize = buffersize;
72 if(data->shapebuffer != NULL)
73 free(data->shapebuffer);
74 data->shapebuffer = malloc(data->buffersize);
75 if(data->shapebuffer == NULL) {
76 SDL_SetError("Could not allocate memory for shaped-window bitmap.");
77 return -1;
78 }
79 }
80
81 window->shaper->usershownflag = window->flags & SDL_WINDOW_SHOWN;
82
83 return 0;
84 }