SDL_blendfillrect.h File Reference
`#include "../../SDL_internal.h"`
Include dependency graph for SDL_blendfillrect.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Functions

int | SDL_BlendFillRect (SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
int | SDL_BlendFillRects (SDL_Surface *dst, const SDL_Rect *rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)

## Function Documentation

int SDL_BlendFillRect | ( | SDL_Surface * | dst,
|  | const SDL_Rect * | rect,
|  | SDL_BlendMode | blendMode,
|  | Uint8 | r,
|  | Uint8 | g,
|  | Uint8 | b,
|  | Uint8 | a
| ) |  |

Definition at line 196 of file SDL_blendfillrect.c.

References SDL_PixelFormat::Amask, SDL_PixelFormat::BitsPerPixel, SDL_Surface::clip_rect, DRAW_MUL, SDL_Surface::format, SDL_PixelFormat::Rmask, SDL_BlendFillRect_ARGB8888(), SDL_BlendFillRect_RGB(), SDL_BlendFillRect_RGB555(), SDL_BlendFillRect_RGB565(), SDL_BlendFillRect_RGB888(), SDL_BlendFillRect_RGBA(), SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_IntersectRect, and SDL_SetError.

{
SDL_Rect clipped;
if (!dst) {
return SDL_SetError("Passed NULL destination surface");
}
/* This function doesn't work on surfaces < 8 bpp */
if (dst->format->BitsPerPixel < 8) {
return SDL_SetError("SDL_BlendFillRect(): Unsupported surface format");
}
/* If 'rect' == NULL, then fill the whole surface */
if (rect) {
/* Perform clipping */
if (!SDL_IntersectRect(rect, &dst->clip_rect, &clipped)) {
return 0;
}
rect = &clipped;
} else {
rect = &dst->clip_rect;
}
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
r = DRAW_MUL(r, a);
g = DRAW_MUL(g, a);
b = DRAW_MUL(b, a);
}
switch (dst->format->BitsPerPixel) {
case 15:
switch (dst->format->Rmask) {
case 0x7C00:
return SDL_BlendFillRect_RGB555(dst, rect, blendMode, r, g, b, a);
}
break;
case 16:
switch (dst->format->Rmask) {
case 0xF800:
return SDL_BlendFillRect_RGB565(dst, rect, blendMode, r, g, b, a);
}
break;
case 32:
switch (dst->format->Rmask) {
case 0x00FF0000:
if (!dst->format->Amask) {
return SDL_BlendFillRect_RGB888(dst, rect, blendMode, r, g, b, a);
} else {
return SDL_BlendFillRect_ARGB8888(dst, rect, blendMode, r, g, b, a);
}
break;
}
break;
default:
break;
}
if (!dst->format->Amask) {
return SDL_BlendFillRect_RGB(dst, rect, blendMode, r, g, b, a);
} else {
return SDL_BlendFillRect_RGBA(dst, rect, blendMode, r, g, b, a);
}
}
SDL_BlendFillRect_RGB565
static int SDL_BlendFillRect_RGB565(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendfillrect.c:53
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
SDL_BlendFillRect_RGB
static int SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendfillrect.c:122
SDL_BlendFillRect_ARGB8888
static int SDL_BlendFillRect_ARGB8888(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendfillrect.c:99
SDL_IntersectRect
#define SDL_IntersectRect
Definition: SDL_dynapi_overrides.h:300
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
SDL_BlendFillRect_RGB888
static int SDL_BlendFillRect_RGB888(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendfillrect.c:76
SDL_PixelFormat::BitsPerPixel
Uint8 BitsPerPixel
Definition: SDL_pixels.h:303
SDL_Surface::clip_rect
SDL_Rect clip_rect
Definition: SDL_surface.h:85
SDL_Surface::format
SDL_PixelFormat * format
Definition: SDL_surface.h:72
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
SDL_PixelFormat::Rmask
Uint32 Rmask
Definition: SDL_pixels.h:306
SDL_BlendFillRect_RGBA
static int SDL_BlendFillRect_RGBA(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendfillrect.c:167
SDL_BLENDMODE_ADD
Definition: SDL_blendmode.h:47
SDL_BlendFillRect_RGB555
static int SDL_BlendFillRect_RGB555(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendfillrect.c:30
SDL_PixelFormat::Amask
Uint32 Amask
Definition: SDL_pixels.h:309
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
DRAW_MUL
#define DRAW_MUL(_a, _b)
Definition: SDL_draw.h:29
SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44

int SDL_BlendFillRects | ( | SDL_Surface * | dst,
|  | const SDL_Rect * | rects,
|  | int | count,
|  | SDL_BlendMode | blendMode,
|  | Uint8 | r,
|  | Uint8 | g,
|  | Uint8 | b,
|  | Uint8 | a
| ) |  |

Definition at line 263 of file SDL_blendfillrect.c.

References SDL_PixelFormat::Amask, SDL_PixelFormat::BitsPerPixel, blendMode, SDL_Surface::clip_rect, DRAW_MUL, SDL_Surface::format, i, NULL, rect, SDL_PixelFormat::Rmask, SDL_BlendFillRect_ARGB8888(), SDL_BlendFillRect_RGB(), SDL_BlendFillRect_RGB555(), SDL_BlendFillRect_RGB565(), SDL_BlendFillRect_RGB888(), SDL_BlendFillRect_RGBA(), SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_IntersectRect, and SDL_SetError.

Referenced by SW_RenderFillRects().

{
SDL_Rect rect;
int i;
int (*func)(SDL_Surface * dst, const SDL_Rect * rect,
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
int status = 0;
if (!dst) {
return SDL_SetError("Passed NULL destination surface");
}
/* This function doesn't work on surfaces < 8 bpp */
if (dst->format->BitsPerPixel < 8) {
return SDL_SetError("SDL_BlendFillRects(): Unsupported surface format");
}
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
r = DRAW_MUL(r, a);
g = DRAW_MUL(g, a);
b = DRAW_MUL(b, a);
}
/* FIXME: Does this function pointer slow things down significantly? */
switch (dst->format->BitsPerPixel) {
case 15:
switch (dst->format->Rmask) {
case 0x7C00:
func = SDL_BlendFillRect_RGB555;
}
break;
case 16:
switch (dst->format->Rmask) {
case 0xF800:
func = SDL_BlendFillRect_RGB565;
}
break;
case 32:
switch (dst->format->Rmask) {
case 0x00FF0000:
if (!dst->format->Amask) {
func = SDL_BlendFillRect_RGB888;
} else {
func = SDL_BlendFillRect_ARGB8888;
}
break;
}
break;
default:
break;
}
if (!func) {
if (!dst->format->Amask) {
func = SDL_BlendFillRect_RGB;
} else {
func = SDL_BlendFillRect_RGBA;
}
}
for (i = 0; i < count; ++i) {
/* Perform clipping */
if (!SDL_IntersectRect(&rects[i], &dst->clip_rect, &rect)) {
continue;
}
status = func(dst, &rect, blendMode, r, g, b, a);
}
return status;
}
SDL_BlendFillRect_RGB565
static int SDL_BlendFillRect_RGB565(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendfillrect.c:53
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1737
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
SDL_BlendFillRect_RGB
static int SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendfillrect.c:122
SDL_BlendMode
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
Definition: SDL_blendmode.h:40
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1564
rect
SDL_Rect rect
Definition: testrelative.c:27
SDL_BlendFillRect_ARGB8888
static int SDL_BlendFillRect_ARGB8888(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendfillrect.c:99
SDL_Surface
A collection of pixels used in software blitting.
Definition: SDL_surface.h:69
SDL_IntersectRect
#define SDL_IntersectRect
Definition: SDL_dynapi_overrides.h:300
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
SDL_BlendFillRect_RGB888
static int SDL_BlendFillRect_RGB888(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendfillrect.c:76
Uint8
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
SDL_PixelFormat::BitsPerPixel
Uint8 BitsPerPixel
Definition: SDL_pixels.h:303
SDL_Surface::clip_rect
SDL_Rect clip_rect
Definition: SDL_surface.h:85
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:42
NULL
#define NULL
Definition: begin_code.h:143
SDL_Surface::format
SDL_PixelFormat * format
Definition: SDL_surface.h:72
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
SDL_PixelFormat::Rmask
Uint32 Rmask
Definition: SDL_pixels.h:306
func
GLenum func
Definition: SDL_opengl_glext.h:657
SDL_BlendFillRect_RGBA
static int SDL_BlendFillRect_RGBA(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendfillrect.c:167
SDL_BLENDMODE_ADD
Definition: SDL_blendmode.h:47
SDL_BlendFillRect_RGB555
static int SDL_BlendFillRect_RGB555(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendfillrect.c:30
SDL_PixelFormat::Amask
Uint32 Amask
Definition: SDL_pixels.h:309
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
DRAW_MUL
#define DRAW_MUL(_a, _b)
Definition: SDL_draw.h:29
SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44