Mercurial > sdl-ios-xcode
annotate src/video/SDL_shape.c @ 4853:f7cde99bf66a
Added last test shape. Because.
author | Eli Gottlieb <eligottlieb@gmail.com> |
---|---|
date | Sun, 15 Aug 2010 21:46:46 -0400 |
parents | c19c729eb201 |
children | 6d4d6605a0d3 |
rev | line source |
---|---|
4765
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
1 /* |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
3 Copyright (C) 2010 Eli Gottlieb |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
4 |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
9 |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
14 |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
18 |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
19 Eli Gottlieb |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
20 eligottlieb@gmail.com |
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
21 */ |
4769
83f9b95da263
Added the standard headers and footers that make SDL_shape.h and SDL_shape.c integrate properly into the build.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4766
diff
changeset
|
22 #include "SDL_config.h" |
4776
29dcad9c58b3
Removed and added back SDL_shape.{c,h} wholesale. Will this get them tracked properly?
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4775
diff
changeset
|
23 |
4769
83f9b95da263
Added the standard headers and footers that make SDL_shape.h and SDL_shape.c integrate properly into the build.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4766
diff
changeset
|
24 #include "SDL.h" |
4841
740e833b2c00
Fixed overwriting of SDL_shape.c in merge.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4839
diff
changeset
|
25 #include "SDL_assert.h" |
4769
83f9b95da263
Added the standard headers and footers that make SDL_shape.h and SDL_shape.c integrate properly into the build.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4766
diff
changeset
|
26 #include "SDL_video.h" |
83f9b95da263
Added the standard headers and footers that make SDL_shape.h and SDL_shape.c integrate properly into the build.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4766
diff
changeset
|
27 #include "SDL_sysvideo.h" |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
28 #include "SDL_pixels.h" |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
29 #include "SDL_surface.h" |
4765
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
30 #include "SDL_shape.h" |
4841
740e833b2c00
Fixed overwriting of SDL_shape.c in merge.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4839
diff
changeset
|
31 #include "SDL_shape_internals.h" |
4766
7b50faf23907
Moved SDL_shape.h, and building out the API as needed by SDL_Eyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4765
diff
changeset
|
32 |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
33 SDL_Window* |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
34 SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) { |
4852
c19c729eb201
Added hiding-as-positioning trick and finally fixed flags.
egottlieb
parents:
4851
diff
changeset
|
35 SDL_Window *result = SDL_CreateWindow(title,x,y,w,h,flags | SDL_WINDOW_BORDERLESS & ~SDL_WINDOW_FULLSCREEN & ~SDL_WINDOW_RESIZABLE); |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
36 if(result != NULL) { |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
37 result->shaper = result->display->device->shape_driver.CreateShaper(result); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
38 if(result->shaper != NULL) { |
4851
5624fb0190b5
Changed flags and positioning (for the fake-hiding) as Andreas recommended.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4850
diff
changeset
|
39 result->shaper->userx = x; |
5624fb0190b5
Changed flags and positioning (for the fake-hiding) as Andreas recommended.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4850
diff
changeset
|
40 result->shaper->usery = y; |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
41 result->shaper->mode.mode = ShapeModeDefault; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
42 result->shaper->mode.parameters.binarizationCutoff = 1; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
43 result->shaper->hasshape = SDL_FALSE; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
44 return result; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
45 } |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
46 else { |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
47 SDL_DestroyWindow(result); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
48 return NULL; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
49 } |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
50 } |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
51 else |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
52 return NULL; |
4766
7b50faf23907
Moved SDL_shape.h, and building out the API as needed by SDL_Eyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4765
diff
changeset
|
53 } |
7b50faf23907
Moved SDL_shape.h, and building out the API as needed by SDL_Eyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4765
diff
changeset
|
54 |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
55 SDL_bool |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
56 SDL_IsShapedWindow(const SDL_Window *window) { |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
57 if(window == NULL) |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
58 return SDL_FALSE; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
59 else |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
60 return (SDL_bool)(window->shaper != NULL); |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
61 } |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
62 |
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:
4810
diff
changeset
|
63 /* REQUIRES that bitmap point to a w-by-h bitmap with ppb pixels-per-byte. */ |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
64 void |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
65 SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* bitmap,Uint8 ppb) { |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
66 int x = 0; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
67 int y = 0; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
68 Uint8 r = 0,g = 0,b = 0,alpha = 0; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
69 Uint8* pixel = NULL; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
70 Uint32 bitmap_pixel,pixel_value = 0,mask_value = 0; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
71 SDL_Color key; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
72 if(SDL_MUSTLOCK(shape)) |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
73 SDL_LockSurface(shape); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
74 pixel = (Uint8*)shape->pixels; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
75 for(y = 0;y<shape->h;y++) { |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
76 for(x=0;x<shape->w;x++) { |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
77 alpha = 0; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
78 pixel_value = 0; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
79 pixel = (Uint8 *)(shape->pixels) + (y*shape->pitch) + (x*shape->format->BytesPerPixel); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
80 switch(shape->format->BytesPerPixel) { |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
81 case(1): |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
82 pixel_value = *(Uint8*)pixel; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
83 break; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
84 case(2): |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
85 pixel_value = *(Uint16*)pixel; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
86 break; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
87 case(3): |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
88 pixel_value = *(Uint32*)pixel & (~shape->format->Amask); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
89 break; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
90 case(4): |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
91 pixel_value = *(Uint32*)pixel; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
92 break; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
93 } |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
94 SDL_GetRGBA(pixel_value,shape->format,&r,&g,&b,&alpha); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
95 bitmap_pixel = y*shape->w + x; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
96 switch(mode.mode) { |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
97 case(ShapeModeDefault): |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
98 mask_value = (alpha >= 1 ? 1 : 0); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
99 break; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
100 case(ShapeModeBinarizeAlpha): |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
101 mask_value = (alpha >= mode.parameters.binarizationCutoff ? 1 : 0); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
102 break; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
103 case(ShapeModeReverseBinarizeAlpha): |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
104 mask_value = (alpha <= mode.parameters.binarizationCutoff ? 1 : 0); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
105 break; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
106 case(ShapeModeColorKey): |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
107 key = mode.parameters.colorKey; |
4846
4f1573996a65
Fixed a bug in X11 shaping that refused to use color-key mode.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4843
diff
changeset
|
108 mask_value = ((key.r != r || key.g != g || key.b != b) ? 1 : 0); |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
109 break; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
110 } |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
111 bitmap[bitmap_pixel / ppb] |= mask_value << (7 - ((ppb - 1) - (bitmap_pixel % ppb))); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
112 } |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
113 } |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
114 if(SDL_MUSTLOCK(shape)) |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
115 SDL_UnlockSurface(shape); |
4766
7b50faf23907
Moved SDL_shape.h, and building out the API as needed by SDL_Eyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4765
diff
changeset
|
116 } |
7b50faf23907
Moved SDL_shape.h, and building out the API as needed by SDL_Eyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4765
diff
changeset
|
117 |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
118 SDL_ShapeTree* |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
119 RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* mask,SDL_Rect dimensions) { |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
120 int x = 0,y = 0; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
121 Uint8* pixel = NULL; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
122 Uint32 pixel_value = 0; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
123 Uint8 r = 0,g = 0,b = 0,a = 0; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
124 SDL_bool pixel_opaque = SDL_FALSE; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
125 int last_opaque = -1; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
126 SDL_Color key; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
127 SDL_ShapeTree* result = (SDL_ShapeTree*)SDL_malloc(sizeof(SDL_ShapeTree)); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
128 SDL_Rect next = {0,0,0,0}; |
4852
c19c729eb201
Added hiding-as-positioning trick and finally fixed flags.
egottlieb
parents:
4851
diff
changeset
|
129 for(y=dimensions.y;y<dimensions.y + dimensions.h;y++) { |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
130 for(x=dimensions.x;x<dimensions.x + dimensions.w;x++) { |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
131 pixel_value = 0; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
132 pixel = (Uint8 *)(mask->pixels) + (y*mask->pitch) + (x*mask->format->BytesPerPixel); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
133 switch(mask->format->BytesPerPixel) { |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
134 case(1): |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
135 pixel_value = *(Uint8*)pixel; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
136 break; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
137 case(2): |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
138 pixel_value = *(Uint16*)pixel; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
139 break; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
140 case(3): |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
141 pixel_value = *(Uint32*)pixel & (~mask->format->Amask); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
142 break; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
143 case(4): |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
144 pixel_value = *(Uint32*)pixel; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
145 break; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
146 } |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
147 SDL_GetRGBA(pixel_value,mask->format,&r,&g,&b,&a); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
148 switch(mode.mode) { |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
149 case(ShapeModeDefault): |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
150 pixel_opaque = (a >= 1 ? SDL_TRUE : SDL_FALSE); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
151 break; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
152 case(ShapeModeBinarizeAlpha): |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
153 pixel_opaque = (a >= mode.parameters.binarizationCutoff ? SDL_TRUE : SDL_FALSE); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
154 break; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
155 case(ShapeModeReverseBinarizeAlpha): |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
156 pixel_opaque = (a <= mode.parameters.binarizationCutoff ? SDL_TRUE : SDL_FALSE); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
157 break; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
158 case(ShapeModeColorKey): |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
159 key = mode.parameters.colorKey; |
4850
14870d46ee2d
Mostly seem to have fixed SDL_CalculateShapeTree. Mostly. There still seem to be some rendering artifacts, stepping effects, and such on Windows -- which indicates subtle logic errors in SDL_CalculateShapeTree().
egottlieb
parents:
4849
diff
changeset
|
160 pixel_opaque = ((key.r != r || key.g != g || key.b != b) ? SDL_TRUE : SDL_FALSE); |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
161 break; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
162 } |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
163 if(last_opaque == -1) |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
164 last_opaque = pixel_opaque; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
165 if(last_opaque != pixel_opaque) { |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
166 result->kind = QuadShape; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
167 //These will stay the same. |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
168 next.w = dimensions.w / 2; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
169 next.h = dimensions.h / 2; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
170 //These will change from recursion to recursion. |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
171 next.x = dimensions.x; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
172 next.y = dimensions.y; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
173 result->data.children.upleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next); |
4850
14870d46ee2d
Mostly seem to have fixed SDL_CalculateShapeTree. Mostly. There still seem to be some rendering artifacts, stepping effects, and such on Windows -- which indicates subtle logic errors in SDL_CalculateShapeTree().
egottlieb
parents:
4849
diff
changeset
|
174 next.x += next.w; |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
175 //Unneeded: next.y = dimensions.y; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
176 result->data.children.upright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
177 next.x = dimensions.x; |
4850
14870d46ee2d
Mostly seem to have fixed SDL_CalculateShapeTree. Mostly. There still seem to be some rendering artifacts, stepping effects, and such on Windows -- which indicates subtle logic errors in SDL_CalculateShapeTree().
egottlieb
parents:
4849
diff
changeset
|
178 next.y += next.h; |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
179 result->data.children.downleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next); |
4850
14870d46ee2d
Mostly seem to have fixed SDL_CalculateShapeTree. Mostly. There still seem to be some rendering artifacts, stepping effects, and such on Windows -- which indicates subtle logic errors in SDL_CalculateShapeTree().
egottlieb
parents:
4849
diff
changeset
|
180 next.x += next.w; |
14870d46ee2d
Mostly seem to have fixed SDL_CalculateShapeTree. Mostly. There still seem to be some rendering artifacts, stepping effects, and such on Windows -- which indicates subtle logic errors in SDL_CalculateShapeTree().
egottlieb
parents:
4849
diff
changeset
|
181 //Unneeded: next.y = dimensions.y + dimensions.h /2; |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
182 result->data.children.downright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
183 return result; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
184 } |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
185 } |
4852
c19c729eb201
Added hiding-as-positioning trick and finally fixed flags.
egottlieb
parents:
4851
diff
changeset
|
186 } |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
187 //If we never recursed, all the pixels in this quadrant have the same "value". |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
188 result->kind = (last_opaque == SDL_TRUE ? OpaqueShape : TransparentShape); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
189 result->data.shape = dimensions; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
190 return result; |
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:
4810
diff
changeset
|
191 } |
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:
4810
diff
changeset
|
192 |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
193 SDL_ShapeTree* |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
194 SDL_CalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* shape) { |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
195 SDL_Rect dimensions = {0,0,shape->w,shape->h}; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
196 SDL_ShapeTree* result = NULL; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
197 if(SDL_MUSTLOCK(shape)) |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
198 SDL_LockSurface(shape); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
199 result = RecursivelyCalculateShapeTree(mode,shape,dimensions); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
200 if(SDL_MUSTLOCK(shape)) |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
201 SDL_UnlockSurface(shape); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
202 return result; |
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:
4810
diff
changeset
|
203 } |
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:
4810
diff
changeset
|
204 |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
205 void |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
206 SDL_TraverseShapeTree(SDL_ShapeTree *tree,SDL_TraversalFunction function,void* closure) { |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
207 SDL_assert(tree != NULL); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
208 if(tree->kind == QuadShape) { |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
209 SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upleft,function,closure); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
210 SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upright,function,closure); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
211 SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.downleft,function,closure); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
212 SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.downright,function,closure); |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
213 } |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
214 else |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
215 function(tree,closure); |
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:
4810
diff
changeset
|
216 } |
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:
4810
diff
changeset
|
217 |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
218 void |
4850
14870d46ee2d
Mostly seem to have fixed SDL_CalculateShapeTree. Mostly. There still seem to be some rendering artifacts, stepping effects, and such on Windows -- which indicates subtle logic errors in SDL_CalculateShapeTree().
egottlieb
parents:
4849
diff
changeset
|
219 SDL_FreeShapeTree(SDL_ShapeTree** shape_tree) { |
14870d46ee2d
Mostly seem to have fixed SDL_CalculateShapeTree. Mostly. There still seem to be some rendering artifacts, stepping effects, and such on Windows -- which indicates subtle logic errors in SDL_CalculateShapeTree().
egottlieb
parents:
4849
diff
changeset
|
220 if((*shape_tree)->kind == QuadShape) { |
14870d46ee2d
Mostly seem to have fixed SDL_CalculateShapeTree. Mostly. There still seem to be some rendering artifacts, stepping effects, and such on Windows -- which indicates subtle logic errors in SDL_CalculateShapeTree().
egottlieb
parents:
4849
diff
changeset
|
221 SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.upleft); |
14870d46ee2d
Mostly seem to have fixed SDL_CalculateShapeTree. Mostly. There still seem to be some rendering artifacts, stepping effects, and such on Windows -- which indicates subtle logic errors in SDL_CalculateShapeTree().
egottlieb
parents:
4849
diff
changeset
|
222 SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.upright); |
14870d46ee2d
Mostly seem to have fixed SDL_CalculateShapeTree. Mostly. There still seem to be some rendering artifacts, stepping effects, and such on Windows -- which indicates subtle logic errors in SDL_CalculateShapeTree().
egottlieb
parents:
4849
diff
changeset
|
223 SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.downleft); |
14870d46ee2d
Mostly seem to have fixed SDL_CalculateShapeTree. Mostly. There still seem to be some rendering artifacts, stepping effects, and such on Windows -- which indicates subtle logic errors in SDL_CalculateShapeTree().
egottlieb
parents:
4849
diff
changeset
|
224 SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.downright); |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
225 } |
4850
14870d46ee2d
Mostly seem to have fixed SDL_CalculateShapeTree. Mostly. There still seem to be some rendering artifacts, stepping effects, and such on Windows -- which indicates subtle logic errors in SDL_CalculateShapeTree().
egottlieb
parents:
4849
diff
changeset
|
226 SDL_free(*shape_tree); |
14870d46ee2d
Mostly seem to have fixed SDL_CalculateShapeTree. Mostly. There still seem to be some rendering artifacts, stepping effects, and such on Windows -- which indicates subtle logic errors in SDL_CalculateShapeTree().
egottlieb
parents:
4849
diff
changeset
|
227 *shape_tree = NULL; |
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:
4810
diff
changeset
|
228 } |
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:
4810
diff
changeset
|
229 |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
230 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
|
231 SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) { |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
232 int result; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
233 if(window == NULL || !SDL_IsShapedWindow(window)) |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
234 //The window given was not a shapeable window. |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
235 return SDL_NONSHAPEABLE_WINDOW; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
236 if(shape == NULL) |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
237 //Invalid shape argument. |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
238 return SDL_INVALID_SHAPE_ARGUMENT; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
239 |
4849
0b918c186938
Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents:
4848
diff
changeset
|
240 if(shape_mode != NULL) |
0b918c186938
Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents:
4848
diff
changeset
|
241 window->shaper->mode = *shape_mode; |
0b918c186938
Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents:
4848
diff
changeset
|
242 result = window->display->device->shape_driver.SetWindowShape(window->shaper,shape,shape_mode); |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
243 window->shaper->hasshape = SDL_TRUE; |
4852
c19c729eb201
Added hiding-as-positioning trick and finally fixed flags.
egottlieb
parents:
4851
diff
changeset
|
244 if(window->shaper->userx != 0 && window->shaper->usery != 0) { |
4851
5624fb0190b5
Changed flags and positioning (for the fake-hiding) as Andreas recommended.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4850
diff
changeset
|
245 SDL_SetWindowPosition(window,window->shaper->userx,window->shaper->usery); |
5624fb0190b5
Changed flags and positioning (for the fake-hiding) as Andreas recommended.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4850
diff
changeset
|
246 window->shaper->userx = 0; |
5624fb0190b5
Changed flags and positioning (for the fake-hiding) as Andreas recommended.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4850
diff
changeset
|
247 window->shaper->usery = 0; |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
248 } |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
249 return result; |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
250 } |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
251 |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
252 SDL_bool |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
253 SDL_WindowHasAShape(SDL_Window *window) { |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
254 if (window == NULL || !SDL_IsShapedWindow(window)) |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
255 return SDL_FALSE; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
256 return window->shaper->hasshape; |
4778
9838d3525a1b
Stubbed out the new get/set parameter functions, added the start of the enum, union, and struct for those parameters themselves, and added doxygen comments throughout the SDL_shape.h header.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4776
diff
changeset
|
257 } |
9838d3525a1b
Stubbed out the new get/set parameter functions, added the start of the enum, union, and struct for those parameters themselves, and added doxygen comments throughout the SDL_shape.h header.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4776
diff
changeset
|
258 |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
259 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
|
260 SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode) { |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
261 if(window != NULL && SDL_IsShapedWindow(window)) { |
4849
0b918c186938
Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents:
4848
diff
changeset
|
262 if(shape_mode == NULL) { |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
263 if(SDL_WindowHasAShape(window)) |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
264 //The window given has a shape. |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
265 return 0; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
266 else |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
267 //The window given is shapeable but lacks a shape. |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
268 return SDL_WINDOW_LACKS_SHAPE; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
269 } |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
270 else { |
4849
0b918c186938
Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
egottlieb
parents:
4848
diff
changeset
|
271 *shape_mode = window->shaper->mode; |
4843
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
272 return 0; |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
273 } |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
274 } |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
275 else |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
276 //The window given is not a valid shapeable window. |
0998d1b5dd23
Fixed formatting of SDL_shape.c post-merge again.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4841
diff
changeset
|
277 return SDL_NONSHAPEABLE_WINDOW; |
4778
9838d3525a1b
Stubbed out the new get/set parameter functions, added the start of the enum, union, and struct for those parameters themselves, and added doxygen comments throughout the SDL_shape.h header.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4776
diff
changeset
|
278 } |