SDL_blendline.c File Reference
`#include "../../SDL_internal.h"`
`#include "SDL_draw.h"`
`#include "SDL_blendline.h"`
`#include "SDL_blendpoint.h"`
Include dependency graph for SDL_blendline.c:

Go to the source code of this file.

## Typedefs

typedef void(* | BlendLineFunc) (SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_bool draw_end)

## Functions

static void | SDL_BlendLine_RGB2 (SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end)
static void | SDL_BlendLine_RGB555 (SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end)
static void | SDL_BlendLine_RGB565 (SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end)
static void | SDL_BlendLine_RGB4 (SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end)
static void | SDL_BlendLine_RGBA4 (SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end)
static void | SDL_BlendLine_RGB888 (SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end)
static void | SDL_BlendLine_ARGB8888 (SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end)
static BlendLineFunc | SDL_CalculateBlendLineFunc (const SDL_PixelFormat *fmt)
int | SDL_BlendLine (SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
int | SDL_BlendLines (SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)

## Typedef Documentation

typedef void(* BlendLineFunc) (SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_bool draw_end)

Definition at line 670 of file SDL_blendline.c.

## Function Documentation

int SDL_BlendLine | ( | SDL_Surface * | dst,
|  | int | x1,
|  | int | y1,
|  | int | x2,
|  | int | y2,
|  | SDL_BlendMode | blendMode,
|  | Uint8 | r,
|  | Uint8 | g,
|  | Uint8 | b,
|  | Uint8 | a
| ) |  |

Definition at line 708 of file SDL_blendline.c.

References SDL_Surface::clip_rect, SDL_Surface::format, SDL_CalculateBlendLineFunc(), SDL_IntersectRectAndLine, SDL_SetError, and SDL_TRUE.

{
BlendLineFunc func;
if (!dst) {
return SDL_SetError("SDL_BlendLine(): Passed NULL destination surface");
}
func = SDL_CalculateBlendLineFunc(dst->format);
if (!func) {
return SDL_SetError("SDL_BlendLine(): Unsupported surface format");
}
/* Perform clipping */
/* FIXME: We don't actually want to clip, as it may change line slope */
if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
return 0;
}
func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, SDL_TRUE);
return 0;
}
BlendLineFunc
void(* BlendLineFunc)(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_bool draw_end)
Definition: SDL_blendline.c:670
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8583
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
SDL_CalculateBlendLineFunc
static BlendLineFunc SDL_CalculateBlendLineFunc(const SDL_PixelFormat *fmt)
Definition: SDL_blendline.c:677
y2
GLfixed GLfixed GLfixed y2
Definition: SDL_opengl_glext.h:4583
x2
GLfixed GLfixed x2
Definition: SDL_opengl_glext.h:4583
y1
GLfixed y1
Definition: SDL_opengl_glext.h:4583
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
SDL_TRUE
Definition: SDL_stdinc.h:129
SDL_Surface::clip_rect
SDL_Rect clip_rect
Definition: SDL_surface.h:85
SDL_Surface::format
SDL_PixelFormat * format
Definition: SDL_surface.h:72
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
func
GLenum func
Definition: SDL_opengl_glext.h:657
SDL_IntersectRectAndLine
#define SDL_IntersectRectAndLine
Definition: SDL_dynapi_overrides.h:303
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109

static void SDL_BlendLine_ARGB8888 | ( | SDL_Surface * | dst,
|  | int | x1,
|  | int | y1,
|  | int | x2,
|  | int | y2,
|  | SDL_BlendMode | blendMode,
|  | Uint8 | _r,
|  | Uint8 | _g,
|  | Uint8 | _b,
|  | Uint8 | _a,
|  | SDL_bool | draw_end
| ) |  |

static

Definition at line 580 of file SDL_blendline.c.

References AALINE, ABS, DLINE, DRAW_MUL, DRAW_SETPIXEL_ADD_ARGB8888, DRAW_SETPIXEL_ARGB8888, DRAW_SETPIXEL_BLEND_ARGB8888, DRAW_SETPIXEL_MOD_ARGB8888, DRAW_SETPIXELXY_ADD_ARGB8888, DRAW_SETPIXELXY_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888, DRAW_SETPIXELXY_MOD_ARGB8888, HLINE, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, and VLINE.

Referenced by SDL_CalculateBlendLineFunc().

