# HG changeset patch
# User egottlieb
# Date 1281816876 14400
# Node ID 0b918c1869389fbe3d839997f7f1018782caef61
# Parent 40b46225e3cfbe23cc278e9a84a7de2b759b9f1a
Finally got the Win32 API code for shaping to work! Just need to fix SDL_CalculateShapeTree() now!
diff -r 40b46225e3cf -r 0b918c186938 VisualC/SDL/SDL_VS2010.vcxproj
--- a/VisualC/SDL/SDL_VS2010.vcxproj Thu Aug 12 18:17:15 2010 -0400
+++ b/VisualC/SDL/SDL_VS2010.vcxproj Sat Aug 14 16:14:36 2010 -0400
@@ -110,7 +110,7 @@
0x0409
- msimg32.lib;winmm.lib;%(AdditionalDependencies)
+ msvcrt.lib;msimg32.lib;winmm.lib;%(AdditionalDependencies)
$(IntDir)SDL.dll
true
true
diff -r 40b46225e3cf -r 0b918c186938 include/SDL_shape.h
--- a/include/SDL_shape.h Thu Aug 12 18:17:15 2010 -0400
+++ b/include/SDL_shape.h Sat Aug 14 16:14:36 2010 -0400
@@ -112,7 +112,7 @@
*
* \param window The shaped window whose parameters should be set.
* \param shape A surface encoding the desired shape for the window.
- * \param shapeMode The parameters to set for the shaped window.
+ * \param shape_mode The parameters to set for the shaped window.
*
* \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on invalid an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW
* if the SDL_Window* given does not reference a valid shaped window.
@@ -120,22 +120,22 @@
* \sa SDL_WindowShapeMode
* \sa SDL_GetShapedWindowMode.
*/
-extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode);
+extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
/**
* \brief Get the shape parameters of a shaped window.
*
* \param window The shaped window whose parameters should be retrieved.
- * \param shapeMode An empty shape-mode structure to fill, or NULL to check whether the window has a shape.
+ * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape.
*
- * \return 0 if the window has a shape and, provided shapeMode was not NULL, shapeMode has been filled with the mode
+ * \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode
* data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if
* the SDL_Window* given is a shapeable window currently lacking a shape.
*
* \sa SDL_WindowShapeMode
* \sa SDL_SetWindowShape
*/
-extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shapeMode);
+extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
diff -r 40b46225e3cf -r 0b918c186938 src/video/SDL_shape.c
--- a/src/video/SDL_shape.c Thu Aug 12 18:17:15 2010 -0400
+++ b/src/video/SDL_shape.c Sat Aug 14 16:14:36 2010 -0400
@@ -32,7 +32,7 @@
SDL_Window*
SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) {
- SDL_Window *result = SDL_CreateWindow(title,x,y,w,h,SDL_WINDOW_BORDERLESS | flags & !SDL_WINDOW_FULLSCREEN & !SDL_WINDOW_SHOWN);
+ SDL_Window *result = SDL_CreateWindow(title,x,y,w,h,flags | SDL_WINDOW_BORDERLESS & !SDL_WINDOW_FULLSCREEN & !SDL_WINDOW_SHOWN);
if(result != NULL) {
result->shaper = result->display->device->shape_driver.CreateShaper(result);
if(result->shaper != NULL) {
@@ -226,7 +226,7 @@
}
int
-SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
+SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) {
int result;
if(window == NULL || !SDL_IsShapedWindow(window))
//The window given was not a shapeable window.
@@ -235,9 +235,9 @@
//Invalid shape argument.
return SDL_INVALID_SHAPE_ARGUMENT;
- if(shapeMode != NULL)
- window->shaper->mode = *shapeMode;
- result = window->display->device->shape_driver.SetWindowShape(window->shaper,shape,shapeMode);
+ if(shape_mode != NULL)
+ window->shaper->mode = *shape_mode;
+ result = window->display->device->shape_driver.SetWindowShape(window->shaper,shape,shape_mode);
window->shaper->hasshape = SDL_TRUE;
if((window->shaper->usershownflag & SDL_WINDOW_SHOWN) == SDL_WINDOW_SHOWN) {
SDL_SetWindowPosition(window,window->x,window->y);
@@ -255,9 +255,9 @@
}
int
-SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shapeMode) {
+SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode) {
if(window != NULL && SDL_IsShapedWindow(window)) {
- if(shapeMode == NULL) {
+ if(shape_mode == NULL) {
if(SDL_WindowHasAShape(window))
//The window given has a shape.
return 0;
@@ -266,7 +266,7 @@
return SDL_WINDOW_LACKS_SHAPE;
}
else {
- *shapeMode = window->shaper->mode;
+ *shape_mode = window->shaper->mode;
return 0;
}
}
diff -r 40b46225e3cf -r 0b918c186938 src/video/SDL_sysvideo.h
--- a/src/video/SDL_sysvideo.h Thu Aug 12 18:17:15 2010 -0400
+++ b/src/video/SDL_sysvideo.h Sat Aug 14 16:14:36 2010 -0400
@@ -157,7 +157,7 @@
struct SDL_ShapeDriver
{
SDL_WindowShaper *(*CreateShaper)(SDL_Window * window);
- int (*SetWindowShape)(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode);
+ int (*SetWindowShape)(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
int (*ResizeWindowShape)(SDL_Window *window);
};
diff -r 40b46225e3cf -r 0b918c186938 src/video/win32/SDL_win32shape.c
--- a/src/video/win32/SDL_win32shape.c Thu Aug 12 18:17:15 2010 -0400
+++ b/src/video/win32/SDL_win32shape.c Sat Aug 14 16:14:36 2010 -0400
@@ -20,6 +20,7 @@
eligottlieb@gmail.com
*/
+#include
#include "SDL_win32shape.h"
#include "SDL_win32video.h"
@@ -49,9 +50,15 @@
void
CombineRectRegions(SDL_ShapeTree* node,void* closure) {
+ char debug_str[200];
SDL_ShapeRect* rect_list = *((SDL_ShapeRect**)closure);
if(node->kind == OpaqueShape) {
SDL_ShapeRect* rect = SDL_malloc(sizeof(SDL_ShapeRect));
+ sprintf_s(&debug_str[0],200,"x: %u y: %u, x+w: %u, y+h: %u\n",
+ node->data.shape.x,node->data.shape.y,
+ node->data.shape.x + node->data.shape.w,node->data.shape.y + node->data.shape.h);
+ OutputDebugStringA(debug_str);
+ OutputDebugStringA("Converting SDL_ShapeTree opaque node to Windows rectangle.\n");
rect->corners[0].x = node->data.shape.x; rect->corners[0].y = node->data.shape.y;
rect->corners[1].x = node->data.shape.x + node->data.shape.w; rect->corners[1].y = node->data.shape.y;
rect->corners[2].x = node->data.shape.x + node->data.shape.w; rect->corners[2].y = node->data.shape.y + node->data.shape.h;
@@ -69,23 +76,24 @@
}
int
-Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
+Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) {
SDL_ShapeData *data;
HRGN mask_region;
SDL_ShapeRect* rects = NULL,*old = NULL;
Uint16 num_rects = 0,i = 0;
int* polygonVertexNumbers = NULL;
POINT* polygons = NULL;
+ char debug_str[200];
if (shaper == NULL || shape == NULL)
return SDL_INVALID_SHAPE_ARGUMENT;
- if(shape->format->Amask == 0 && shapeMode->mode != ShapeModeColorKey || shape->w != shaper->window->w || shape->h != shaper->window->h)
+ if(shape->format->Amask == 0 && shape_mode->mode != ShapeModeColorKey || shape->w != shaper->window->w || shape->h != shaper->window->h)
return SDL_INVALID_SHAPE_ARGUMENT;
data = (SDL_ShapeData*)shaper->driverdata;
if(data->mask_tree != NULL)
SDL_FreeShapeTree(&data->mask_tree);
- data->mask_tree = SDL_CalculateShapeTree(*shapeMode,shape);
+ data->mask_tree = SDL_CalculateShapeTree(*shape_mode,shape);
SDL_TraverseShapeTree(data->mask_tree,&CombineRectRegions,&rects);
num_rects = num_shape_rects(rects);
@@ -94,8 +102,12 @@
polygonVertexNumbers[i] = 4;
polygons = (POINT*)SDL_malloc(sizeof(POINT)*4*num_rects);
for(i=0;icorners[i % 4];
if(i % 4 == 3) {
+ sprintf_s(&debug_str[0],200,"x: %u y: %u, x+w: %u, y+h: %u\n",
+ rects->corners[0].x,rects->corners[0].y,
+ rects->corners[2].x,rects->corners[2].y);
+ OutputDebugStringA(debug_str);
old = rects;
rects = rects->next;
SDL_free(old);
diff -r 40b46225e3cf -r 0b918c186938 src/video/win32/SDL_win32shape.h
--- a/src/video/win32/SDL_win32shape.h Thu Aug 12 18:17:15 2010 -0400
+++ b/src/video/win32/SDL_win32shape.h Sat Aug 14 16:14:36 2010 -0400
@@ -35,7 +35,7 @@
} SDL_ShapeData;
extern SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window);
-extern int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode);
+extern int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
extern int Win32_ResizeWindowShape(SDL_Window *window);
#endif /* _SDL_win32shape_h */
diff -r 40b46225e3cf -r 0b918c186938 test/testshape.c
--- a/test/testshape.c Thu Aug 12 18:17:15 2010 -0400
+++ b/test/testshape.c Sat Aug 14 16:14:36 2010 -0400
@@ -8,7 +8,7 @@
#define SHAPED_WINDOW_Y 150
#define SHAPED_WINDOW_DIMENSION 640
-#define TICK_INTERVAL 1000/60
+#define TICK_INTERVAL 1000/10
typedef struct LoadedPicture {
SDL_Surface *surface;
@@ -32,11 +32,11 @@
static Uint32 next_time;
Uint32 time_left() {
- Uint32 now = SDL_GetTicks();
- if(next_time <= now)
- return 0;
+ Uint32 now = SDL_GetTicks();
+ if(next_time <= now)
+ return 0;
else
- return next_time - now;
+ return next_time - now;
}
int main(int argc,char** argv) {