21 #include "../SDL_internal.h"
46 result->shaper->mode.parameters.binarizationCutoff = 1;
76 Uint32 pixel_value = 0,mask_value = 0;
77 int bytes_per_scanline = (shape->
w + (ppb - 1)) / ppb;
78 Uint8 *bitmap_scanline;
82 for(
y = 0;
y<shape->
h;
y++) {
83 bitmap_scanline =
bitmap +
y * bytes_per_scanline;
84 for(
x=0;
x<shape->
w;
x++) {
93 pixel_value = *(
Uint16*)pixel;
99 pixel_value = *(
Uint32*)pixel;
105 mask_value = (
alpha >= 1 ? 1 : 0);
108 mask_value = (
alpha >=
mode.parameters.binarizationCutoff ? 1 : 0);
111 mask_value = (
alpha <=
mode.parameters.binarizationCutoff ? 1 : 0);
114 key =
mode.parameters.colorKey;
115 mask_value = ((
key.r !=
r ||
key.g !=
g ||
key.b !=
b) ? 1 : 0);
118 bitmap_scanline[
x / ppb] |= mask_value << (
x % ppb);
132 int last_opaque = -1;
137 for(
y=dimensions.
y;
y<dimensions.
y + dimensions.
h;
y++) {
138 for(
x=dimensions.
x;
x<dimensions.
x + dimensions.
w;
x++) {
141 switch(
mask->format->BytesPerPixel) {
143 pixel_value = *pixel;
146 pixel_value = *(
Uint16*)pixel;
149 pixel_value = *(
Uint32*)pixel & (~
mask->format->Amask);
152 pixel_value = *(
Uint32*)pixel;
167 key =
mode.parameters.colorKey;
171 if(last_opaque == -1)
172 last_opaque = pixel_opaque;
173 if(last_opaque != pixel_opaque) {
174 const int halfwidth = dimensions.
w / 2;
175 const int halfheight = dimensions.
h / 2;
179 next.
x = dimensions.
x;
180 next.
y = dimensions.
y;
185 next.
x = dimensions.
x + halfwidth;
186 next.
w = dimensions.
w - halfwidth;
189 next.
x = dimensions.
x;
191 next.
y = dimensions.
y + halfheight;
192 next.
h = dimensions.
h - halfheight;
195 next.
x = dimensions.
x + halfwidth;
196 next.
w = dimensions.
w - halfwidth;
207 result->data.shape = dimensions;
219 dimensions.
w = shape->
w;
220 dimensions.
h = shape->
h;
241 function(tree,closure);
268 if(shape_mode !=
NULL)
269 window->shaper->mode = *shape_mode;
272 if(
window->shaper->userx != 0 &&
window->shaper->usery != 0) {
274 window->shaper->userx = 0;
275 window->shaper->usery = 0;
285 return window->shaper->hasshape;
292 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)
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.
int SDL_GetShapedWindowMode(SDL_Window *window, SDL_WindowShapeMode *shape_mode)
Get the shape parameters of a shaped window.
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)
static SDL_ShapeTree * RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode, SDL_Surface *mask, SDL_Rect dimensions)
SDL_ShapeTree * SDL_CalculateShapeTree(SDL_WindowShapeMode mode, SDL_Surface *shape)
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).
int(* SetWindowShape)(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
SDL_WindowShaper *(* CreateShaper)(SDL_Window *window)
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