annotate src/video/win32/SDL_win32shape.c @ 4849:0b918c186938

Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
author egottlieb
date Sat, 14 Aug 2010 16:14:36 -0400
parents 40b46225e3cf
children 14870d46ee2d
rev   line source
4777
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
1 /*
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
3 Copyright (C) 2010 Eli Gottlieb
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
4
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
9
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
13 Lesser General Public License for more details.
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
14
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
18
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
19 Eli Gottlieb
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
20 eligottlieb@gmail.com
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
21 */
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
22
4849
0b918c186938 Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents: 4848
diff changeset
23 #include <stdio.h>
4822
55f32099a4b5 Worked on Windows implementation and the quad-trees.
egottlieb
parents: 4815
diff changeset
24 #include "SDL_win32shape.h"
4815
93402b9dd20c Added Andreas's patch to fix my silly C++-style errors.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4813
diff changeset
25 #include "SDL_win32video.h"
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.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4777
diff changeset
26
4838
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
27 SDL_WindowShaper*
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
28 Win32_CreateShaper(SDL_Window * window) {
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
29 int resized_properly;
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
30 SDL_WindowShaper* result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper));
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
31 result->window = window;
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
32 result->mode.mode = ShapeModeDefault;
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
33 result->mode.parameters.binarizationCutoff = 1;
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
34 result->usershownflag = 0;
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
35 result->driverdata = (SDL_ShapeData*)SDL_malloc(sizeof(SDL_ShapeData));
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
36 ((SDL_ShapeData*)result->driverdata)->mask_tree = NULL;
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
37 //Put some driver-data here.
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
38 window->shaper = result;
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
39 resized_properly = Win32_ResizeWindowShape(window);
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
40 if (resized_properly != 0)
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
41 return NULL;
4815
93402b9dd20c Added Andreas's patch to fix my silly C++-style errors.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4813
diff changeset
42
4838
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
43 return result;
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.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4777
diff changeset
44 }
4777
6e03d73054d7 Fixed names of driver-specific implementation files.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
45
4844
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
46 typedef struct {
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
47 POINT corners[4];
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
48 void* next;
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
49 } SDL_ShapeRect;
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
50
4838
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
51 void
4844
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
52 CombineRectRegions(SDL_ShapeTree* node,void* closure) {
4849
0b918c186938 Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents: 4848
diff changeset
53 char debug_str[200];
4844
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
54 SDL_ShapeRect* rect_list = *((SDL_ShapeRect**)closure);
4838
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
55 if(node->kind == OpaqueShape) {
4844
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
56 SDL_ShapeRect* rect = SDL_malloc(sizeof(SDL_ShapeRect));
4849
0b918c186938 Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents: 4848
diff changeset
57 sprintf_s(&debug_str[0],200,"x: %u y: %u, x+w: %u, y+h: %u\n",
0b918c186938 Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents: 4848
diff changeset
58 node->data.shape.x,node->data.shape.y,
0b918c186938 Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents: 4848
diff changeset
59 node->data.shape.x + node->data.shape.w,node->data.shape.y + node->data.shape.h);
0b918c186938 Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents: 4848
diff changeset
60 OutputDebugStringA(debug_str);
0b918c186938 Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents: 4848
diff changeset
61 OutputDebugStringA("Converting SDL_ShapeTree opaque node to Windows rectangle.\n");
4844
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
62 rect->corners[0].x = node->data.shape.x; rect->corners[0].y = node->data.shape.y;
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
63 rect->corners[1].x = node->data.shape.x + node->data.shape.w; rect->corners[1].y = node->data.shape.y;
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
64 rect->corners[2].x = node->data.shape.x + node->data.shape.w; rect->corners[2].y = node->data.shape.y + node->data.shape.h;
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
65 rect->corners[3].x = node->data.shape.x; rect->corners[3].y = node->data.shape.y + node->data.shape.h;
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
66 rect->next = *((SDL_ShapeRect**)closure);
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
67 *((SDL_ShapeRect**)closure) = rect;
4838
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
68 }
4813
5b4c7d7d8953 Wrote out the system for breaking shape-masks into quad-trees of rectangles, and added code to conglomerate those quad-trees of rectangles into regions for setting shapes under Win32.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4809
diff changeset
69 }
5b4c7d7d8953 Wrote out the system for breaking shape-masks into quad-trees of rectangles, and added code to conglomerate those quad-trees of rectangles into regions for setting shapes under Win32.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4809
diff changeset
70
4844
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
71 Uint32 num_shape_rects(SDL_ShapeRect* rect) {
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
72 if(rect == NULL)
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
73 return 0;
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
74 else
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
75 return 1 + num_shape_rects(rect->next);
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
76 }
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
77
4838
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
78 int
4849
0b918c186938 Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents: 4848
diff changeset
79 Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) {
4838
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
80 SDL_ShapeData *data;
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
81 HRGN mask_region;
4844
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
82 SDL_ShapeRect* rects = NULL,*old = NULL;
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
83 Uint16 num_rects = 0,i = 0;
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
84 int* polygonVertexNumbers = NULL;
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
85 POINT* polygons = NULL;
4849
0b918c186938 Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents: 4848
diff changeset
86 char debug_str[200];
4815
93402b9dd20c Added Andreas's patch to fix my silly C++-style errors.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4813
diff changeset
87
4838
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
88 if (shaper == NULL || shape == NULL)
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
89 return SDL_INVALID_SHAPE_ARGUMENT;
4849
0b918c186938 Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents: 4848
diff changeset
90 if(shape->format->Amask == 0 && shape_mode->mode != ShapeModeColorKey || shape->w != shaper->window->w || shape->h != shaper->window->h)
4838
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
91 return SDL_INVALID_SHAPE_ARGUMENT;
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
92
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
93 data = (SDL_ShapeData*)shaper->driverdata;
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
94 if(data->mask_tree != NULL)
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
95 SDL_FreeShapeTree(&data->mask_tree);
4849
0b918c186938 Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents: 4848
diff changeset
96 data->mask_tree = SDL_CalculateShapeTree(*shape_mode,shape);
4838
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
97
4844
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
98 SDL_TraverseShapeTree(data->mask_tree,&CombineRectRegions,&rects);
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
99 num_rects = num_shape_rects(rects);
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
100 polygonVertexNumbers = (int*)SDL_malloc(sizeof(int)*num_rects);
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
101 for(i=0;i<num_rects;i++)
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
102 polygonVertexNumbers[i] = 4;
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
103 polygons = (POINT*)SDL_malloc(sizeof(POINT)*4*num_rects);
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
104 for(i=0;i<num_rects*4;i++) {
4849
0b918c186938 Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents: 4848
diff changeset
105 polygons[i] = rects->corners[i % 4];
4844
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
106 if(i % 4 == 3) {
4849
0b918c186938 Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents: 4848
diff changeset
107 sprintf_s(&debug_str[0],200,"x: %u y: %u, x+w: %u, y+h: %u\n",
0b918c186938 Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents: 4848
diff changeset
108 rects->corners[0].x,rects->corners[0].y,
0b918c186938 Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents: 4848
diff changeset
109 rects->corners[2].x,rects->corners[2].y);
0b918c186938 Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents: 4848
diff changeset
110 OutputDebugStringA(debug_str);
4844
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
111 old = rects;
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
112 rects = rects->next;
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
113 SDL_free(old);
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
114 }
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
115 }
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
116
4838
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
117 /*
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
118 * Set the new region mask for the window
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
119 */
4848
40b46225e3cf Added SDL_SetWindowPosition() call to SDL_SetWindowShape(), going to see what this does on Windows.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4844
diff changeset
120 mask_region = CreatePolyPolygonRgn(polygons,polygonVertexNumbers,num_rects,WINDING);
4844
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
121 SetWindowRgn(((SDL_WindowData *)(shaper->window->driverdata))->hwnd, mask_region, TRUE);
c4f5bcaf7572 Switched over to poly-polygon region building and shape-tree traversal for Win32.
egottlieb
parents: 4839
diff changeset
122
4848
40b46225e3cf Added SDL_SetWindowPosition() call to SDL_SetWindowShape(), going to see what this does on Windows.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4844
diff changeset
123 SDL_free(polygons);
40b46225e3cf Added SDL_SetWindowPosition() call to SDL_SetWindowShape(), going to see what this does on Windows.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4844
diff changeset
124 SDL_free(polygonVertexNumbers);
4838
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
125
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
126 return 0;
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.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4777
diff changeset
127 }
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.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4777
diff changeset
128
4838
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
129 int
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
130 Win32_ResizeWindowShape(SDL_Window *window) {
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
131 SDL_ShapeData* data;
4815
93402b9dd20c Added Andreas's patch to fix my silly C++-style errors.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4813
diff changeset
132
4838
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
133 if (window == NULL)
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
134 return -1;
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
135 data = (SDL_ShapeData *)window->shaper->driverdata;
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
136 if (data == NULL)
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
137 return -1;
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
138
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
139 if(data->mask_tree != NULL)
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
140 SDL_FreeShapeTree(&data->mask_tree);
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
141
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
142 window->shaper->usershownflag |= window->flags & SDL_WINDOW_SHOWN;
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
143
1f9915666afd Reformatting code to match the rest of SDL. Variable names seem OK; replaced tabs with 4 spaces each for indentation.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4822
diff changeset
144 return 0;
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.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4777
diff changeset
145 }