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

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:
232  }
233  break;
234  case 16:
235  switch (dst->format->Rmask) {
236  case 0xF800:
238  }
239  break;
240  case 32:
241  switch (dst->format->Rmask) {
242  case 0x00FF0000:
243  if (!dst->format->Amask) {
245  } else {
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 }

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

101 {
102  unsigned inva = 0xff - a;
103 
104  switch (blendMode) {
105  case SDL_BLENDMODE_BLEND:
107  break;
108  case SDL_BLENDMODE_ADD:
110  break;
111  case SDL_BLENDMODE_MOD:
113  break;
114  default:
116  break;
117  }
118  return 0;
119 }

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

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

124 {
125  SDL_PixelFormat *fmt = dst->format;
126  unsigned inva = 0xff - a;
127 
128  switch (fmt->BytesPerPixel) {
129  case 2:
130  switch (blendMode) {
131  case SDL_BLENDMODE_BLEND:
133  break;
134  case SDL_BLENDMODE_ADD:
136  break;
137  case SDL_BLENDMODE_MOD:
139  break;
140  default:
142  break;
143  }
144  return 0;
145  case 4:
146  switch (blendMode) {
147  case SDL_BLENDMODE_BLEND:
149  break;
150  case SDL_BLENDMODE_ADD:
152  break;
153  case SDL_BLENDMODE_MOD:
155  break;
156  default:
158  break;
159  }
160  return 0;
161  default:
162  return SDL_Unsupported();
163  }
164 }

References blendMode, SDL_PixelFormat::BytesPerPixel, DRAW_SETPIXEL_ADD_RGB, DRAW_SETPIXEL_BLEND_RGB, DRAW_SETPIXEL_MOD_RGB, DRAW_SETPIXEL_RGB, FILLRECT, SDL_PixelFormat::format, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, 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

Definition at line 30 of file SDL_blendfillrect.c.

32 {
33  unsigned inva = 0xff - a;
34 
35  switch (blendMode) {
38  break;
39  case SDL_BLENDMODE_ADD:
41  break;
42  case SDL_BLENDMODE_MOD:
44  break;
45  default:
47  break;
48  }
49  return 0;
50 }

References blendMode, DRAW_SETPIXEL_ADD_RGB555, DRAW_SETPIXEL_BLEND_RGB555, DRAW_SETPIXEL_MOD_RGB555, DRAW_SETPIXEL_RGB555, FILLRECT, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, and SDL_BLENDMODE_MOD.

Referenced by SDL_BlendFillRect(), and SDL_BlendFillRects().

◆ 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

Definition at line 53 of file SDL_blendfillrect.c.

55 {
56  unsigned inva = 0xff - a;
57 
58  switch (blendMode) {
61  break;
62  case SDL_BLENDMODE_ADD:
64  break;
65  case SDL_BLENDMODE_MOD:
67  break;
68  default:
70  break;
71  }
72  return 0;
73 }

References blendMode, DRAW_SETPIXEL_ADD_RGB565, DRAW_SETPIXEL_BLEND_RGB565, DRAW_SETPIXEL_MOD_RGB565, DRAW_SETPIXEL_RGB565, FILLRECT, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, and SDL_BLENDMODE_MOD.

Referenced by SDL_BlendFillRect(), and SDL_BlendFillRects().

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

78 {
79  unsigned inva = 0xff - a;
80 
81  switch (blendMode) {
84  break;
85  case SDL_BLENDMODE_ADD:
87  break;
88  case SDL_BLENDMODE_MOD:
90  break;
91  default:
93  break;
94  }
95  return 0;
96 }

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

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

169 {
170  SDL_PixelFormat *fmt = dst->format;
171  unsigned inva = 0xff - a;
172 
173  switch (fmt->BytesPerPixel) {
174  case 4:
175  switch (blendMode) {
176  case SDL_BLENDMODE_BLEND:
178  break;
179  case SDL_BLENDMODE_ADD:
181  break;
182  case SDL_BLENDMODE_MOD:
184  break;
185  default:
187  break;
188  }
189  return 0;
190  default:
191  return SDL_Unsupported();
192  }
193 }

References blendMode, SDL_PixelFormat::BytesPerPixel, DRAW_SETPIXEL_ADD_RGBA, DRAW_SETPIXEL_BLEND_RGBA, DRAW_SETPIXEL_MOD_RGBA, DRAW_SETPIXEL_RGBA, FILLRECT, SDL_PixelFormat::format, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, 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 263 of file SDL_blendfillrect.c.

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

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:187
SDL_PixelFormat::BytesPerPixel
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
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:218
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:317
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
DRAW_SETPIXEL_BLEND_ARGB8888
#define DRAW_SETPIXEL_BLEND_ARGB8888
Definition: SDL_draw.h:190
DRAW_SETPIXEL_BLEND_RGB888
#define DRAW_SETPIXEL_BLEND_RGB888
Definition: SDL_draw.h:159
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
SDL_IntersectRect
#define SDL_IntersectRect
Definition: SDL_dynapi_overrides.h:294
DRAW_SETPIXEL_BLEND_RGB555
#define DRAW_SETPIXEL_BLEND_RGB555
Definition: SDL_draw.h:97
DRAW_SETPIXEL_BLEND_RGB565
#define DRAW_SETPIXEL_BLEND_RGB565
Definition: SDL_draw.h:128
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
DRAW_SETPIXEL_RGB555
#define DRAW_SETPIXEL_RGB555
Definition: SDL_draw.h:94
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
func
GLenum func
Definition: SDL_opengl_glext.h:657
DRAW_SETPIXEL_BLEND_RGBA
#define DRAW_SETPIXEL_BLEND_RGBA
Definition: SDL_draw.h:265
DRAW_SETPIXEL_ADD_RGB
#define DRAW_SETPIXEL_ADD_RGB
Definition: SDL_draw.h:225
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1737
DRAW_SETPIXEL_MOD_ARGB8888
#define DRAW_SETPIXEL_MOD_ARGB8888
Definition: SDL_draw.h:198
SDL_BLENDMODE_MOD
@ SDL_BLENDMODE_MOD
Definition: SDL_blendmode.h:50
DRAW_SETPIXEL_MOD_RGB888
#define DRAW_SETPIXEL_MOD_RGB888
Definition: SDL_draw.h:167
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
DRAW_SETPIXEL_RGB565
#define DRAW_SETPIXEL_RGB565
Definition: SDL_draw.h:125
DRAW_SETPIXEL_ADD_RGB888
#define DRAW_SETPIXEL_ADD_RGB888
Definition: SDL_draw.h:163
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:132
DRAW_SETPIXEL_MOD_RGB
#define DRAW_SETPIXEL_MOD_RGB
Definition: SDL_draw.h:229
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
DRAW_SETPIXEL_ADD_RGBA
#define DRAW_SETPIXEL_ADD_RGBA
Definition: SDL_draw.h:269
DRAW_SETPIXEL_MOD_RGB565
#define DRAW_SETPIXEL_MOD_RGB565
Definition: SDL_draw.h:136
FILLRECT
#define FILLRECT(type, op)
Definition: SDL_draw.h:545
SDL_PixelFormat
Definition: SDL_pixels.h:315
DRAW_SETPIXEL_BLEND_RGB
#define DRAW_SETPIXEL_BLEND_RGB
Definition: SDL_draw.h:221
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:194
DRAW_SETPIXEL_MOD_RGBA
#define DRAW_SETPIXEL_MOD_RGBA
Definition: SDL_draw.h:273
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_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:262
DRAW_SETPIXEL_RGB888
#define DRAW_SETPIXEL_RGB888
Definition: SDL_draw.h:156
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:53
DRAW_SETPIXEL_MOD_RGB555
#define DRAW_SETPIXEL_MOD_RGB555
Definition: SDL_draw.h:105
DRAW_SETPIXEL_ADD_RGB555
#define DRAW_SETPIXEL_ADD_RGB555
Definition: SDL_draw.h:101
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:179