{
unsigned r, g, b, a, inva;
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
r = DRAW_MUL(_r, _a);
g = DRAW_MUL(_g, _a);
b = DRAW_MUL(_b, _a);
a = _a;
} else {
r = _r;
g = _g;
b = _b;
a = _a;
}
inva = (a ^ 0xff);
if (y1 == y2) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
HLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
break;
case SDL_BLENDMODE_ADD:
HLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
break;
case SDL_BLENDMODE_MOD:
HLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
break;
default:
HLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
break;
}
} else if (x1 == x2) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
VLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
break;
case SDL_BLENDMODE_ADD:
VLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
break;
case SDL_BLENDMODE_MOD:
VLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
break;
default:
VLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
break;
}
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
DLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
break;
case SDL_BLENDMODE_ADD:
DLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
break;
case SDL_BLENDMODE_MOD:
DLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
break;
default:
DLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
break;
}
} else {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY_BLEND_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888,
draw_end);
break;
case SDL_BLENDMODE_ADD:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY_ADD_ARGB8888, DRAW_SETPIXELXY_ADD_ARGB8888,
draw_end);
break;
case SDL_BLENDMODE_MOD:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY_MOD_ARGB8888, DRAW_SETPIXELXY_MOD_ARGB8888,
draw_end);
break;
default:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888,
draw_end);
break;
}
}
}
DRAW_SETPIXEL_BLEND_ARGB8888
#define DRAW_SETPIXEL_BLEND_ARGB8888
Definition: SDL_draw.h:190
DRAW_SETPIXEL_MOD_ARGB8888
#define DRAW_SETPIXEL_MOD_ARGB8888
Definition: SDL_draw.h:198
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8583
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
Uint32
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:157
y2
GLfixed GLfixed GLfixed y2
Definition: SDL_opengl_glext.h:4583
VLINE
#define VLINE(type, op, draw_end)
Definition: SDL_draw.h:318
DRAW_SETPIXELXY_MOD_ARGB8888
#define DRAW_SETPIXELXY_MOD_ARGB8888(x, y)
Definition: SDL_draw.h:211
ABS
#define ABS(_x)
Definition: SDL_gamecontroller.c:34
DLINE
#define DLINE(type, op, draw_end)
Definition: SDL_draw.h:340
HLINE
#define HLINE(type, op, draw_end)
Definition: SDL_draw.h:296
x2
GLfixed GLfixed x2
Definition: SDL_opengl_glext.h:4583
SDL_BLENDMODE_MOD
Definition: SDL_blendmode.h:50
y1
GLfixed y1
Definition: SDL_opengl_glext.h:4583
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
DRAW_SETPIXELXY_ARGB8888
#define DRAW_SETPIXELXY_ARGB8888(x, y)
Definition: SDL_draw.h:202
DRAW_SETPIXEL_ARGB8888
#define DRAW_SETPIXEL_ARGB8888
Definition: SDL_draw.h:187
AALINE
#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end)
Definition: SDL_draw.h:547
SDL_BLENDMODE_ADD
Definition: SDL_blendmode.h:47
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
DRAW_SETPIXELXY_BLEND_ARGB8888
#define DRAW_SETPIXELXY_BLEND_ARGB8888(x, y)
Definition: SDL_draw.h:205
DRAW_SETPIXELXY_ADD_ARGB8888
#define DRAW_SETPIXELXY_ADD_ARGB8888(x, y)
Definition: SDL_draw.h:208
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
DRAW_SETPIXEL_ADD_ARGB8888
#define DRAW_SETPIXEL_ADD_ARGB8888
Definition: SDL_draw.h:194
DRAW_MUL
#define DRAW_MUL(_a, _b)
Definition: SDL_draw.h:29
SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44

static void SDL_BlendLine_RGB2 | ( | SDL_Surface * | dst,
|  | int | x1,
|  | int | y1,
|  | int | x2,
|  | int | y2,
|  | SDL_BlendMode | blendMode,
|  | Uint8 | _r,
|  | Uint8 | _g,
|  | Uint8 | _b,
|  | Uint8 | _a,
|  | SDL_bool | draw_end
| ) |  |

static

Definition at line 31 of file SDL_blendline.c.

References AALINE, ABS, DLINE, DRAW_MUL, DRAW_SETPIXEL_ADD_RGB, DRAW_SETPIXEL_BLEND_RGB, DRAW_SETPIXEL_MOD_RGB, DRAW_SETPIXEL_RGB, DRAW_SETPIXELXY2_ADD_RGB, DRAW_SETPIXELXY2_BLEND_RGB, DRAW_SETPIXELXY2_MOD_RGB, DRAW_SETPIXELXY2_RGB, SDL_Surface::format, HLINE, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, and VLINE.

Referenced by SDL_CalculateBlendLineFunc().

