SDL_shape_internals.h File Reference
`#include "../SDL_internal.h"`
`#include "SDL_rect.h"`
`#include "SDL_shape.h"`
`#include "SDL_surface.h"`
`#include "begin_code.h"`
`#include "close_code.h"`
Include dependency graph for SDL_shape_internals.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | SDL_QuadTreeChildren
union | SDL_ShapeUnion
struct | SDL_ShapeTree

## Typedefs

typedef void(* | SDL_TraversalFunction) (SDL_ShapeTree *, void *)

## Enumerations

enum | SDL_ShapeKind { QuadShape, TransparentShape, OpaqueShape }

## Functions

void | SDL_CalculateShapeBitmap (SDL_WindowShapeMode mode, SDL_Surface *shape, Uint8 *bitmap, Uint8 ppb)
SDL_ShapeTree * | SDL_CalculateShapeTree (SDL_WindowShapeMode mode, SDL_Surface *shape)
void | SDL_TraverseShapeTree (SDL_ShapeTree *tree, SDL_TraversalFunction function, void *closure)
void | SDL_FreeShapeTree (SDL_ShapeTree **shape_tree)

## Typedef Documentation

typedef void(* SDL_TraversalFunction) (SDL_ShapeTree *, void *)

Definition at line 54 of file SDL_shape_internals.h.

## Enumeration Type Documentation

enum SDL_ShapeKind

Enumerator
QuadShape |
TransparentShape |
OpaqueShape |

Definition at line 47 of file SDL_shape_internals.h.

{ QuadShape,TransparentShape,OpaqueShape } SDL_ShapeKind;
SDL_ShapeKind
SDL_ShapeKind
Definition: SDL_shape_internals.h:47
OpaqueShape
Definition: SDL_shape_internals.h:47
QuadShape
Definition: SDL_shape_internals.h:47
TransparentShape
Definition: SDL_shape_internals.h:47

## Function Documentation

void SDL_CalculateShapeBitmap | ( | SDL_WindowShapeMode | mode,
|  | SDL_Surface * | shape,
|  | Uint8 * | bitmap,
|  | Uint8 | ppb
| ) |  |

Definition at line 67 of file SDL_shape.c.

References SDL_PixelFormat::Amask, SDL_Color::b, SDL_WindowShapeParams::binarizationCutoff, SDL_PixelFormat::BytesPerPixel, SDL_WindowShapeParams::colorKey, SDL_Surface::format, SDL_Color::g, SDL_Surface::h, SDL_WindowShapeMode::mode, NULL, SDL_WindowShapeMode::parameters, SDL_Surface::pitch, SDL_Surface::pixels, SDL_Color::r, SDL_GetRGBA, SDL_LockSurface, SDL_MUSTLOCK, SDL_UnlockSurface, ShapeModeBinarizeAlpha, ShapeModeColorKey, ShapeModeDefault, ShapeModeReverseBinarizeAlpha, and SDL_Surface::w.

