21#include "../SDL_internal.h"
47 result->shaper->mode.parameters.binarizationCutoff = 1;
77 Uint32 pixel_value = 0,mask_value = 0;
78 int bytes_per_scanline = (shape->
w + (ppb - 1)) / ppb;
79 Uint8 *bitmap_scanline;
83 for(
y = 0;
y<shape->
h;
y++) {
84 bitmap_scanline =
bitmap +
y * bytes_per_scanline;
85 for(
x=0;
x<shape->
w;
x++) {
91 pixel_value = *(
Uint8*)pixel;
94 pixel_value = *(
Uint16*)pixel;
100 pixel_value = *(
Uint32*)pixel;
106 mask_value = (
alpha >= 1 ? 1 : 0);
109 mask_value = (
alpha >=
mode.parameters.binarizationCutoff ? 1 : 0);
112 mask_value = (
alpha <=
mode.parameters.binarizationCutoff ? 1 : 0);
115 key =
mode.parameters.colorKey;
116 mask_value = ((
key.r !=
r ||
key.g !=
g ||
key.b !=
b) ? 1 : 0);
119 bitmap_scanline[
x / ppb] |= mask_value << (
x % ppb);
133 int last_opaque = -1;
138 for(
y=dimensions.
y;
y<dimensions.
y + dimensions.
h;
y++) {
139 for(
x=dimensions.
x;
x<dimensions.
x + dimensions.
w;
x++) {
142 switch(
mask->format->BytesPerPixel) {
144 pixel_value = *(
Uint8*)pixel;
147 pixel_value = *(
Uint16*)pixel;
150 pixel_value = *(
Uint32*)pixel & (~
mask->format->Amask);
153 pixel_value = *(
Uint32*)pixel;
168 key =
mode.parameters.colorKey;
172 if(last_opaque == -1)
173 last_opaque = pixel_opaque;
174 if(last_opaque != pixel_opaque) {
175 const int halfwidth = dimensions.
w / 2;
176 const int halfheight = dimensions.
h / 2;
180 next.
x = dimensions.
x;
181 next.
y = dimensions.
y;
186 next.
x = dimensions.
x + halfwidth;
187 next.
w = dimensions.
w - halfwidth;
190 next.
x = dimensions.
x;
192 next.
y = dimensions.
y + halfheight;
193 next.
h = dimensions.
h - halfheight;
196 next.
x = dimensions.
x + halfwidth;
197 next.
w = dimensions.
w - halfwidth;
208 result->data.shape = dimensions;
220 dimensions.
w = shape->
w;
221 dimensions.
h = shape->
h;
242 function(tree,closure);
269 if(shape_mode !=
NULL)
270 window->shaper->mode = *shape_mode;
273 if(
window->shaper->userx != 0 &&
window->shaper->usery != 0) {
275 window->shaper->userx = 0;
276 window->shaper->usery = 0;
286 return window->shaper->hasshape;
293 if(shape_mode ==
NULL) {
#define SDL_assert(condition)
#define SDL_DestroyWindow
#define SDL_SetWindowPosition
#define SDL_UnlockSurface
GLint GLint GLint GLint GLint GLint y
GLdouble GLdouble GLdouble r
GLint GLint GLint GLint GLint x
GLboolean GLboolean GLboolean b
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
GLboolean GLboolean GLboolean GLboolean a
GLfloat GLfloat GLfloat alpha
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
static SDL_bool SDL_WindowHasAShape(SDL_Window *window)
int SDL_GetShapedWindowMode(SDL_Window *window, SDL_WindowShapeMode *shape_mode)
Get the shape parameters of a shaped window.
SDL_ShapeTree * SDL_CalculateShapeTree(SDL_WindowShapeMode mode, SDL_Surface *shape)
void SDL_TraverseShapeTree(SDL_ShapeTree *tree, SDL_TraversalFunction function, void *closure)
void SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode, SDL_Surface *shape, Uint8 *bitmap, Uint8 ppb)
void SDL_FreeShapeTree(SDL_ShapeTree **shape_tree)
SDL_Window * SDL_CreateShapedWindow(const char *title, unsigned int x, unsigned int y, unsigned int w, unsigned int h, Uint32 flags)
Create a window that can be shaped with the specified position, dimensions, and flags.
static SDL_ShapeTree * RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode, SDL_Surface *mask, SDL_Rect dimensions)
SDL_bool SDL_IsShapedWindow(const SDL_Window *window)
Return whether the given window is a shaped window.
int SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
Set the shape and parameters of a shaped window.
#define SDL_INVALID_SHAPE_ARGUMENT
#define SDL_NONSHAPEABLE_WINDOW
@ ShapeModeBinarizeAlpha
A binarized alpha cutoff with a given integer value.
@ ShapeModeColorKey
A color key is applied.
@ ShapeModeDefault
The default mode, a binarized alpha cutoff of 1.
@ ShapeModeReverseBinarizeAlpha
A binarized alpha cutoff with a given integer value, but with the opposite comparison.
#define SDL_WINDOW_LACKS_SHAPE
void(* SDL_TraversalFunction)(SDL_ShapeTree *, void *)
SDL_VideoDevice * SDL_GetVideoDevice(void)
EGLSurface EGLNativeWindowType * window
struct SDL_ShapeTree * downright
struct SDL_ShapeTree * upleft
struct SDL_ShapeTree * downleft
struct SDL_ShapeTree * upright
A rectangle, with the origin at the upper left (integer).
SDL_WindowShaper *(* CreateShaper)(SDL_Window *window)
int(* SetWindowShape)(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
A collection of pixels used in software blitting.
SDL_ShapeDriver shape_driver
The type used to identify a window.
A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents.
WindowShapeMode mode
The mode of these window-shape parameters.
SDL_QuadTreeChildren children