{
const SDL_PixelFormat *fmt = dst->format;
unsigned r, g, b, a, inva;
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
r = DRAW_MUL(_r, _a);
g = DRAW_MUL(_g, _a);
b = DRAW_MUL(_b, _a);
a = _a;
} else {
r = _r;
g = _g;
b = _b;
a = _a;
}
inva = (a ^ 0xff);
if (y1 == y2) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
break;
case SDL_BLENDMODE_ADD:
HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
break;
case SDL_BLENDMODE_MOD:
HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
break;
default:
HLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
break;
}
} else if (x1 == x2) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
break;
case SDL_BLENDMODE_ADD:
VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
break;
case SDL_BLENDMODE_MOD:
VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
break;
default:
VLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
break;
}
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
break;
case SDL_BLENDMODE_ADD:
DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
break;
case SDL_BLENDMODE_MOD:
DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
break;
default:
DLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
break;
}
} else {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY2_BLEND_RGB, DRAW_SETPIXELXY2_BLEND_RGB,
draw_end);
break;
case SDL_BLENDMODE_ADD:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY2_ADD_RGB, DRAW_SETPIXELXY2_ADD_RGB,
draw_end);
break;
case SDL_BLENDMODE_MOD:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY2_MOD_RGB, DRAW_SETPIXELXY2_MOD_RGB,
draw_end);
break;
default:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY2_RGB, DRAW_SETPIXELXY2_BLEND_RGB,
draw_end);
break;
}
}
}
DRAW_SETPIXELXY2_RGB
#define DRAW_SETPIXELXY2_RGB(x, y)
Definition: SDL_draw.h:233
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8583
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
y2
GLfixed GLfixed GLfixed y2
Definition: SDL_opengl_glext.h:4583
DRAW_SETPIXELXY2_BLEND_RGB
#define DRAW_SETPIXELXY2_BLEND_RGB(x, y)
Definition: SDL_draw.h:239
VLINE
#define VLINE(type, op, draw_end)
Definition: SDL_draw.h:318
DRAW_SETPIXEL_MOD_RGB
#define DRAW_SETPIXEL_MOD_RGB
Definition: SDL_draw.h:229
ABS
#define ABS(_x)
Definition: SDL_gamecontroller.c:34
DLINE
#define DLINE(type, op, draw_end)
Definition: SDL_draw.h:340
HLINE
#define HLINE(type, op, draw_end)
Definition: SDL_draw.h:296
x2
GLfixed GLfixed x2
Definition: SDL_opengl_glext.h:4583
DRAW_SETPIXEL_RGB
#define DRAW_SETPIXEL_RGB
Definition: SDL_draw.h:218
SDL_BLENDMODE_MOD
Definition: SDL_blendmode.h:50
y1
GLfixed y1
Definition: SDL_opengl_glext.h:4583
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
DRAW_SETPIXEL_ADD_RGB
#define DRAW_SETPIXEL_ADD_RGB
Definition: SDL_draw.h:225
SDL_Surface::format
SDL_PixelFormat * format
Definition: SDL_surface.h:72
AALINE
#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end)
Definition: SDL_draw.h:547
DRAW_SETPIXEL_BLEND_RGB
#define DRAW_SETPIXEL_BLEND_RGB
Definition: SDL_draw.h:221
SDL_BLENDMODE_ADD
Definition: SDL_blendmode.h:47
SDL_PixelFormat
Definition: SDL_pixels.h:299
Uint16
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:147
DRAW_SETPIXELXY2_ADD_RGB
#define DRAW_SETPIXELXY2_ADD_RGB(x, y)
Definition: SDL_draw.h:245
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
DRAW_MUL
#define DRAW_MUL(_a, _b)
Definition: SDL_draw.h:29
SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44
DRAW_SETPIXELXY2_MOD_RGB
#define DRAW_SETPIXELXY2_MOD_RGB(x, y)
Definition: SDL_draw.h:251

static void SDL_BlendLine_RGB4 | ( | SDL_Surface * | dst,
|  | int | x1,
|  | int | y1,
|  | int | x2,
|  | int | y2,
|  | SDL_BlendMode | blendMode,
|  | Uint8 | _r,
|  | Uint8 | _g,
|  | Uint8 | _b,
|  | Uint8 | _a,
|  | SDL_bool | draw_end
| ) |  |

static

Definition at line 305 of file SDL_blendline.c.

References AALINE, ABS, DLINE, DRAW_MUL, DRAW_SETPIXEL_ADD_RGB, DRAW_SETPIXEL_BLEND_RGB, DRAW_SETPIXEL_MOD_RGB, DRAW_SETPIXEL_RGB, DRAW_SETPIXELXY4_ADD_RGB, DRAW_SETPIXELXY4_BLEND_RGB, DRAW_SETPIXELXY4_MOD_RGB, DRAW_SETPIXELXY4_RGB, SDL_Surface::format, HLINE, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, and VLINE.

Referenced by SDL_CalculateBlendLineFunc().

