Go to the documentation of this file.
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++) {
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 = *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) {
int SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
Set the shape and parameters of a shaped window.
#define SDL_UnlockSurface
SDL_ShapeTree * SDL_CalculateShapeTree(SDL_WindowShapeMode mode, SDL_Surface *shape)
A collection of pixels used in software blitting.
void SDL_FreeShapeTree(SDL_ShapeTree **shape_tree)
struct SDL_ShapeTree * upright
void(* SDL_TraversalFunction)(SDL_ShapeTree *, void *)
GLboolean GLboolean GLboolean b
SDL_bool SDL_IsShapedWindow(const SDL_Window *window)
Return whether the given window is a shaped window.
int SDL_GetShapedWindowMode(SDL_Window *window, SDL_WindowShapeMode *shape_mode)
Get the shape parameters of a shaped window.
GLdouble GLdouble GLdouble r
static SDL_bool SDL_WindowHasAShape(SDL_Window *window)
GLboolean GLboolean GLboolean GLboolean a
GLfloat GLfloat GLfloat GLfloat h
The type used to identify a window.
#define SDL_INVALID_SHAPE_ARGUMENT
@ ShapeModeBinarizeAlpha
A binarized alpha cutoff with a given integer value.
GLfloat GLfloat GLfloat alpha
A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents.
@ ShapeModeReverseBinarizeAlpha
A binarized alpha cutoff with a given integer value, but with the opposite comparison.
WindowShapeMode mode
The mode of these window-shape parameters.
int(* SetWindowShape)(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
GLint GLint GLint GLint GLint x
EGLSurface EGLNativeWindowType * window
#define SDL_WINDOW_LACKS_SHAPE
#define SDL_NONSHAPEABLE_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.
@ ShapeModeColorKey
A color key is applied.
#define SDL_assert(condition)
SDL_ShapeDriver shape_driver
GLint GLint GLint GLint GLint GLint y
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
A rectangle, with the origin at the upper left (integer).
void SDL_TraverseShapeTree(SDL_ShapeTree *tree, SDL_TraversalFunction function, void *closure)
struct SDL_ShapeTree * downright
SDL_QuadTreeChildren children
SDL_VideoDevice * SDL_GetVideoDevice(void)
static SDL_ShapeTree * RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode, SDL_Surface *mask, SDL_Rect dimensions)
@ ShapeModeDefault
The default mode, a binarized alpha cutoff of 1.
void SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode, SDL_Surface *shape, Uint8 *bitmap, Uint8 ppb)
#define SDL_SetWindowPosition
struct SDL_ShapeTree * upleft
#define SDL_DestroyWindow
SDL_WindowShaper *(* CreateShaper)(SDL_Window *window)
GLubyte GLubyte GLubyte GLubyte w
struct SDL_ShapeTree * downleft