SDL  2.0
SDL_blendfillrect.c File Reference
#include "../../SDL_internal.h"
#include "SDL_draw.h"
#include "SDL_blendfillrect.h"
+ Include dependency graph for SDL_blendfillrect.c:

Go to the source code of this file.

Functions

static int SDL_BlendFillRect_RGB555 (SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
 
static int SDL_BlendFillRect_RGB565 (SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
 
static int SDL_BlendFillRect_RGB888 (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)
 
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_RGBA (SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
 
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_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 
)
static

Definition at line 108 of file SDL_blendfillrect.c.

110 {
111  unsigned inva = 0xff - a;
112 
113  switch (blendMode) {
114  case SDL_BLENDMODE_BLEND:
116  break;
117  case SDL_BLENDMODE_ADD:
119  break;
120  case SDL_BLENDMODE_MOD:
122  break;
123  case SDL_BLENDMODE_MUL:
125  break;
126  default:
128  break;
129  }
130  return 0;
131 }

References blendMode, DRAW_SETPIXEL_ADD_ARGB8888, DRAW_SETPIXEL_ARGB8888, DRAW_SETPIXEL_BLEND_ARGB8888, DRAW_SETPIXEL_MOD_ARGB8888, DRAW_SETPIXEL_MUL_ARGB8888, FILLRECT, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, and SDL_BLENDMODE_MUL.

Referenced by SDL_BlendFillRect(), and SDL_BlendFillRects().

◆ 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 
)
static

Definition at line 134 of file SDL_blendfillrect.c.

136 {
137  SDL_PixelFormat *fmt = dst->format;
138  unsigned inva = 0xff - a;
139 
140  switch (fmt->BytesPerPixel) {
141  case 2:
142  switch (blendMode) {
143  case SDL_BLENDMODE_BLEND:
145  break;
146  case SDL_BLENDMODE_ADD:
148  break;
149  case SDL_BLENDMODE_MOD:
151  break;
152  case SDL_BLENDMODE_MUL:
154  break;
155  default:
157  break;
158  }
159  return 0;
160  case 4:
161  switch (blendMode) {
162  case SDL_BLENDMODE_BLEND:
164  break;
165  case SDL_BLENDMODE_ADD:
167  break;
168  case SDL_BLENDMODE_MOD:
170  break;
171  case SDL_BLENDMODE_MUL:
173  break;
174  default:
176  break;
177  }
178  return 0;
179  default:
180  return SDL_Unsupported();
181  }
182 }

References blendMode, SDL_PixelFormat::BytesPerPixel, DRAW_SETPIXEL_ADD_RGB, DRAW_SETPIXEL_BLEND_RGB, DRAW_SETPIXEL_MOD_RGB, DRAW_SETPIXEL_MUL_RGB, DRAW_SETPIXEL_RGB, FILLRECT, SDL_PixelFormat::format, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, SDL_BLENDMODE_MUL, and SDL_Unsupported.

Referenced by SDL_BlendFillRect(), and SDL_BlendFillRects().

◆ 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 
)
static

◆ 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 
)
static

◆ 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 
)
static

Definition at line 82 of file SDL_blendfillrect.c.

84 {
85  unsigned inva = 0xff - a;
86 
87  switch (blendMode) {
90  break;
91  case SDL_BLENDMODE_ADD:
93  break;
94  case SDL_BLENDMODE_MOD:
96  break;
97  case SDL_BLENDMODE_MUL:
99  break;
100  default:
102  break;
103  }
104  return 0;
105 }

References blendMode, DRAW_SETPIXEL_ADD_RGB888, DRAW_SETPIXEL_BLEND_RGB888, DRAW_SETPIXEL_MOD_RGB888, DRAW_SETPIXEL_MUL_RGB888, DRAW_SETPIXEL_RGB888, FILLRECT, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, and SDL_BLENDMODE_MUL.

Referenced by SDL_BlendFillRect(), and SDL_BlendFillRects().

◆ 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 
)
static

Definition at line 185 of file SDL_blendfillrect.c.

187 {
188  SDL_PixelFormat *fmt = dst->format;
189  unsigned inva = 0xff - a;
190 
191  switch (fmt->BytesPerPixel) {
192  case 4:
193  switch (blendMode) {
194  case SDL_BLENDMODE_BLEND:
196  break;
197  case SDL_BLENDMODE_ADD:
199  break;
200  case SDL_BLENDMODE_MOD:
202  break;
203  case SDL_BLENDMODE_MUL:
205  break;
206  default:
208  break;
209  }
210  return 0;
211  default:
212  return SDL_Unsupported();
213  }
214 }

References blendMode, SDL_PixelFormat::BytesPerPixel, DRAW_SETPIXEL_ADD_RGBA, DRAW_SETPIXEL_BLEND_RGBA, DRAW_SETPIXEL_MOD_RGBA, DRAW_SETPIXEL_MUL_RGBA, DRAW_SETPIXEL_RGBA, FILLRECT, SDL_PixelFormat::format, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, SDL_BLENDMODE_MUL, and SDL_Unsupported.