{
const SDL_PixelFormat *fmt = dst->format;
unsigned r, g, b, a, inva;
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
r = DRAW_MUL(_r, _a);
g = DRAW_MUL(_g, _a);
b = DRAW_MUL(_b, _a);
a = _a;
} else {
r = _r;
g = _g;
b = _b;
a = _a;
}
inva = (a ^ 0xff);
if (y1 == y2) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
break;
case SDL_BLENDMODE_ADD:
HLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
break;
case SDL_BLENDMODE_MOD:
HLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
break;
default:
HLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
break;
}
} else if (x1 == x2) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
break;
case SDL_BLENDMODE_ADD:
VLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
break;
case SDL_BLENDMODE_MOD:
VLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
break;
default:
VLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
break;
}
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
break;
case SDL_BLENDMODE_ADD:
DLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
break;
case SDL_BLENDMODE_MOD:
DLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
break;
default:
DLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
break;
}
} else {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY4_BLEND_RGB, DRAW_SETPIXELXY4_BLEND_RGB,
draw_end);
break;
case SDL_BLENDMODE_ADD:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY4_ADD_RGB, DRAW_SETPIXELXY4_ADD_RGB,
draw_end);
break;
case SDL_BLENDMODE_MOD:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY4_MOD_RGB, DRAW_SETPIXELXY4_MOD_RGB,
draw_end);
break;
default:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY4_RGB, DRAW_SETPIXELXY4_BLEND_RGB,
draw_end);
break;
}
}
}
DRAW_SETPIXELXY4_MOD_RGB
#define DRAW_SETPIXELXY4_MOD_RGB(x, y)
Definition: SDL_draw.h:254
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8583
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
Uint32
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:157
y2
GLfixed GLfixed GLfixed y2
Definition: SDL_opengl_glext.h:4583
VLINE
#define VLINE(type, op, draw_end)
Definition: SDL_draw.h:318
DRAW_SETPIXEL_MOD_RGB
#define DRAW_SETPIXEL_MOD_RGB
Definition: SDL_draw.h:229
ABS
#define ABS(_x)
Definition: SDL_gamecontroller.c:34
DLINE
#define DLINE(type, op, draw_end)
Definition: SDL_draw.h:340
HLINE
#define HLINE(type, op, draw_end)
Definition: SDL_draw.h:296
x2
GLfixed GLfixed x2
Definition: SDL_opengl_glext.h:4583
DRAW_SETPIXEL_RGB
#define DRAW_SETPIXEL_RGB
Definition: SDL_draw.h:218
SDL_BLENDMODE_MOD
Definition: SDL_blendmode.h:50
y1
GLfixed y1
Definition: SDL_opengl_glext.h:4583
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
DRAW_SETPIXELXY4_BLEND_RGB
#define DRAW_SETPIXELXY4_BLEND_RGB(x, y)
Definition: SDL_draw.h:242
DRAW_SETPIXEL_ADD_RGB
#define DRAW_SETPIXEL_ADD_RGB
Definition: SDL_draw.h:225
SDL_Surface::format
SDL_PixelFormat * format
Definition: SDL_surface.h:72
AALINE
#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end)
Definition: SDL_draw.h:547
DRAW_SETPIXEL_BLEND_RGB
#define DRAW_SETPIXEL_BLEND_RGB
Definition: SDL_draw.h:221
SDL_BLENDMODE_ADD
Definition: SDL_blendmode.h:47
SDL_PixelFormat
Definition: SDL_pixels.h:299
DRAW_SETPIXELXY4_ADD_RGB
#define DRAW_SETPIXELXY4_ADD_RGB(x, y)
Definition: SDL_draw.h:248
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
DRAW_SETPIXELXY4_RGB
#define DRAW_SETPIXELXY4_RGB(x, y)
Definition: SDL_draw.h:236
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
DRAW_MUL
#define DRAW_MUL(_a, _b)
Definition: SDL_draw.h:29
SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44

static void SDL_BlendLine_RGB555 | ( | SDL_Surface * | dst,
|  | int | x1,
|  | int | y1,
|  | int | x2,
|  | int | y2,
|  | SDL_BlendMode | blendMode,
|  | Uint8 | _r,
|  | Uint8 | _g,
|  | Uint8 | _b,
|  | Uint8 | _a,
|  | SDL_bool | draw_end
| ) |  |

static

Definition at line 123 of file SDL_blendline.c.

References AALINE, ABS, DLINE, DRAW_MUL, DRAW_SETPIXEL_ADD_RGB555, DRAW_SETPIXEL_BLEND_RGB555, DRAW_SETPIXEL_MOD_RGB555, DRAW_SETPIXEL_RGB555, DRAW_SETPIXELXY_ADD_RGB555, DRAW_SETPIXELXY_BLEND_RGB555, DRAW_SETPIXELXY_MOD_RGB555, DRAW_SETPIXELXY_RGB555, HLINE, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, and VLINE.

Referenced by SDL_CalculateBlendLineFunc().

{
unsigned r, g, b, a, inva;
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
r = DRAW_MUL(_r, _a);
g = DRAW_MUL(_g, _a);
b = DRAW_MUL(_b, _a);
a = _a;
} else {
r = _r;
g = _g;
b = _b;
a = _a;
}
inva = (a ^ 0xff);
if (y1 == y2) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
break;
case SDL_BLENDMODE_ADD:
HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
break;
case SDL_BLENDMODE_MOD:
HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
break;
default:
HLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
break;
}
} else if (x1 == x2) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
break;
case SDL_BLENDMODE_ADD:
VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
break;
case SDL_BLENDMODE_MOD:
VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
break;
default:
VLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
break;
}
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
break;
case SDL_BLENDMODE_ADD:
DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
break;
case SDL_BLENDMODE_MOD:
DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
break;
default:
DLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
break;
}
} else {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY_BLEND_RGB555, DRAW_SETPIXELXY_BLEND_RGB555,
draw_end);
break;
case SDL_BLENDMODE_ADD:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY_ADD_RGB555, DRAW_SETPIXELXY_ADD_RGB555,
draw_end);
break;
case SDL_BLENDMODE_MOD:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY_MOD_RGB555, DRAW_SETPIXELXY_MOD_RGB555,
draw_end);
break;
default:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY_RGB555, DRAW_SETPIXELXY_BLEND_RGB555,
draw_end);
break;
}
}
}
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8583
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
y2
GLfixed GLfixed GLfixed y2
Definition: SDL_opengl_glext.h:4583
VLINE
#define VLINE(type, op, draw_end)
Definition: SDL_draw.h:318
ABS
#define ABS(_x)
Definition: SDL_gamecontroller.c:34
DLINE
#define DLINE(type, op, draw_end)
Definition: SDL_draw.h:340
HLINE
#define HLINE(type, op, draw_end)
Definition: SDL_draw.h:296
x2
GLfixed GLfixed x2
Definition: SDL_opengl_glext.h:4583
SDL_BLENDMODE_MOD
Definition: SDL_blendmode.h:50
y1
GLfixed y1
Definition: SDL_opengl_glext.h:4583
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
DRAW_SETPIXEL_BLEND_RGB555
#define DRAW_SETPIXEL_BLEND_RGB555
Definition: SDL_draw.h:97
DRAW_SETPIXEL_ADD_RGB555
#define DRAW_SETPIXEL_ADD_RGB555
Definition: SDL_draw.h:101
DRAW_SETPIXELXY_BLEND_RGB555
#define DRAW_SETPIXELXY_BLEND_RGB555(x, y)
Definition: SDL_draw.h:112
DRAW_SETPIXELXY_MOD_RGB555
#define DRAW_SETPIXELXY_MOD_RGB555(x, y)
Definition: SDL_draw.h:118
DRAW_SETPIXELXY_ADD_RGB555
#define DRAW_SETPIXELXY_ADD_RGB555(x, y)
Definition: SDL_draw.h:115
AALINE
#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end)
Definition: SDL_draw.h:547
SDL_BLENDMODE_ADD
Definition: SDL_blendmode.h:47
DRAW_SETPIXEL_MOD_RGB555
#define DRAW_SETPIXEL_MOD_RGB555
Definition: SDL_draw.h:105
Uint16
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:147
DRAW_SETPIXEL_RGB555
#define DRAW_SETPIXEL_RGB555
Definition: SDL_draw.h:94
DRAW_SETPIXELXY_RGB555
#define DRAW_SETPIXELXY_RGB555(x, y)
Definition: SDL_draw.h:109
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
DRAW_MUL
#define DRAW_MUL(_a, _b)
Definition: SDL_draw.h:29
SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44

