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 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.

198 {
199  SDL_Rect clipped;
200 
201  if (!dst) {
202  return SDL_SetError("Passed NULL destination surface");
203  }
204 
205  /* This function doesn't work on surfaces < 8 bpp */
206  if (dst->format->BitsPerPixel < 8) {
207  return SDL_SetError("SDL_BlendFillRect(): Unsupported surface format");
208  }
209 
210  /* If 'rect' == NULL, then fill the whole surface */
211  if (rect) {
212  /* Perform clipping */
213  if (!SDL_IntersectRect(rect, &dst->clip_rect, &clipped)) {
214  return 0;
215  }
216  rect = &clipped;
217  } else {
218  rect = &dst->clip_rect;
219  }
220 
222  r = DRAW_MUL(r, a);
223  g = DRAW_MUL(g, a);
224  b = DRAW_MUL(b, a);
225  }
226 
227  switch (dst->format->BitsPerPixel) {
228  case 15:
229  switch (dst->format->Rmask) {
230  case 0x7C00:
231  return SDL_BlendFillRect_RGB555(dst, rect, blendMode, r, g, b, a);
232  }
233  break;
234  case 16:
235  switch (dst->format->Rmask) {
236  case 0xF800:
237  return SDL_BlendFillRect_RGB565(dst, rect, blendMode, r, g, b, a);
238  }
239  break;
240  case 32:
241  switch (dst->format->Rmask) {
242  case 0x00FF0000:
243  if (!dst->format->Amask) {
244  return SDL_BlendFillRect_RGB888(dst, rect, blendMode, r, g, b, a);
245  } else {
246  return SDL_BlendFillRect_ARGB8888(dst, rect, blendMode, r, g, b, a);
247  }
248  /* break; -Wunreachable-code-break */
249  }
250  break;
251  default:
252  break;
253  }
254 
255  if (!dst->format->Amask) {
256  return SDL_BlendFillRect_RGB(dst, rect, blendMode, r, g, b, a);
257  } else {
258  return SDL_BlendFillRect_RGBA(dst, rect, blendMode, r, g, b, a);
259  }
260 }
static int SDL_BlendFillRect_RGB565(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
static int SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
static int SDL_BlendFillRect_ARGB8888(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
#define SDL_IntersectRect
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
static int SDL_BlendFillRect_RGB888(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Uint8 BitsPerPixel
Definition: SDL_pixels.h:319
SDL_Rect clip_rect
Definition: SDL_surface.h:85
SDL_PixelFormat * format
Definition: SDL_surface.h:72
#define SDL_SetError
static int SDL_BlendFillRect_RGBA(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
static int SDL_BlendFillRect_RGB555(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean g
GLboolean GLboolean GLboolean b
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
#define DRAW_MUL(_a, _b)
Definition: SDL_draw.h:29

◆ 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 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().

265 {
266  SDL_Rect rect;
267  int i;
268  int (*func)(SDL_Surface * dst, const SDL_Rect * rect,
270  int status = 0;
271 
272  if (!dst) {
273  return SDL_SetError("Passed NULL destination surface");
274  }
275 
276  /* This function doesn't work on surfaces < 8 bpp */
277  if (dst->format->BitsPerPixel < 8) {
278  return SDL_SetError("SDL_BlendFillRects(): Unsupported surface format");
279  }
280 
281  if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
282  r = DRAW_MUL(r, a);
283  g = DRAW_MUL(g, a);
284  b = DRAW_MUL(b, a);
285  }
286 
287  /* FIXME: Does this function pointer slow things down significantly? */
288  switch (dst->format->BitsPerPixel) {
289  case 15:
290  switch (dst->format->Rmask) {
291  case 0x7C00:
293  }
294  break;
295  case 16:
296  switch (dst->format->Rmask) {
297  case 0xF800:
299  }
300  break;
301  case 32:
302  switch (dst->format->Rmask) {
303  case 0x00FF0000:
304  if (!dst->format->Amask) {
306  } else {
308  }
309  break;
310  }
311  break;
312  default:
313  break;
314  }
315 
316  if (!func) {
317  if (!dst->format->Amask) {
319  } else {
321  }
322  }
323 
324  for (i = 0; i < count; ++i) {
325  /* Perform clipping */
326  if (!SDL_IntersectRect(&rects[i], &dst->clip_rect, &rect)) {
327  continue;
328  }
329  status = func(dst, &rect, blendMode, r, g, b, a);
330  }
331  return status;
332 }
static int SDL_BlendFillRect_RGB565(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
GLenum GLenum dst
static int SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
Definition: SDL_blendmode.h:40
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
SDL_Rect rect
Definition: testrelative.c:27
static int SDL_BlendFillRect_ARGB8888(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
A collection of pixels used in software blitting.
Definition: SDL_surface.h:69
#define SDL_IntersectRect
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
static int SDL_BlendFillRect_RGB888(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
uint8_t Uint8
Definition: SDL_stdinc.h:157
Uint8 BitsPerPixel
Definition: SDL_pixels.h:319
SDL_Rect clip_rect
Definition: SDL_surface.h:85
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
#define NULL
Definition: begin_code.h:164
SDL_PixelFormat * format
Definition: SDL_surface.h:72
#define SDL_SetError
GLenum func
static int SDL_BlendFillRect_RGBA(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
static int SDL_BlendFillRect_RGB555(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean g
GLboolean GLboolean GLboolean b
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
#define DRAW_MUL(_a, _b)
Definition: SDL_draw.h:29