Commit 56ab3ca5 authored by egottlieb's avatar egottlieb

Worked on Windows implementation and the quad-trees.

parent c33852e9
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ShowAllFiles>true</ShowAllFiles>
<LocalDebuggerCommandArguments Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"C:\Users\Eli\My Programs\test\shapes\p16_shape24.bmp"</LocalDebuggerCommandArguments>
<DebuggerFlavor Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project> </Project>
\ No newline at end of file
...@@ -131,6 +131,9 @@ SDL_ShapeTree* RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surfac ...@@ -131,6 +131,9 @@ SDL_ShapeTree* RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surfac
case(2): case(2):
pixel_value = *(Uint16*)pixel; pixel_value = *(Uint16*)pixel;
break; break;
case(3):
pixel_value = *(Uint32*)pixel & (~mask->format->Amask);
break;
case(4): case(4):
pixel_value = *(Uint32*)pixel; pixel_value = *(Uint32*)pixel;
break; break;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
eligottlieb@gmail.com eligottlieb@gmail.com
*/ */
#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) {
...@@ -30,6 +30,8 @@ SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window) { ...@@ -30,6 +30,8 @@ SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window) {
result->mode.mode = ShapeModeDefault; result->mode.mode = ShapeModeDefault;
result->mode.parameters.binarizationCutoff = 1; result->mode.parameters.binarizationCutoff = 1;
result->usershownflag = 0; result->usershownflag = 0;
result->driverdata = (SDL_ShapeData*)SDL_malloc(sizeof(SDL_ShapeData));
((SDL_ShapeData*)result->driverdata)->mask_tree = NULL;
//Put some driver-data here. //Put some driver-data here.
window->shaper = result; window->shaper = result;
resized_properly = Win32_ResizeWindowShape(window); resized_properly = Win32_ResizeWindowShape(window);
...@@ -51,15 +53,17 @@ void CombineRectRegions(SDL_ShapeTree* node, void* closure) { ...@@ -51,15 +53,17 @@ 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;
HWND hwnd; HWND hwnd;
if (shaper == NULL || shape == NULL) if (shaper == NULL || shape == NULL)
return SDL_INVALID_SHAPE_ARGUMENT; return SDL_INVALID_SHAPE_ARGUMENT;
if(!SDL_ISPIXELFORMAT_ALPHA(SDL_MasksToPixelFormatEnum(shape->format->BitsPerPixel,shape->format->Rmask,shape->format->Gmask,shape->format->Bmask,shape->format->Amask)) && shapeMode->mode != ShapeModeColorKey || shape->w != shaper->window->w || shape->h != shaper->window->h) if(shape->format->Amask == 0 && shapeMode->mode != ShapeModeColorKey || shape->w != shaper->window->w || shape->h != shaper->window->h)
return SDL_INVALID_SHAPE_ARGUMENT; return SDL_INVALID_SHAPE_ARGUMENT;
data = (SDL_ShapeData*)shaper->driverdata; data = (SDL_ShapeData*)shaper->driverdata;
if(data->mask_tree != NULL)
SDL_FreeShapeTree(&data->mask_tree);
data->mask_tree = SDL_CalculateShapeTree(*shapeMode,shape,SDL_FALSE); data->mask_tree = SDL_CalculateShapeTree(*shapeMode,shape,SDL_FALSE);
/* /*
...@@ -72,7 +76,7 @@ int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowS ...@@ -72,7 +76,7 @@ int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowS
/* /*
* Set the new region mask for the window * Set the new region mask for the window
*/ */
windowdata=(SDL_WindowData *)(shaper->window->driverdata); windowdata=(SDL_WindowData *)(shaper->window->driverdata);
hwnd = windowdata->hwnd; hwnd = windowdata->hwnd;
SetWindowRgn(hwnd, mask_region, TRUE); SetWindowRgn(hwnd, mask_region, TRUE);
......
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