static void SDL_BlendLine_RGB565 | ( | SDL_Surface * | dst,
|  | int | x1,
|  | int | y1,
|  | int | x2,
|  | int | y2,
|  | SDL_BlendMode | blendMode,
|  | Uint8 | _r,
|  | Uint8 | _g,
|  | Uint8 | _b,
|  | Uint8 | _a,
|  | SDL_bool | draw_end
| ) |  |

static

Definition at line 214 of file SDL_blendline.c.

References AALINE, ABS, DLINE, DRAW_MUL, DRAW_SETPIXEL_ADD_RGB565, DRAW_SETPIXEL_BLEND_RGB565, DRAW_SETPIXEL_MOD_RGB565, DRAW_SETPIXEL_RGB565, DRAW_SETPIXELXY_ADD_RGB565, DRAW_SETPIXELXY_BLEND_RGB565, DRAW_SETPIXELXY_MOD_RGB565, DRAW_SETPIXELXY_RGB565, HLINE, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, and VLINE.

Referenced by SDL_CalculateBlendLineFunc().

{
unsigned r, g, b, a, inva;
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
r = DRAW_MUL(_r, _a);
g = DRAW_MUL(_g, _a);
b = DRAW_MUL(_b, _a);
a = _a;
} else {
r = _r;
g = _g;
b = _b;
a = _a;
}
inva = (a ^ 0xff);
if (y1 == y2) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
break;
case SDL_BLENDMODE_ADD:
HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
break;
case SDL_BLENDMODE_MOD:
HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
break;
default:
HLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
break;
}
} else if (x1 == x2) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
break;
case SDL_BLENDMODE_ADD:
VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
break;
case SDL_BLENDMODE_MOD:
VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
break;
default:
VLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
break;
}
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
break;
case SDL_BLENDMODE_ADD:
DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
break;
case SDL_BLENDMODE_MOD:
DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
break;
default:
DLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
break;
}
} else {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY_BLEND_RGB565, DRAW_SETPIXELXY_BLEND_RGB565,
draw_end);
break;
case SDL_BLENDMODE_ADD:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY_ADD_RGB565, DRAW_SETPIXELXY_ADD_RGB565,
draw_end);
break;
case SDL_BLENDMODE_MOD:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY_MOD_RGB565, DRAW_SETPIXELXY_MOD_RGB565,
draw_end);
break;
default:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY_RGB565, DRAW_SETPIXELXY_BLEND_RGB565,
draw_end);
break;
}
}
}
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8583
DRAW_SETPIXELXY_RGB565
#define DRAW_SETPIXELXY_RGB565(x, y)
Definition: SDL_draw.h:140
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
DRAW_SETPIXEL_MOD_RGB565
#define DRAW_SETPIXEL_MOD_RGB565
Definition: SDL_draw.h:136
DRAW_SETPIXEL_ADD_RGB565
#define DRAW_SETPIXEL_ADD_RGB565
Definition: SDL_draw.h:132
y2
GLfixed GLfixed GLfixed y2
Definition: SDL_opengl_glext.h:4583
VLINE
#define VLINE(type, op, draw_end)
Definition: SDL_draw.h:318
ABS
#define ABS(_x)
Definition: SDL_gamecontroller.c:34
DLINE
#define DLINE(type, op, draw_end)
Definition: SDL_draw.h:340
HLINE
#define HLINE(type, op, draw_end)
Definition: SDL_draw.h:296
x2
GLfixed GLfixed x2
Definition: SDL_opengl_glext.h:4583
SDL_BLENDMODE_MOD
Definition: SDL_blendmode.h:50
y1
GLfixed y1
Definition: SDL_opengl_glext.h:4583
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
DRAW_SETPIXEL_BLEND_RGB565
#define DRAW_SETPIXEL_BLEND_RGB565
Definition: SDL_draw.h:128
AALINE
#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end)
Definition: SDL_draw.h:547
DRAW_SETPIXEL_RGB565
#define DRAW_SETPIXEL_RGB565
Definition: SDL_draw.h:125
SDL_BLENDMODE_ADD
Definition: SDL_blendmode.h:47
DRAW_SETPIXELXY_MOD_RGB565
#define DRAW_SETPIXELXY_MOD_RGB565(x, y)
Definition: SDL_draw.h:149
Uint16
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:147
DRAW_SETPIXELXY_BLEND_RGB565
#define DRAW_SETPIXELXY_BLEND_RGB565(x, y)
Definition: SDL_draw.h:143
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
DRAW_MUL
#define DRAW_MUL(_a, _b)
Definition: SDL_draw.h:29
SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44
DRAW_SETPIXELXY_ADD_RGB565
#define DRAW_SETPIXELXY_ADD_RGB565(x, y)
Definition: SDL_draw.h:146

