Mercurial > sdl-ios-xcode
annotate src/video/SDL_shape.c @ 4806:007567dbb8c1
Reapplied Win32 make-it-build patch. What's going on? Still get rendering artifacts when testing on x11, have literally no idea why.
author | Eli Gottlieb <eligottlieb@gmail.com> |
---|---|
date | Tue, 20 Jul 2010 12:42:43 -0400 |
parents | f14a8c05f5bb |
children | c9eb95f29770 |
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" |
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
|
25 #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
|
26 #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
|
27 #include "SDL_pixels.h" |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
28 #include "SDL_surface.h" |
4765
5ff305de5834
Added stub files, working on sample program SDLeyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff
changeset
|
29 #include "SDL_shape.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
|
30 |
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
|
31 SDL_Window* SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) { |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
32 SDL_Window *result = SDL_CreateWindow(title,x,y,w,h,SDL_WINDOW_BORDERLESS | flags & !SDL_WINDOW_FULLSCREEN & !SDL_WINDOW_SHOWN); |
4796
e8caf178d082
Added in Visual Studio patch.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4795
diff
changeset
|
33 if(result != NULL) { |
e8caf178d082
Added in Visual Studio patch.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4795
diff
changeset
|
34 result->shaper = result->display->device->shape_driver.CreateShaper(result); |
e8caf178d082
Added in Visual Studio patch.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4795
diff
changeset
|
35 if(result->shaper != NULL) { |
e8caf178d082
Added in Visual Studio patch.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4795
diff
changeset
|
36 result->shaper->usershownflag = flags & SDL_WINDOW_SHOWN; |
e8caf178d082
Added in Visual Studio patch.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4795
diff
changeset
|
37 result->shaper->alphacutoff = 1; |
e8caf178d082
Added in Visual Studio patch.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4795
diff
changeset
|
38 result->shaper->hasshape = SDL_FALSE; |
e8caf178d082
Added in Visual Studio patch.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4795
diff
changeset
|
39 return result; |
e8caf178d082
Added in Visual Studio patch.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4795
diff
changeset
|
40 } |
e8caf178d082
Added in Visual Studio patch.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4795
diff
changeset
|
41 else { |
e8caf178d082
Added in Visual Studio patch.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4795
diff
changeset
|
42 SDL_DestroyWindow(result); |
e8caf178d082
Added in Visual Studio patch.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4795
diff
changeset
|
43 return NULL; |
e8caf178d082
Added in Visual Studio patch.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4795
diff
changeset
|
44 } |
e8caf178d082
Added in Visual Studio patch.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4795
diff
changeset
|
45 } |
e8caf178d082
Added in Visual Studio patch.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4795
diff
changeset
|
46 else |
e8caf178d082
Added in Visual Studio patch.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4795
diff
changeset
|
47 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
|
48 } |
7b50faf23907
Moved SDL_shape.h, and building out the API as needed by SDL_Eyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4765
diff
changeset
|
49 |
4781
fc4c775b468a
Added Andreas's fixes to the header and stub file for SDL_shape.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4780
diff
changeset
|
50 SDL_bool SDL_IsShapedWindow(const SDL_Window *window) { |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
51 if(window == NULL) |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
52 return SDL_FALSE; |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
53 else |
4789
a6bc01875d20
Fixed a pair of syntax errors.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4787
diff
changeset
|
54 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
|
55 } |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
56 |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
57 /* REQUIRES that bitmap point to a w-by-h bitmap with 1bpp. */ |
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:
4782
diff
changeset
|
58 void SDL_CalculateShapeBitmap(Uint8 alphacutoff,SDL_Surface *shape,Uint8* bitmap,Uint8 ppb,Uint8 value) { |
4787
e25ad8d97027
Ported over, to the best of my ability, the code for Win32 shaped windows and patched in the correct C syntax and coding conventions of SDL.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4786
diff
changeset
|
59 int x = 0; |
e25ad8d97027
Ported over, to the best of my ability, the code for Win32 shaped windows and patched in the correct C syntax and coding conventions of SDL.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4786
diff
changeset
|
60 int y = 0; |
4795
6f0bc179771c
Numerous bug fixes that keep testeyes from crashing and dying.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4789
diff
changeset
|
61 Uint8 r = 0,g = 0,b = 0,alpha = 0; |
4802
f14a8c05f5bb
Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4801
diff
changeset
|
62 Uint8* pixel = NULL; |
f14a8c05f5bb
Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4801
diff
changeset
|
63 Uint32 bitmap_pixel,pixel_value = 0; |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
64 if(SDL_MUSTLOCK(shape)) |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
65 SDL_LockSurface(shape); |
4799
a0e096916474
Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4796
diff
changeset
|
66 pixel = (Uint8*)shape->pixels; |
a0e096916474
Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4796
diff
changeset
|
67 for(y = 0;y<shape->h;y++) { |
a0e096916474
Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4796
diff
changeset
|
68 for(x=0;x<shape->w;x++) { |
4787
e25ad8d97027
Ported over, to the best of my ability, the code for Win32 shaped windows and patched in the correct C syntax and coding conventions of SDL.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4786
diff
changeset
|
69 alpha = 0; |
4802
f14a8c05f5bb
Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4801
diff
changeset
|
70 pixel_value = 0; |
4806
007567dbb8c1
Reapplied Win32 make-it-build patch. What's going on? Still get rendering artifacts when testing on x11, have literally no idea why.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4802
diff
changeset
|
71 pixel = (Uint8 *)(shape->pixels) + (y*shape->pitch) + (x*shape->format->BytesPerPixel); |
4802
f14a8c05f5bb
Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4801
diff
changeset
|
72 switch(shape->format->BytesPerPixel) { |
f14a8c05f5bb
Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4801
diff
changeset
|
73 case(1): |
f14a8c05f5bb
Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4801
diff
changeset
|
74 pixel_value = *(Uint8*)pixel; |
f14a8c05f5bb
Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4801
diff
changeset
|
75 break; |
f14a8c05f5bb
Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4801
diff
changeset
|
76 case(2): |
f14a8c05f5bb
Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4801
diff
changeset
|
77 pixel_value = *(Uint16*)pixel; |
f14a8c05f5bb
Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4801
diff
changeset
|
78 break; |
f14a8c05f5bb
Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4801
diff
changeset
|
79 case(4): |
f14a8c05f5bb
Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4801
diff
changeset
|
80 pixel_value = *(Uint32*)pixel; |
f14a8c05f5bb
Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4801
diff
changeset
|
81 break; |
f14a8c05f5bb
Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4801
diff
changeset
|
82 } |
f14a8c05f5bb
Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4801
diff
changeset
|
83 SDL_GetRGBA(pixel_value,shape->format,&r,&g,&b,&alpha); |
4796
e8caf178d082
Added in Visual Studio patch.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4795
diff
changeset
|
84 bitmap_pixel = y*shape->w + x; |
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:
4782
diff
changeset
|
85 bitmap[bitmap_pixel / ppb] |= (alpha >= alphacutoff ? value : 0) << ((ppb - 1) - (bitmap_pixel % ppb)); |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
86 } |
4799
a0e096916474
Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4796
diff
changeset
|
87 } |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
88 if(SDL_MUSTLOCK(shape)) |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
89 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
|
90 } |
7b50faf23907
Moved SDL_shape.h, and building out the API as needed by SDL_Eyes.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4765
diff
changeset
|
91 |
4781
fc4c775b468a
Added Andreas's fixes to the header and stub file for SDL_shape.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4780
diff
changeset
|
92 int SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) { |
4787
e25ad8d97027
Ported over, to the best of my ability, the code for Win32 shaped windows and patched in the correct C syntax and coding conventions of SDL.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4786
diff
changeset
|
93 int result; |
4786
175da36d1342
Fixed up shape files as best I can.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4785
diff
changeset
|
94 if(window == NULL || !SDL_IsShapedWindow(window)) |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
95 //The window given was not a shapeable window. |
4801
506a9165491b
Added #define's for error codes returned from SDL shaped-window API.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4799
diff
changeset
|
96 return SDL_NONSHAPEABLE_WINDOW; |
4780
4f915a47b995
Replaced the model of treating a window's shape as a render target with treating a window's shape as a surface passed into an SDL_SetWindowShape() function. I'll send this off to Andreas and Sam and start coding.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4778
diff
changeset
|
97 if(shape == NULL) |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
98 //Invalid shape argument. |
4801
506a9165491b
Added #define's for error codes returned from SDL shaped-window API.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4799
diff
changeset
|
99 return SDL_INVALID_SHAPE_ARGUMENT; |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
100 |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
101 if(shapeMode != NULL) { |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
102 switch(shapeMode->mode) { |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
103 case ShapeModeDefault: { |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
104 window->shaper->alphacutoff = 1; |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
105 break; |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
106 } |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
107 case ShapeModeBinarizeAlpha: { |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
108 window->shaper->alphacutoff = shapeMode->parameters.binarizationCutoff; |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
109 break; |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
110 } |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
111 } |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
112 } |
4802
f14a8c05f5bb
Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4801
diff
changeset
|
113 //TODO: Platform-specific implementations of SetWindowShape. X11 is finished. Win32 is finished. Debugging is in progress on both. |
4787
e25ad8d97027
Ported over, to the best of my ability, the code for Win32 shaped windows and patched in the correct C syntax and coding conventions of SDL.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4786
diff
changeset
|
114 result = window->display->device->shape_driver.SetWindowShape(window->shaper,shape,shapeMode); |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
115 window->shaper->hasshape = SDL_TRUE; |
4787
e25ad8d97027
Ported over, to the best of my ability, the code for Win32 shaped windows and patched in the correct C syntax and coding conventions of SDL.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4786
diff
changeset
|
116 if((window->shaper->usershownflag & SDL_WINDOW_SHOWN) == SDL_WINDOW_SHOWN) { |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
117 SDL_ShowWindow(window); |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
118 window->shaper->usershownflag &= !SDL_WINDOW_SHOWN; |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
119 } |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
120 return result; |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
121 } |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
122 |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
123 SDL_bool SDL_WindowHasAShape(SDL_Window *window) { |
4787
e25ad8d97027
Ported over, to the best of my ability, the code for Win32 shaped windows and patched in the correct C syntax and coding conventions of SDL.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4786
diff
changeset
|
124 if (window == NULL && !SDL_IsShapedWindow(window)) |
e25ad8d97027
Ported over, to the best of my ability, the code for Win32 shaped windows and patched in the correct C syntax and coding conventions of SDL.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4786
diff
changeset
|
125 return SDL_FALSE; |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
126 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
|
127 } |
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
|
128 |
4781
fc4c775b468a
Added Andreas's fixes to the header and stub file for SDL_shape.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4780
diff
changeset
|
129 int SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shapeMode) { |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
130 if(window != NULL && SDL_IsShapedWindow(window)) { |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
131 if(shapeMode == NULL) { |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
132 if(SDL_WindowHasAShape(window)) |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
133 //The window given has a shape. |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
134 return 0; |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
135 else |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
136 //The window given is shapeable but lacks a shape. |
4801
506a9165491b
Added #define's for error codes returned from SDL shaped-window API.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4799
diff
changeset
|
137 return SDL_WINDOW_LACKS_SHAPE; |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
138 } |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
139 else { |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
140 if(window->shaper->alphacutoff != 1) { |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
141 shapeMode->mode = ShapeModeBinarizeAlpha; |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
142 shapeMode->parameters.binarizationCutoff = window->shaper->alphacutoff; |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
143 } |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
144 else |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
145 shapeMode->mode = ShapeModeDefault; |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
146 return 0; |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
147 } |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
148 } |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
149 else |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4781
diff
changeset
|
150 //The window given is not a valid shapeable window. |
4801
506a9165491b
Added #define's for error codes returned from SDL shaped-window API.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4799
diff
changeset
|
151 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
|
152 } |