{
int x = 0;
int y = 0;
Uint8 r = 0,g = 0,b = 0,alpha = 0;
Uint8* pixel = NULL;
Uint32 bitmap_pixel,pixel_value = 0,mask_value = 0;
SDL_Color key;
if(SDL_MUSTLOCK(shape))
SDL_LockSurface(shape);
for(y = 0;y<shape->h;y++) {
for(x=0;x<shape->w;x++) {
alpha = 0;
pixel_value = 0;
pixel = (Uint8 *)(shape->pixels) + (y*shape->pitch) + (x*shape->format->BytesPerPixel);
switch(shape->format->BytesPerPixel) {
case(1):
pixel_value = *(Uint8*)pixel;
break;
case(2):
pixel_value = *(Uint16*)pixel;
break;
case(3):
pixel_value = *(Uint32*)pixel & (~shape->format->Amask);
break;
case(4):
pixel_value = *(Uint32*)pixel;
break;
}
SDL_GetRGBA(pixel_value,shape->format,&r,&g,&b,&alpha);
bitmap_pixel = y*shape->w + x;
switch(mode.mode) {
case(ShapeModeDefault):
mask_value = (alpha >= 1 ? 1 : 0);
break;
case(ShapeModeBinarizeAlpha):
mask_value = (alpha >= mode.parameters.binarizationCutoff ? 1 : 0);
break;
case(ShapeModeReverseBinarizeAlpha):
mask_value = (alpha <= mode.parameters.binarizationCutoff ? 1 : 0);
break;
case(ShapeModeColorKey):
key = mode.parameters.colorKey;
mask_value = ((key.r != r || key.g != g || key.b != b) ? 1 : 0);
break;
}
bitmap[bitmap_pixel / ppb] |= mask_value << (7 - ((ppb - 1) - (bitmap_pixel % ppb)));
}
}
if(SDL_MUSTLOCK(shape))
SDL_UnlockSurface(shape);
}
bitmap
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
Definition: SDL_opengl_glext.h:4534
SDL_Color
Definition: SDL_pixels.h:279
SDL_UnlockSurface
#define SDL_UnlockSurface
Definition: SDL_dynapi_overrides.h:453
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
Uint32
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:157
SDL_Color::g
Uint8 g
Definition: SDL_pixels.h:282
SDL_Surface::h
int h
Definition: SDL_surface.h:73
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
SDL_PixelFormat::BytesPerPixel
Uint8 BytesPerPixel
Definition: SDL_pixels.h:304
ShapeModeColorKey
A color key is applied.
Definition: SDL_shape.h:87
SDL_Color::b
Uint8 b
Definition: SDL_pixels.h:283
SDL_Surface::w
int w
Definition: SDL_surface.h:73
alpha
GLfloat GLfloat GLfloat alpha
Definition: SDL_opengl_glext.h:412
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
SDL_Color::r
Uint8 r
Definition: SDL_pixels.h:281
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
SDL_Surface::pixels
void * pixels
Definition: SDL_surface.h:75
Uint8
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
ShapeModeDefault
The default mode, a binarized alpha cutoff of 1.
Definition: SDL_shape.h:81
SDL_WindowShapeMode::parameters
SDL_WindowShapeParams parameters
Window-shape parameters.
Definition: SDL_shape.h:104
SDL_GetRGBA
#define SDL_GetRGBA
Definition: SDL_dynapi_overrides.h:295
NULL
#define NULL
Definition: begin_code.h:143
ShapeModeBinarizeAlpha
A binarized alpha cutoff with a given integer value.
Definition: SDL_shape.h:83
SDL_Surface::format
SDL_PixelFormat * format
Definition: SDL_surface.h:72
SDL_LockSurface
#define SDL_LockSurface
Definition: SDL_dynapi_overrides.h:452
SDL_MUSTLOCK
#define SDL_MUSTLOCK(S)
Definition: SDL_surface.h:61
SDL_WindowShapeParams::colorKey
SDL_Color colorKey
Definition: SDL_shape.h:96
ShapeModeReverseBinarizeAlpha
A binarized alpha cutoff with a given integer value, but with the opposite comparison.
Definition: SDL_shape.h:85
SDL_Surface::pitch
int pitch
Definition: SDL_surface.h:74
Uint16
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:147
SDL_WindowShapeParams::binarizationCutoff
Uint8 binarizationCutoff
a cutoff alpha value for binarization of the window shape&#39;s alpha channel.
Definition: SDL_shape.h:95
SDL_PixelFormat::Amask
Uint32 Amask
Definition: SDL_pixels.h:309
SDL_WindowShapeMode::mode
WindowShapeMode mode
The mode of these window-shape parameters.
Definition: SDL_shape.h:102
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109

SDL_ShapeTree* SDL_CalculateShapeTree | ( | SDL_WindowShapeMode | mode,
|  | SDL_Surface * | shape
| ) |  |

Definition at line 207 of file SDL_shape.c.

References SDL_Surface::h, NULL, RecursivelyCalculateShapeTree(), SDL_LockSurface, SDL_MUSTLOCK, SDL_UnlockSurface, and SDL_Surface::w.