static void SDL_BlendLine_RGB888 | ( | SDL_Surface * | dst,
|  | int | x1,
|  | int | y1,
|  | int | x2,
|  | int | y2,
|  | SDL_BlendMode | blendMode,
|  | Uint8 | _r,
|  | Uint8 | _g,
|  | Uint8 | _b,
|  | Uint8 | _a,
|  | SDL_bool | draw_end
| ) |  |

static

Definition at line 489 of file SDL_blendline.c.

References AALINE, ABS, DLINE, DRAW_MUL, DRAW_SETPIXEL_ADD_RGB888, DRAW_SETPIXEL_BLEND_RGB888, DRAW_SETPIXEL_MOD_RGB888, DRAW_SETPIXEL_RGB888, DRAW_SETPIXELXY_ADD_RGB888, DRAW_SETPIXELXY_BLEND_RGB888, DRAW_SETPIXELXY_MOD_RGB888, DRAW_SETPIXELXY_RGB888, HLINE, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, and VLINE.

Referenced by SDL_CalculateBlendLineFunc().

{
unsigned r, g, b, a, inva;
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
r = DRAW_MUL(_r, _a);
g = DRAW_MUL(_g, _a);
b = DRAW_MUL(_b, _a);
a = _a;
} else {
r = _r;
g = _g;
b = _b;
a = _a;
}
inva = (a ^ 0xff);
if (y1 == y2) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
break;
case SDL_BLENDMODE_ADD:
HLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
break;
case SDL_BLENDMODE_MOD:
HLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
break;
default:
HLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
break;
}
} else if (x1 == x2) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
break;
case SDL_BLENDMODE_ADD:
VLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
break;
case SDL_BLENDMODE_MOD:
VLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
break;
default:
VLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
break;
}
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
break;
case SDL_BLENDMODE_ADD:
DLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
break;
case SDL_BLENDMODE_MOD:
DLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
break;
default:
DLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
break;
}
} else {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY_BLEND_RGB888, DRAW_SETPIXELXY_BLEND_RGB888,
draw_end);
break;
case SDL_BLENDMODE_ADD:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY_ADD_RGB888, DRAW_SETPIXELXY_ADD_RGB888,
draw_end);
break;
case SDL_BLENDMODE_MOD:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY_MOD_RGB888, DRAW_SETPIXELXY_MOD_RGB888,
draw_end);
break;
default:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY_RGB888, DRAW_SETPIXELXY_BLEND_RGB888,
draw_end);
break;
}
}
}
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8583
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
DRAW_SETPIXELXY_ADD_RGB888
#define DRAW_SETPIXELXY_ADD_RGB888(x, y)
Definition: SDL_draw.h:177
Uint32
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:157
y2
GLfixed GLfixed GLfixed y2
Definition: SDL_opengl_glext.h:4583
VLINE
#define VLINE(type, op, draw_end)
Definition: SDL_draw.h:318
DRAW_SETPIXEL_ADD_RGB888
#define DRAW_SETPIXEL_ADD_RGB888
Definition: SDL_draw.h:163
ABS
#define ABS(_x)
Definition: SDL_gamecontroller.c:34
DLINE
#define DLINE(type, op, draw_end)
Definition: SDL_draw.h:340
HLINE
#define HLINE(type, op, draw_end)
Definition: SDL_draw.h:296
x2
GLfixed GLfixed x2
Definition: SDL_opengl_glext.h:4583
DRAW_SETPIXEL_BLEND_RGB888
#define DRAW_SETPIXEL_BLEND_RGB888
Definition: SDL_draw.h:159
SDL_BLENDMODE_MOD
Definition: SDL_blendmode.h:50
y1
GLfixed y1
Definition: SDL_opengl_glext.h:4583
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
DRAW_SETPIXELXY_BLEND_RGB888
#define DRAW_SETPIXELXY_BLEND_RGB888(x, y)
Definition: SDL_draw.h:174
DRAW_SETPIXEL_RGB888
#define DRAW_SETPIXEL_RGB888
Definition: SDL_draw.h:156
AALINE
#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end)
Definition: SDL_draw.h:547
DRAW_SETPIXELXY_MOD_RGB888
#define DRAW_SETPIXELXY_MOD_RGB888(x, y)
Definition: SDL_draw.h:180
SDL_BLENDMODE_ADD
Definition: SDL_blendmode.h:47
DRAW_SETPIXELXY_RGB888
#define DRAW_SETPIXELXY_RGB888(x, y)
Definition: SDL_draw.h:171
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
DRAW_SETPIXEL_MOD_RGB888
#define DRAW_SETPIXEL_MOD_RGB888
Definition: SDL_draw.h:167
DRAW_MUL
#define DRAW_MUL(_a, _b)
Definition: SDL_draw.h:29
SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44

