SDL  2.0
SDL_blendpoint.h File Reference
+ Include dependency graph for SDL_blendpoint.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int SDL_BlendPoint (SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
 
int SDL_BlendPoints (SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
 

Function Documentation

◆ SDL_BlendPoint()

int SDL_BlendPoint ( SDL_Surface dst,
int  x,
int  y,
SDL_BlendMode  blendMode,
Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a 
)

Definition at line 217 of file SDL_blendpoint.c.

219 {
220  if (!dst) {
221  return SDL_SetError("Passed NULL destination surface");
222  }
223 
224  /* This function doesn't work on surfaces < 8 bpp */
225  if (dst->format->BitsPerPixel < 8) {
226  return SDL_SetError("SDL_BlendPoint(): Unsupported surface format");
227  }
228 
229  /* Perform clipping */
230  if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
231  x >= (dst->clip_rect.x + dst->clip_rect.w) ||
232  y >= (dst->clip_rect.y + dst->clip_rect.h)) {
233  return 0;
234  }
235 
237  r = DRAW_MUL(r, a);
238  g = DRAW_MUL(g, a);
239  b = DRAW_MUL(b, a);
240  }
241 
242  switch (dst->format->BitsPerPixel) {
243  case 15:
244  switch (dst->format->Rmask) {
245  case 0x7C00:
246  return SDL_BlendPoint_RGB555(dst, x, y, blendMode, r, g, b, a);
247  }
248  break;
249  case 16:
250  switch (dst->format->Rmask) {
251  case 0xF800:
252  return SDL_BlendPoint_RGB565(dst, x, y, blendMode, r, g, b, a);
253  }
254  break;
255  case 32:
256  switch (dst->format->Rmask) {
257  case 0x00FF0000:
258  if (!dst->format->Amask) {
259  return SDL_BlendPoint_RGB888(dst, x, y, blendMode, r, g, b, a);
260  } else {
261  return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b, a);
262  }
263  /* break; -Wunreachable-code-break */
264  }
265  break;
266  default:
267  break;
268  }
269 
270  if (!dst->format->Amask) {
271  return SDL_BlendPoint_RGB(dst, x, y, blendMode, r, g, b, a);
272  } else {
273  return SDL_BlendPoint_RGBA(dst, x, y, blendMode, r, g, b, a);
274  }
275 }

References blendMode, DRAW_MUL, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BlendPoint_ARGB8888(), SDL_BlendPoint_RGB(), SDL_BlendPoint_RGB555(), SDL_BlendPoint_RGB565(), SDL_BlendPoint_RGB888(), SDL_BlendPoint_RGBA(), and SDL_SetError.

Referenced by SDL_BlendLines().

◆ SDL_BlendPoints()

int SDL_BlendPoints ( SDL_Surface dst,
const SDL_Point points,
int  count,
SDL_BlendMode  blendMode,
Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a 
)

Definition at line 278 of file SDL_blendpoint.c.

280 {
281  int minx, miny;
282  int maxx, maxy;
283  int i;
284  int x, y;
285  int (*func)(SDL_Surface * dst, int x, int y,
287  int status = 0;
288 
289  if (!dst) {
290  return SDL_SetError("Passed NULL destination surface");
291  }
292 
293  /* This function doesn't work on surfaces < 8 bpp */
294  if (dst->format->BitsPerPixel < 8) {
295  return SDL_SetError("SDL_BlendPoints(): Unsupported surface format");
296  }
297 
299  r = DRAW_MUL(r, a);
300  g = DRAW_MUL(g, a);
301  b = DRAW_MUL(b, a);
302  }
303 
304  /* FIXME: Does this function pointer slow things down significantly? */
305  switch (dst->format->BitsPerPixel) {
306  case 15:
307  switch (dst->format->Rmask) {
308  case 0x7C00:
310  break;
311  }
312  break;
313  case 16:
314  switch (dst->format->Rmask) {
315  case 0xF800:
317  break;
318  }
319  break;
320  case 32:
321  switch (dst->format->Rmask) {
322  case 0x00FF0000:
323  if (!dst->format->Amask) {
325  } else {
327  }
328  break;
329  }
330  break;
331  default:
332  break;
333  }
334 
335  if (!func) {
336  if (!dst->format->Amask) {
338  } else {
340  }
341  }
342 
343  minx = dst->clip_rect.x;
344  maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
345  miny = dst->clip_rect.y;
346  maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
347 
348  for (i = 0; i < count; ++i) {
349  x = points[i].x;
350  y = points[i].y;
351 
352  if (x < minx || x > maxx || y < miny || y > maxy) {
353  continue;
354  }
355  status = func(dst, x, y, blendMode, r, g, b, a);
356  }
357  return status;
358 }

References blendMode, DRAW_MUL, i, NULL, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BlendPoint_ARGB8888(), SDL_BlendPoint_RGB(), SDL_BlendPoint_RGB555(), SDL_BlendPoint_RGB565(), SDL_BlendPoint_RGB888(), SDL_BlendPoint_RGBA(), and SDL_SetError.

Referenced by SW_RunCommandQueue().

points
GLfixed GLfixed GLint GLint GLfixed points
Definition: SDL_opengl_glext.h:4561
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_BlendPoint_RGBA
static int SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendpoint.c:185
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_BlendPoint_RGB565
static int SDL_BlendPoint_RGB565(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendpoint.c:56
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
SDL_BlendPoint_RGB
static int SDL_BlendPoint_RGB(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendpoint.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
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_BlendPoint_RGB555
static int SDL_BlendPoint_RGB555(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendpoint.c:30
SDL_BlendPoint_RGB888
static int SDL_BlendPoint_RGB888(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendpoint.c:82
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_BlendPoint_ARGB8888
static int SDL_BlendPoint_ARGB8888(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendpoint.c:108
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:179