Referenced by SDL_BlendFillRect(), and SDL_BlendFillRects().

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

Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:203
DRAW_SETPIXEL_ARGB8888
#define DRAW_SETPIXEL_ARGB8888
Definition: SDL_draw.h:219
SDL_PixelFormat::BytesPerPixel
Uint8 BytesPerPixel
Definition: SDL_pixels.h:323
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_Surface
A collection of pixels used in software blitting.
Definition: SDL_surface.h:70
DRAW_SETPIXEL_RGB
#define DRAW_SETPIXEL_RGB
Definition: SDL_draw.h:257
SDL_BLENDMODE_ADD
@ SDL_BLENDMODE_ADD
Definition: SDL_blendmode.h:47
NULL
#define NULL
Definition: begin_code.h:167
SDL_PixelFormat::format
Uint32 format
Definition: SDL_pixels.h:320
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1112
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1112
DRAW_SETPIXEL_MUL_RGB555
#define DRAW_SETPIXEL_MUL_RGB555
Definition: SDL_draw.h:120
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
DRAW_SETPIXEL_BLEND_ARGB8888
#define DRAW_SETPIXEL_BLEND_ARGB8888
Definition: SDL_draw.h:222
DRAW_SETPIXEL_BLEND_RGB888
#define DRAW_SETPIXEL_BLEND_RGB888
Definition: SDL_draw.h:184
DRAW_SETPIXEL_MUL_RGB565
#define DRAW_SETPIXEL_MUL_RGB565
Definition: SDL_draw.h:158
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
DRAW_SETPIXEL_MUL_RGB888
#define DRAW_SETPIXEL_MUL_RGB888
Definition: SDL_draw.h:196
SDL_IntersectRect
#define SDL_IntersectRect
Definition: SDL_dynapi_overrides.h:294
DRAW_SETPIXEL_BLEND_RGB555
#define DRAW_SETPIXEL_BLEND_RGB555
Definition: SDL_draw.h:108
DRAW_SETPIXEL_BLEND_RGB565
#define DRAW_SETPIXEL_BLEND_RGB565
Definition: SDL_draw.h:146
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
DRAW_SETPIXEL_RGB555
#define DRAW_SETPIXEL_RGB555
Definition: SDL_draw.h:105
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1112
func
GLenum func
Definition: SDL_opengl_glext.h:660
DRAW_SETPIXEL_BLEND_RGBA
#define DRAW_SETPIXEL_BLEND_RGBA
Definition: SDL_draw.h:314
DRAW_SETPIXEL_ADD_RGB
#define DRAW_SETPIXEL_ADD_RGB
Definition: SDL_draw.h:264
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1740
DRAW_SETPIXEL_MOD_ARGB8888
#define DRAW_SETPIXEL_MOD_ARGB8888
Definition: SDL_draw.h:230
DRAW_SETPIXEL_MUL_RGB
#define DRAW_SETPIXEL_MUL_RGB
Definition: SDL_draw.h:272
SDL_BLENDMODE_MOD
@ SDL_BLENDMODE_MOD
Definition: SDL_blendmode.h:50
DRAW_SETPIXEL_MOD_RGB888
#define DRAW_SETPIXEL_MOD_RGB888
Definition: SDL_draw.h:192
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
SDL_BLENDMODE_MUL
@ SDL_BLENDMODE_MUL
Definition: SDL_blendmode.h:53
DRAW_SETPIXEL_RGB565
#define DRAW_SETPIXEL_RGB565
Definition: SDL_draw.h:143
DRAW_SETPIXEL_ADD_RGB888
#define DRAW_SETPIXEL_ADD_RGB888
Definition: SDL_draw.h:188
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
Uint16
uint16_t Uint16
Definition: SDL_stdinc.h:191
DRAW_SETPIXEL_ADD_RGB565
#define DRAW_SETPIXEL_ADD_RGB565
Definition: SDL_draw.h:150
DRAW_SETPIXEL_MOD_RGB
#define DRAW_SETPIXEL_MOD_RGB
Definition: SDL_draw.h:268
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_SETPIXEL_ADD_RGBA
#define DRAW_SETPIXEL_ADD_RGBA
Definition: SDL_draw.h:318
DRAW_SETPIXEL_MOD_RGB565
#define DRAW_SETPIXEL_MOD_RGB565
Definition: SDL_draw.h:154
FILLRECT
#define FILLRECT(type, op)
Definition: SDL_draw.h:601
SDL_PixelFormat
Definition: SDL_pixels.h:318
DRAW_SETPIXEL_BLEND_RGB
#define DRAW_SETPIXEL_BLEND_RGB
Definition: SDL_draw.h:260
DRAW_MUL
#define DRAW_MUL(_a, _b)
Definition: SDL_draw.h:29
SDL_BLENDMODE_BLEND
@ SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44
DRAW_SETPIXEL_ADD_ARGB8888
#define DRAW_SETPIXEL_ADD_ARGB8888
Definition: SDL_draw.h:226
DRAW_SETPIXEL_MUL_RGBA
#define DRAW_SETPIXEL_MUL_RGBA
Definition: SDL_draw.h:326
DRAW_SETPIXEL_MOD_RGBA
#define DRAW_SETPIXEL_MOD_RGBA
Definition: SDL_draw.h:322
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
DRAW_SETPIXEL_RGBA
#define DRAW_SETPIXEL_RGBA
Definition: SDL_draw.h:311
DRAW_SETPIXEL_RGB888
#define DRAW_SETPIXEL_RGB888
Definition: SDL_draw.h:181
SDL_Unsupported
#define SDL_Unsupported()
Definition: SDL_error.h:53
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
DRAW_SETPIXEL_MOD_RGB555
#define DRAW_SETPIXEL_MOD_RGB555
Definition: SDL_draw.h:116
DRAW_SETPIXEL_ADD_RGB555
#define DRAW_SETPIXEL_ADD_RGB555
Definition: SDL_draw.h:112
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:179
DRAW_SETPIXEL_MUL_ARGB8888
#define DRAW_SETPIXEL_MUL_ARGB8888
Definition: SDL_draw.h:234