static void SDL_BlendLine_RGBA4 | ( | SDL_Surface * | dst,
|  | int | x1,
|  | int | y1,
|  | int | x2,
|  | int | y2,
|  | SDL_BlendMode | blendMode,
|  | Uint8 | _r,
|  | Uint8 | _g,
|  | Uint8 | _b,
|  | Uint8 | _a,
|  | SDL_bool | draw_end
| ) |  |

static

Definition at line 397 of file SDL_blendline.c.

References AALINE, ABS, DLINE, DRAW_MUL, DRAW_SETPIXEL_ADD_RGBA, DRAW_SETPIXEL_BLEND_RGBA, DRAW_SETPIXEL_MOD_RGBA, DRAW_SETPIXEL_RGBA, DRAW_SETPIXELXY4_ADD_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA, DRAW_SETPIXELXY4_MOD_RGBA, DRAW_SETPIXELXY4_RGBA, SDL_Surface::format, HLINE, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, and VLINE.

Referenced by SDL_CalculateBlendLineFunc().

{
const SDL_PixelFormat *fmt = dst->format;
unsigned r, g, b, a, inva;
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
r = DRAW_MUL(_r, _a);
g = DRAW_MUL(_g, _a);
b = DRAW_MUL(_b, _a);
a = _a;
} else {
r = _r;
g = _g;
b = _b;
a = _a;
}
inva = (a ^ 0xff);
if (y1 == y2) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
break;
case SDL_BLENDMODE_ADD:
HLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
break;
case SDL_BLENDMODE_MOD:
HLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
break;
default:
HLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
break;
}
} else if (x1 == x2) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
break;
case SDL_BLENDMODE_ADD:
VLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
break;
case SDL_BLENDMODE_MOD:
VLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
break;
default:
VLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
break;
}
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
break;
case SDL_BLENDMODE_ADD:
DLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
break;
case SDL_BLENDMODE_MOD:
DLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
break;
default:
DLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
break;
}
} else {
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY4_BLEND_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA,
draw_end);
break;
case SDL_BLENDMODE_ADD:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY4_ADD_RGBA, DRAW_SETPIXELXY4_ADD_RGBA,
draw_end);
break;
case SDL_BLENDMODE_MOD:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY4_MOD_RGBA, DRAW_SETPIXELXY4_MOD_RGBA,
draw_end);
break;
default:
AALINE(x1, y1, x2, y2,
DRAW_SETPIXELXY4_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA,
draw_end);
break;
}
}
}
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8583
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
Uint32
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:157
DRAW_SETPIXEL_RGBA
#define DRAW_SETPIXEL_RGBA
Definition: SDL_draw.h:262
DRAW_SETPIXELXY4_RGBA
#define DRAW_SETPIXELXY4_RGBA(x, y)
Definition: SDL_draw.h:277
y2
GLfixed GLfixed GLfixed y2
Definition: SDL_opengl_glext.h:4583
VLINE
#define VLINE(type, op, draw_end)
Definition: SDL_draw.h:318
DRAW_SETPIXELXY4_ADD_RGBA
#define DRAW_SETPIXELXY4_ADD_RGBA(x, y)
Definition: SDL_draw.h:283
ABS
#define ABS(_x)
Definition: SDL_gamecontroller.c:34
DLINE
#define DLINE(type, op, draw_end)
Definition: SDL_draw.h:340
HLINE
#define HLINE(type, op, draw_end)
Definition: SDL_draw.h:296
DRAW_SETPIXELXY4_MOD_RGBA
#define DRAW_SETPIXELXY4_MOD_RGBA(x, y)
Definition: SDL_draw.h:286
x2
GLfixed GLfixed x2
Definition: SDL_opengl_glext.h:4583
SDL_BLENDMODE_MOD
Definition: SDL_blendmode.h:50
y1
GLfixed y1
Definition: SDL_opengl_glext.h:4583
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
SDL_Surface::format
SDL_PixelFormat * format
Definition: SDL_surface.h:72
AALINE
#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end)
Definition: SDL_draw.h:547
SDL_BLENDMODE_ADD
Definition: SDL_blendmode.h:47
SDL_PixelFormat
Definition: SDL_pixels.h:299
DRAW_SETPIXEL_ADD_RGBA
#define DRAW_SETPIXEL_ADD_RGBA
Definition: SDL_draw.h:269
DRAW_SETPIXELXY4_BLEND_RGBA
#define DRAW_SETPIXELXY4_BLEND_RGBA(x, y)
Definition: SDL_draw.h:280
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
DRAW_SETPIXEL_MOD_RGBA
#define DRAW_SETPIXEL_MOD_RGBA
Definition: SDL_draw.h:273
DRAW_SETPIXEL_BLEND_RGBA
#define DRAW_SETPIXEL_BLEND_RGBA
Definition: SDL_draw.h:265
DRAW_MUL
#define DRAW_MUL(_a, _b)
Definition: SDL_draw.h:29
SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44

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