{
SDL_Rect dimensions = {0,0,shape->w,shape->h};
SDL_ShapeTree* result = NULL;
if(SDL_MUSTLOCK(shape))
SDL_LockSurface(shape);
result = RecursivelyCalculateShapeTree(mode,shape,dimensions);
if(SDL_MUSTLOCK(shape))
SDL_UnlockSurface(shape);
return result;
}
SDL_UnlockSurface
#define SDL_UnlockSurface
Definition: SDL_dynapi_overrides.h:453
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9432
SDL_Surface::h
int h
Definition: SDL_surface.h:73
SDL_Surface::w
int w
Definition: SDL_surface.h:73
NULL
#define NULL
Definition: begin_code.h:143
SDL_LockSurface
#define SDL_LockSurface
Definition: SDL_dynapi_overrides.h:452
SDL_MUSTLOCK
#define SDL_MUSTLOCK(S)
Definition: SDL_surface.h:61
SDL_ShapeTree
Definition: SDL_shape_internals.h:49
RecursivelyCalculateShapeTree
static SDL_ShapeTree * RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode, SDL_Surface *mask, SDL_Rect dimensions)
Definition: SDL_shape.c:121
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64

void SDL_FreeShapeTree | ( | SDL_ShapeTree ** | shape_tree | ) |

Definition at line 234 of file SDL_shape.c.

References NULL, QuadShape, SDL_free(), and SDL_FreeShapeTree().

Referenced by SDL_FreeShapeTree().

{
if((*shape_tree)->kind == QuadShape) {
SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.upleft);
SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.upright);
SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.downleft);
SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.downright);
}
SDL_free(*shape_tree);
*shape_tree = NULL;
}
SDL_FreeShapeTree
void SDL_FreeShapeTree(SDL_ShapeTree **shape_tree)
Definition: SDL_shape.c:234
SDL_free
void SDL_free(void *mem)
QuadShape
Definition: SDL_shape_internals.h:47
NULL
#define NULL
Definition: begin_code.h:143
SDL_ShapeTree
Definition: SDL_shape_internals.h:49

void SDL_TraverseShapeTree | ( | SDL_ShapeTree * | tree,
|  | SDL_TraversalFunction | function,
|  | void * | closure
| ) |  |

Definition at line 220 of file SDL_shape.c.

References SDL_ShapeUnion::children, SDL_ShapeTree::data, SDL_QuadTreeChildren::downleft, SDL_QuadTreeChildren::downright, SDL_ShapeTree::kind, NULL, QuadShape, SDL_assert, SDL_TraverseShapeTree(), SDL_QuadTreeChildren::upleft, and SDL_QuadTreeChildren::upright.

Referenced by SDL_TraverseShapeTree().

{
SDL_assert(tree != NULL);
if(tree->kind == QuadShape) {
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.downleft,function,closure);
SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.downright,function,closure);
}
else
function(tree,closure);
}
SDL_QuadTreeChildren::upright
struct SDL_ShapeTree * upright
Definition: SDL_shape_internals.h:39
SDL_ShapeTree::data
SDL_ShapeUnion data
Definition: SDL_shape_internals.h:51
QuadShape
Definition: SDL_shape_internals.h:47
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:167
NULL
#define NULL
Definition: begin_code.h:143
SDL_TraverseShapeTree
void SDL_TraverseShapeTree(SDL_ShapeTree *tree, SDL_TraversalFunction function, void *closure)
Definition: SDL_shape.c:220
SDL_ShapeTree
Definition: SDL_shape_internals.h:49
SDL_QuadTreeChildren::upleft
struct SDL_ShapeTree * upleft
Definition: SDL_shape_internals.h:39
SDL_ShapeTree::kind
SDL_ShapeKind kind
Definition: SDL_shape_internals.h:50
SDL_QuadTreeChildren::downright
struct SDL_ShapeTree * downright
Definition: SDL_shape_internals.h:39
SDL_ShapeUnion::children
SDL_QuadTreeChildren children
Definition: SDL_shape_internals.h:43
SDL_QuadTreeChildren::downleft
struct SDL_ShapeTree * downleft
Definition: SDL_shape_internals.h:39