SDL  2.0
SDL_blendfillrect.h File Reference
+ 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

◆ SDL_BlendFillRect()

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

Definition at line 217 of file SDL_blendfillrect.c.

219 {
220  SDL_Rect clipped;
221 
222  if (!dst) {
223  return SDL_SetError("Passed NULL destination surface");
224  }
225 
226  /* This function doesn't work on surfaces < 8 bpp */
227  if (dst->format->BitsPerPixel < 8) {
228  return SDL_SetError("SDL_BlendFillRect(): Unsupported surface format");
229  }
230 
231  /* If 'rect' == NULL, then fill the whole surface */
232  if (rect) {
233  /* Perform clipping */
234  if (!SDL_IntersectRect(rect, &dst->clip_rect, &clipped)) {
235  return 0;
236  }
237  rect = &clipped;
238  } else {
239  rect = &dst->clip_rect;
240  }
241 
243  r = DRAW_MUL(r, a);
244  g = DRAW_MUL(g, a);
245  b = DRAW_MUL(b, a);
246  }
247 
248  switch (dst->format->BitsPerPixel) {
249  case 15:
250  switch (dst->format->Rmask) {
251  case 0x7C00:
253  }
254  break;
255  case 16:
256  switch (dst->format->Rmask) {
257  case 0xF800:
259  }
260  break;
261  case 32:
262  switch (dst->format->Rmask) {
263  case 0x00FF0000:
264  if (!dst->format->Amask) {
266  } else {
268  }
269  /* break; -Wunreachable-code-break */
270  }
271  break;
272  default:
273  break;
274  }
275 
276  if (!dst->format->Amask) {
277  return SDL_BlendFillRect_RGB(dst, rect, blendMode, r, g, b, a);
278  } else {
279  return SDL_BlendFillRect_RGBA(dst, rect, blendMode, r, g, b, a);
280  }
281 }

References blendMode, DRAW_MUL, rect, 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_BlendFillRects()

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 284 of file SDL_blendfillrect.c.

286 {
287  SDL_Rect rect;
288  int i;
289  int (*func)(SDL_Surface * dst, const SDL_Rect * rect,
291  int status = 0;
292 
293  if (!dst) {
294  return SDL_SetError("Passed NULL destination surface");
295  }
296 
297  /* This function doesn't work on surfaces < 8 bpp */
298  if (dst->format->BitsPerPixel < 8) {
299  return SDL_SetError("SDL_BlendFillRects(): Unsupported surface format");
300  }
301 
303  r = DRAW_MUL(r, a);
304  g = DRAW_MUL(g, a);
305  b = DRAW_MUL(b, a);
306  }
307 
308  /* FIXME: Does this function pointer slow things down significantly? */
309  switch (dst->format->BitsPerPixel) {
310  case 15:
311  switch (dst->format->Rmask) {
312  case 0x7C00:
314  }
315  break;
316  case 16:
317  switch (dst->format->Rmask) {
318  case 0xF800:
320  }
321  break;
322  case 32:
323  switch (dst->format->Rmask) {
324  case 0x00FF0000:
325  if (!dst->format->Amask) {
327  } else {
329  }
330  break;
331  }
332  break;
333  default:
334  break;
335  }
336 
337  if (!func) {
338  if (!dst->format->Amask) {
340  } else {
342  }
343  }
344 
345  for (i = 0; i < count; ++i) {
346  /* Perform clipping */
347  if (!SDL_IntersectRect(&rects[i], &dst->clip_rect, &rect)) {
348  continue;
349  }
350  status = func(dst, &rect, blendMode, r, g, b, a);
351  }
352  return status;
353 }

References blendMode, DRAW_MUL, i, NULL, rect, 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_RunCommandQueue().

blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_Surface
A collection of pixels used in software blitting.
Definition: SDL_surface.h:70
SDL_BLENDMODE_ADD
@ SDL_BLENDMODE_ADD
Definition: SDL_blendmode.h:47
NULL
#define NULL
Definition: begin_code.h:167
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1112
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1112
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
SDL_IntersectRect
#define SDL_IntersectRect
Definition: SDL_dynapi_overrides.h:294
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:108
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1112
func
GLenum func
Definition: SDL_opengl_glext.h:660
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1740
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:82
rect
SDL_Rect rect
Definition: testrelative.c:27
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_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:134
DRAW_MUL
#define DRAW_MUL(_a, _b)
Definition: SDL_draw.h:29
SDL_BLENDMODE_BLEND
@ SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44
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:185
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_Rect
A rectangle, with the origin at the upper left (integer).
Definition: SDL_rect.h:77
rects
EGLSurface EGLint * rects
Definition: eglext.h:282
SDL_BlendMode
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
Definition: SDL_blendmode.h:40
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:50
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:56
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:179