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

References SDL_PixelFormat::Amask, SDL_PixelFormat::BitsPerPixel, SDL_Surface::clip_rect, DRAW_MUL, SDL_Surface::format, SDL_Rect::h, SDL_PixelFormat::Rmask, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BlendPoint_ARGB8888(), SDL_BlendPoint_RGB(), SDL_BlendPoint_RGB555(), SDL_BlendPoint_RGB565(), SDL_BlendPoint_RGB888(), SDL_BlendPoint_RGBA(), SDL_SetError, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_BlendLines().

198 {
199  if (!dst) {
200  return SDL_SetError("Passed NULL destination surface");
201  }
202 
203  /* This function doesn't work on surfaces < 8 bpp */
204  if (dst->format->BitsPerPixel < 8) {
205  return SDL_SetError("SDL_BlendPoint(): Unsupported surface format");
206  }
207 
208  /* Perform clipping */
209  if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
210  x >= (dst->clip_rect.x + dst->clip_rect.w) ||
211  y >= (dst->clip_rect.y + dst->clip_rect.h)) {
212  return 0;
213  }
214 
216  r = DRAW_MUL(r, a);
217  g = DRAW_MUL(g, a);
218  b = DRAW_MUL(b, a);
219  }
220 
221  switch (dst->format->BitsPerPixel) {
222  case 15:
223  switch (dst->format->Rmask) {
224  case 0x7C00:
225  return SDL_BlendPoint_RGB555(dst, x, y, blendMode, r, g, b, a);
226  }
227  break;
228  case 16:
229  switch (dst->format->Rmask) {
230  case 0xF800:
231  return SDL_BlendPoint_RGB565(dst, x, y, blendMode, r, g, b, a);
232  }
233  break;
234  case 32:
235  switch (dst->format->Rmask) {
236  case 0x00FF0000:
237  if (!dst->format->Amask) {
238  return SDL_BlendPoint_RGB888(dst, x, y, blendMode, r, g, b,
239  a);
240  } else {
241  return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b,
242  a);
243  }
244  break;
245  }
246  break;
247  default:
248  break;
249  }
250 
251  if (!dst->format->Amask) {
252  return SDL_BlendPoint_RGB(dst, x, y, blendMode, r, g, b, a);
253  } else {
254  return SDL_BlendPoint_RGBA(dst, x, y, blendMode, r, g, b, a);
255  }
256 }
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
static int SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
static int SDL_BlendPoint_ARGB8888(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
static int SDL_BlendPoint_RGB888(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
static int SDL_BlendPoint_RGB565(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
GLboolean GLboolean g
static int SDL_BlendPoint_RGB555(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
Uint8 BitsPerPixel
Definition: SDL_pixels.h:317
int x
Definition: SDL_rect.h:66
int w
Definition: SDL_rect.h:67
SDL_Rect clip_rect
Definition: SDL_surface.h:85
static int SDL_BlendPoint_RGB(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_PixelFormat * format
Definition: SDL_surface.h:72
#define SDL_SetError
int h
Definition: SDL_rect.h:67
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean GLboolean b
int y
Definition: SDL_rect.h:66
#define DRAW_MUL(_a, _b)
Definition: SDL_draw.h:29

§ 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 259 of file SDL_blendpoint.c.

References SDL_PixelFormat::Amask, SDL_PixelFormat::BitsPerPixel, blendMode, SDL_Surface::clip_rect, DRAW_MUL, SDL_Surface::format, SDL_Rect::h, i, NULL, SDL_PixelFormat::Rmask, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BlendPoint_ARGB8888(), SDL_BlendPoint_RGB(), SDL_BlendPoint_RGB555(), SDL_BlendPoint_RGB565(), SDL_BlendPoint_RGB888(), SDL_BlendPoint_RGBA(), SDL_SetError, SDL_Rect::w, SDL_Point::x, SDL_Rect::x, SDL_Point::y, and SDL_Rect::y.

Referenced by SW_RenderDrawPoints().

261 {
262  int minx, miny;
263  int maxx, maxy;
264  int i;
265  int x, y;
266  int (*func)(SDL_Surface * dst, int x, int y,
268  int status = 0;
269 
270  if (!dst) {
271  return SDL_SetError("Passed NULL destination surface");
272  }
273 
274  /* This function doesn't work on surfaces < 8 bpp */
275  if (dst->format->BitsPerPixel < 8) {
276  return SDL_SetError("SDL_BlendPoints(): Unsupported surface format");
277  }
278 
279  if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
280  r = DRAW_MUL(r, a);
281  g = DRAW_MUL(g, a);
282  b = DRAW_MUL(b, a);
283  }
284 
285  /* FIXME: Does this function pointer slow things down significantly? */
286  switch (dst->format->BitsPerPixel) {
287  case 15:
288  switch (dst->format->Rmask) {
289  case 0x7C00:
291  break;
292  }
293  break;
294  case 16:
295  switch (dst->format->Rmask) {
296  case 0xF800:
298  break;
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  minx = dst->clip_rect.x;
325  maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
326  miny = dst->clip_rect.y;
327  maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
328 
329  for (i = 0; i < count; ++i) {
330  x = points[i].x;
331  y = points[i].y;
332 
333  if (x < minx || x > maxx || y < miny || y > maxy) {
334  continue;
335  }
336  status = func(dst, x, y, blendMode, r, g, b, a);
337  }
338  return status;
339 }
GLenum GLenum dst
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
static int SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
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:1564
A collection of pixels used in software blitting.
Definition: SDL_surface.h:69
static int SDL_BlendPoint_ARGB8888(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
static int SDL_BlendPoint_RGB888(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
static int SDL_BlendPoint_RGB565(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
GLboolean GLboolean g
int x
Definition: SDL_rect.h:50
static int SDL_BlendPoint_RGB555(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
int y
Definition: SDL_rect.h:51
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
Uint8 BitsPerPixel
Definition: SDL_pixels.h:317
int x
Definition: SDL_rect.h:66
int w
Definition: SDL_rect.h:67
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
static int SDL_BlendPoint_RGB(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
#define NULL
Definition: begin_code.h:143
SDL_PixelFormat * format
Definition: SDL_surface.h:72
#define SDL_SetError
GLenum func
int h
Definition: SDL_rect.h:67
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean GLboolean b
int y
Definition: SDL_rect.h:66
#define DRAW_MUL(_a, _b)
Definition: SDL_draw.h:29