Definition at line 733 of file SDL_blendline.c.

References SDL_Surface::clip_rect, SDL_Surface::format, i, SDL_BlendPoint(), SDL_CalculateBlendLineFunc(), SDL_IntersectRectAndLine, SDL_SetError, SDL_Point::x, and SDL_Point::y.

Referenced by SW_RenderDrawLines().

{
int i;
int x1, y1;
int x2, y2;
SDL_bool draw_end;
BlendLineFunc func;
if (!dst) {
return SDL_SetError("SDL_BlendLines(): Passed NULL destination surface");
}
func = SDL_CalculateBlendLineFunc(dst->format);
if (!func) {
return SDL_SetError("SDL_BlendLines(): Unsupported surface format");
}
for (i = 1; i < count; ++i) {
x1 = points[i-1].x;
y1 = points[i-1].y;
x2 = points[i].x;
y2 = points[i].y;
/* Perform clipping */
/* FIXME: We don't actually want to clip, as it may change line slope */
if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
continue;
}
/* Draw the end if it was clipped */
draw_end = (x2 != points[i].x || y2 != points[i].y);
func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, draw_end);
}
if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
SDL_BlendPoint(dst, points[count-1].x, points[count-1].y,
blendMode, r, g, b, a);
}
return 0;
}
BlendLineFunc
void(* BlendLineFunc)(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_bool draw_end)
Definition: SDL_blendline.c:670
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8583
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
SDL_CalculateBlendLineFunc
static BlendLineFunc SDL_CalculateBlendLineFunc(const SDL_PixelFormat *fmt)
Definition: SDL_blendline.c:677
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1564
y2
GLfixed GLfixed GLfixed y2
Definition: SDL_opengl_glext.h:4583
x2
GLfixed GLfixed x2
Definition: SDL_opengl_glext.h:4583
y1
GLfixed y1
Definition: SDL_opengl_glext.h:4583
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:126
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
SDL_Point::x
int x
Definition: SDL_rect.h:50
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
SDL_Point::y
int y
Definition: SDL_rect.h:51
SDL_Surface::clip_rect
SDL_Rect clip_rect
Definition: SDL_surface.h:85
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:42
SDL_Surface::format
SDL_PixelFormat * format
Definition: SDL_surface.h:72
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
func
GLenum func
Definition: SDL_opengl_glext.h:657
SDL_BlendPoint
int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Definition: SDL_blendpoint.c:196
SDL_IntersectRectAndLine
#define SDL_IntersectRectAndLine
Definition: SDL_dynapi_overrides.h:303
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109

static BlendLineFunc SDL_CalculateBlendLineFunc | ( | const SDL_PixelFormat * | fmt | ) |

static

Definition at line 677 of file SDL_blendline.c.

References SDL_PixelFormat::Amask, SDL_PixelFormat::BytesPerPixel, NULL, SDL_PixelFormat::Rmask, SDL_BlendLine_ARGB8888(), SDL_BlendLine_RGB2(), SDL_BlendLine_RGB4(), SDL_BlendLine_RGB555(), SDL_BlendLine_RGB565(), SDL_BlendLine_RGB888(), and SDL_BlendLine_RGBA4().

Referenced by SDL_BlendLine(), and SDL_BlendLines().

{
switch (fmt->BytesPerPixel) {
case 2:
if (fmt->Rmask == 0x7C00) {
return SDL_BlendLine_RGB555;
} else if (fmt->Rmask == 0xF800) {
return SDL_BlendLine_RGB565;
} else {
return SDL_BlendLine_RGB2;
}
break;
case 4:
if (fmt->Rmask == 0x00FF0000) {
if (fmt->Amask) {
return SDL_BlendLine_ARGB8888;
} else {
return SDL_BlendLine_RGB888;
}
} else {
if (fmt->Amask) {
return SDL_BlendLine_RGBA4;
} else {
return SDL_BlendLine_RGB4;
}
}
}
return NULL;
}
SDL_BlendLine_RGBA4
static void SDL_BlendLine_RGBA4(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end)
Definition: SDL_blendline.c:397
SDL_PixelFormat::BytesPerPixel
Uint8 BytesPerPixel
Definition: SDL_pixels.h:304
SDL_BlendLine_RGB555
static void SDL_BlendLine_RGB555(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end)
Definition: SDL_blendline.c:123
SDL_BlendLine_RGB4
static void SDL_BlendLine_RGB4(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end)
Definition: SDL_blendline.c:305
SDL_BlendLine_RGB888
static void SDL_BlendLine_RGB888(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end)
Definition: SDL_blendline.c:489
NULL
#define NULL
Definition: begin_code.h:143
SDL_BlendLine_ARGB8888
static void SDL_BlendLine_ARGB8888(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end)
Definition: SDL_blendline.c:580
SDL_PixelFormat::Rmask
Uint32 Rmask
Definition: SDL_pixels.h:306
SDL_BlendLine_RGB2
static void SDL_BlendLine_RGB2(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end)
Definition: SDL_blendline.c:31
SDL_BlendLine_RGB565
static void SDL_BlendLine_RGB565(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end)
Definition: SDL_blendline.c:214
SDL_PixelFormat::Amask
Uint32 Amask
Definition: SDL_pixels.h:309