Commit 30693e91 authored by Eli Gottlieb's avatar Eli Gottlieb

Reformatting code to match the rest of SDL. Variable names seem OK; replaced...

Reformatting code to match the rest of SDL.  Variable names seem OK; replaced tabs with 4 spaces each for indentation.
parent 34bbabf0
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
#include "SDL_shape.h" #include "SDL_shape.h"
#include "../src/video/SDL_shape_internals.h" #include "../src/video/SDL_shape_internals.h"
SDL_Window* SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) { 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,SDL_WINDOW_BORDERLESS | flags & !SDL_WINDOW_FULLSCREEN & !SDL_WINDOW_SHOWN);
if(result != NULL) { if(result != NULL) {
result->shaper = result->display->device->shape_driver.CreateShaper(result); result->shaper = result->display->device->shape_driver.CreateShaper(result);
...@@ -49,7 +50,8 @@ SDL_Window* SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int ...@@ -49,7 +50,8 @@ SDL_Window* SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int
return NULL; return NULL;
} }
SDL_bool SDL_IsShapedWindow(const SDL_Window *window) { SDL_bool
SDL_IsShapedWindow(const SDL_Window *window) {
if(window == NULL) if(window == NULL)
return SDL_FALSE; return SDL_FALSE;
else else
...@@ -57,7 +59,8 @@ SDL_bool SDL_IsShapedWindow(const SDL_Window *window) { ...@@ -57,7 +59,8 @@ SDL_bool SDL_IsShapedWindow(const SDL_Window *window) {
} }
/* REQUIRES that bitmap point to a w-by-h bitmap with ppb pixels-per-byte. */ /* REQUIRES that bitmap point to a w-by-h bitmap with ppb pixels-per-byte. */
void SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* bitmap,Uint8 ppb) { void
SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* bitmap,Uint8 ppb) {
int x = 0; int x = 0;
int y = 0; int y = 0;
Uint8 r = 0,g = 0,b = 0,alpha = 0; Uint8 r = 0,g = 0,b = 0,alpha = 0;
...@@ -110,7 +113,8 @@ void SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* ...@@ -110,7 +113,8 @@ void SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8*
SDL_UnlockSurface(shape); SDL_UnlockSurface(shape);
} }
SDL_ShapeTree* RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* mask,SDL_bool invert,SDL_Rect dimensions) { SDL_ShapeTree*
RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* mask,SDL_bool invert,SDL_Rect dimensions) {
int x = 0,y = 0; int x = 0,y = 0;
Uint8* pixel = NULL; Uint8* pixel = NULL;
Uint32 pixel_value = 0; Uint32 pixel_value = 0;
...@@ -185,7 +189,8 @@ SDL_ShapeTree* RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surfac ...@@ -185,7 +189,8 @@ SDL_ShapeTree* RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surfac
return result; return result;
} }
SDL_ShapeTree* SDL_CalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* shape,SDL_bool invert) { SDL_ShapeTree*
SDL_CalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* shape,SDL_bool invert) {
SDL_Rect dimensions = {0,0,shape->w,shape->h}; SDL_Rect dimensions = {0,0,shape->w,shape->h};
SDL_ShapeTree* result = NULL; SDL_ShapeTree* result = NULL;
if(SDL_MUSTLOCK(shape)) if(SDL_MUSTLOCK(shape))
...@@ -196,7 +201,8 @@ SDL_ShapeTree* SDL_CalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* shap ...@@ -196,7 +201,8 @@ SDL_ShapeTree* SDL_CalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* shap
return result; return result;
} }
void SDL_TraverseShapeTree(SDL_ShapeTree *tree,void(*function)(SDL_ShapeTree*,void*),void* closure) { void
SDL_TraverseShapeTree(SDL_ShapeTree *tree,void(*function)(SDL_ShapeTree*,void*),void* closure) {
if(tree->kind == QuadShape) { if(tree->kind == QuadShape) {
SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upleft,function,closure); SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upleft,function,closure);
SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upright,function,closure); SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upright,function,closure);
...@@ -207,7 +213,8 @@ void SDL_TraverseShapeTree(SDL_ShapeTree *tree,void(*function)(SDL_ShapeTree*,vo ...@@ -207,7 +213,8 @@ void SDL_TraverseShapeTree(SDL_ShapeTree *tree,void(*function)(SDL_ShapeTree*,vo
function(tree,closure); function(tree,closure);
} }
void SDL_FreeShapeTree(SDL_ShapeTree** shapeTree) { void
SDL_FreeShapeTree(SDL_ShapeTree** shapeTree) {
if((*shapeTree)->kind == QuadShape) { if((*shapeTree)->kind == QuadShape) {
SDL_FreeShapeTree((SDL_ShapeTree **)&(*shapeTree)->data.children.upleft); SDL_FreeShapeTree((SDL_ShapeTree **)&(*shapeTree)->data.children.upleft);
SDL_FreeShapeTree((SDL_ShapeTree **)&(*shapeTree)->data.children.upright); SDL_FreeShapeTree((SDL_ShapeTree **)&(*shapeTree)->data.children.upright);
...@@ -218,7 +225,8 @@ void SDL_FreeShapeTree(SDL_ShapeTree** shapeTree) { ...@@ -218,7 +225,8 @@ void SDL_FreeShapeTree(SDL_ShapeTree** shapeTree) {
*shapeTree = NULL; *shapeTree = NULL;
} }
int SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) { int
SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
int result; int result;
if(window == NULL || !SDL_IsShapedWindow(window)) if(window == NULL || !SDL_IsShapedWindow(window))
//The window given was not a shapeable window. //The window given was not a shapeable window.
...@@ -239,13 +247,15 @@ int SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode ...@@ -239,13 +247,15 @@ int SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode
return result; return result;
} }
SDL_bool SDL_WindowHasAShape(SDL_Window *window) { SDL_bool
SDL_WindowHasAShape(SDL_Window *window) {
if (window == NULL && !SDL_IsShapedWindow(window)) if (window == NULL && !SDL_IsShapedWindow(window))
return SDL_FALSE; return SDL_FALSE;
return window->shaper->hasshape; return window->shaper->hasshape;
} }
int SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shapeMode) { int
SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shapeMode) {
if(window != NULL && SDL_IsShapedWindow(window)) { if(window != NULL && SDL_IsShapedWindow(window)) {
if(shapeMode == NULL) { if(shapeMode == NULL) {
if(SDL_WindowHasAShape(window)) if(SDL_WindowHasAShape(window))
......
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
#include "SDL_shape.h" #include "SDL_shape.h"
#include "SDL_cocoashape.h" #include "SDL_cocoashape.h"
SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window) { SDL_WindowShaper*
Cocoa_CreateShaper(SDL_Window* window) {
SDL_WindowData* data = (SDL_WindowData*)window->driverdata; SDL_WindowData* data = (SDL_WindowData*)window->driverdata;
[data->nswindow setAlpha:1.0]; [data->nswindow setAlpha:1.0];
[data->nswindow setOpaque:YES]; [data->nswindow setOpaque:YES];
...@@ -48,7 +49,8 @@ SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window) { ...@@ -48,7 +49,8 @@ SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window) {
return result; return result;
} }
int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) { int
Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
SDL_WindowData* data = (SDL_WindowData*)shaper->window->driverdata; SDL_WindowData* data = (SDL_WindowData*)shaper->window->driverdata;
if(data->saved == SDL_True) { if(data->saved == SDL_True) {
[data->context restoreGraphicsState]; [data->context restoreGraphicsState];
...@@ -64,7 +66,8 @@ int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowS ...@@ -64,7 +66,8 @@ int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowS
Windoze shape-calculation code: a list of rectangles. This will work... I think. */ Windoze shape-calculation code: a list of rectangles. This will work... I think. */
} }
int Cocoa_ResizeWindowShape(SDL_Window *window) { int
Cocoa_ResizeWindowShape(SDL_Window *window) {
SDL_ShapeData* data = window->shaper->driverdata; SDL_ShapeData* data = window->shaper->driverdata;
assert(data != NULL); assert(data != NULL);
return 0; return 0;
......
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
#include "SDL_win32shape.h" #include "SDL_win32shape.h"
#include "SDL_win32video.h" #include "SDL_win32video.h"
SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window) { SDL_WindowShaper*
Win32_CreateShaper(SDL_Window * window) {
int resized_properly; int resized_properly;
SDL_WindowShaper* result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper)); SDL_WindowShaper* result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper));
result->window = window; result->window = window;
...@@ -41,7 +42,8 @@ SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window) { ...@@ -41,7 +42,8 @@ SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window) {
return result; return result;
} }
void CombineRectRegions(SDL_ShapeTree* node, void* closure) { void
CombineRectRegions(SDL_ShapeTree* node, void* closure) {
HRGN* mask_region = (HRGN *)closure; HRGN* mask_region = (HRGN *)closure;
if(node->kind == OpaqueShape) { if(node->kind == OpaqueShape) {
HRGN temp_region = CreateRectRgn(node->data.shape.x,node->data.shape.y,node->data.shape.w,node->data.shape.h); HRGN temp_region = CreateRectRgn(node->data.shape.x,node->data.shape.y,node->data.shape.w,node->data.shape.h);
...@@ -50,7 +52,8 @@ void CombineRectRegions(SDL_ShapeTree* node, void* closure) { ...@@ -50,7 +52,8 @@ void CombineRectRegions(SDL_ShapeTree* node, void* closure) {
} }
} }
int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) { int
Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
SDL_ShapeData *data; SDL_ShapeData *data;
HRGN mask_region; HRGN mask_region;
SDL_WindowData *windowdata; SDL_WindowData *windowdata;
...@@ -83,7 +86,8 @@ int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowS ...@@ -83,7 +86,8 @@ int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowS
return 0; return 0;
} }
int Win32_ResizeWindowShape(SDL_Window *window) { int
Win32_ResizeWindowShape(SDL_Window *window) {
SDL_ShapeData* data; SDL_ShapeData* data;
if (window == NULL) if (window == NULL)
......
...@@ -25,11 +25,13 @@ ...@@ -25,11 +25,13 @@
#include "SDL_x11shape.h" #include "SDL_x11shape.h"
#include "SDL_x11window.h" #include "SDL_x11window.h"
SDL_Window* X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) { SDL_Window*
X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) {
return SDL_CreateWindow(title,x,y,w,h,flags); return SDL_CreateWindow(title,x,y,w,h,flags);
} }
SDL_WindowShaper* X11_CreateShaper(SDL_Window* window) { SDL_WindowShaper*
X11_CreateShaper(SDL_Window* window) {
SDL_WindowShaper* result = NULL; SDL_WindowShaper* result = NULL;
#if SDL_VIDEO_DRIVER_X11_XSHAPE #if SDL_VIDEO_DRIVER_X11_XSHAPE
...@@ -52,7 +54,8 @@ SDL_WindowShaper* X11_CreateShaper(SDL_Window* window) { ...@@ -52,7 +54,8 @@ SDL_WindowShaper* X11_CreateShaper(SDL_Window* window) {
return result; return result;
} }
int X11_ResizeWindowShape(SDL_Window* window) { int
X11_ResizeWindowShape(SDL_Window* window) {
SDL_ShapeData* data = window->shaper->driverdata; SDL_ShapeData* data = window->shaper->driverdata;
assert(data != NULL); assert(data != NULL);
...@@ -77,7 +80,8 @@ int X11_ResizeWindowShape(SDL_Window* window) { ...@@ -77,7 +80,8 @@ int X11_ResizeWindowShape(SDL_Window* window) {
return 0; return 0;
} }
int X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) { int
X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
if(shaper == NULL || shape == NULL || shaper->driverdata == NULL) if(shaper == NULL || shape == NULL || shaper->driverdata == NULL)
return -1; return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment