SDL_blit_slow.h File Reference
`#include "../SDL_internal.h"`
Include dependency graph for SDL_blit_slow.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Functions

void | SDL_Blit_Slow (SDL_BlitInfo *info)

## Function Documentation

void SDL_Blit_Slow | ( | SDL_BlitInfo * | info | ) |

Definition at line 31 of file SDL_blit_slow.c.

References SDL_BlitInfo::a, SDL_PixelFormat::Amask, ASSEMBLE_RGB, ASSEMBLE_RGBA, SDL_BlitInfo::b, SDL_PixelFormat::Bshift, SDL_PixelFormat::BytesPerPixel, SDL_BlitInfo::colorkey, DISEMBLE_RGB, DISEMBLE_RGBA, SDL_BlitInfo::dst, SDL_BlitInfo::dst_fmt, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_pitch, SDL_BlitInfo::dst_w, blit_table::dstB, blit_table::dstbpp, blit_table::dstG, blit_table::dstR, SDL_BlitInfo::flags, SDL_BlitInfo::g, SDL_PixelFormat::Gshift, SDL_BlitInfo::r, SDL_PixelFormat::Rshift, SDL_COPY_ADD, SDL_COPY_BLEND, SDL_COPY_COLORKEY, SDL_COPY_MOD, SDL_COPY_MODULATE_ALPHA, SDL_COPY_MODULATE_COLOR, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, SDL_BlitInfo::src_h, SDL_BlitInfo::src_pitch, SDL_BlitInfo::src_w, blit_table::srcB, blit_table::srcG, and blit_table::srcR.

Referenced by SDL_CalculateBlit().

{
const int flags = info->flags;
const Uint32 modulateR = info->r;
const Uint32 modulateG = info->g;
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
int srcy, srcx;
int posy, posx;
int incy, incx;
SDL_PixelFormat *src_fmt = info->src_fmt;
SDL_PixelFormat *dst_fmt = info->dst_fmt;
int srcbpp = src_fmt->BytesPerPixel;
int dstbpp = dst_fmt->BytesPerPixel;
srcy = 0;
posy = 0;
incy = (info->src_h << 16) / info->dst_h;
incx = (info->src_w << 16) / info->dst_w;
while (info->dst_h--) {
Uint8 *src = 0;
Uint8 *dst = (Uint8 *) info->dst;
int n = info->dst_w;
srcx = -1;
posx = 0x10000L;
while (posy >= 0x10000L) {
++srcy;
posy -= 0x10000L;
}
while (n--) {
if (posx >= 0x10000L) {
while (posx >= 0x10000L) {
++srcx;
posx -= 0x10000L;
}
src =
(info->src + (srcy * info->src_pitch) + (srcx * srcbpp));
}
if (src_fmt->Amask) {
DISEMBLE_RGBA(src, srcbpp, src_fmt, srcpixel, srcR, srcG,
srcB, srcA);
} else {
DISEMBLE_RGB(src, srcbpp, src_fmt, srcpixel, srcR, srcG,
srcB);
srcA = 0xFF;
}
if (flags & SDL_COPY_COLORKEY) {
/* srcpixel isn't set for 24 bpp */
if (srcbpp == 3) {
srcpixel = (srcR << src_fmt->Rshift) |
(srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift);
}
if (srcpixel == info->colorkey) {
posx += incx;
dst += dstbpp;
continue;
}
}
if (dst_fmt->Amask) {
DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG,
dstB, dstA);
} else {
DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG,
dstB);
dstA = 0xFF;
}
if (flags & SDL_COPY_MODULATE_COLOR) {
srcR = (srcR * modulateR) / 255;
srcG = (srcG * modulateG) / 255;
srcB = (srcB * modulateB) / 255;
}
if (flags & SDL_COPY_MODULATE_ALPHA) {
srcA = (srcA * modulateA) / 255;
}
if (flags & (SDL_COPY_BLEND | SDL_COPY_ADD)) {
/* This goes away if we ever use premultiplied alpha */
if (srcA < 255) {
srcR = (srcR * srcA) / 255;
srcG = (srcG * srcA) / 255;
srcB = (srcB * srcA) / 255;
}
}
switch (flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD)) {
case 0:
dstR = srcR;
dstG = srcG;
dstB = srcB;
dstA = srcA;
break;
case SDL_COPY_BLEND:
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
break;
case SDL_COPY_ADD:
dstR = srcR + dstR;
if (dstR > 255)
dstR = 255;
dstG = srcG + dstG;
if (dstG > 255)
dstG = 255;
dstB = srcB + dstB;
if (dstB > 255)
dstB = 255;
break;
case SDL_COPY_MOD:
dstR = (srcR * dstR) / 255;
dstG = (srcG * dstG) / 255;
dstB = (srcB * dstB) / 255;
break;
}
if (dst_fmt->Amask) {
ASSEMBLE_RGBA(dst, dstbpp, dst_fmt, dstR, dstG, dstB, dstA);
} else {
ASSEMBLE_RGB(dst, dstbpp, dst_fmt, dstR, dstG, dstB);
}
posx += incx;
dst += dstbpp;
}
posy += incy;
info->dst += info->dst_pitch;
}
}
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1737
SDL_BlitInfo::r
Uint8 r
Definition: SDL_blit.h:70
SDL_COPY_MODULATE_COLOR
#define SDL_COPY_MODULATE_COLOR
Definition: SDL_blit.h:34
blit_table::srcG
Uint32 srcG
Definition: SDL_blit_N.c:2460
blit_table::srcB
Uint32 srcB
Definition: SDL_blit_N.c:2460
SDL_BlitInfo::b
Uint8 b
Definition: SDL_blit.h:70
SDL_COPY_COLORKEY
#define SDL_COPY_COLORKEY
Definition: SDL_blit.h:39
n
GLdouble n
Definition: SDL_opengl_glext.h:1952
Uint32
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:155
blit_table::dstB
Uint32 dstB
Definition: SDL_blit_N.c:2462
blit_table::dstR
Uint32 dstR
Definition: SDL_blit_N.c:2462
SDL_PixelFormat::BytesPerPixel
Uint8 BytesPerPixel
Definition: SDL_pixels.h:304
SDL_BlitInfo::flags
int flags
Definition: SDL_blit.h:68
SDL_BlitInfo::g
Uint8 g
Definition: SDL_blit.h:70
SDL_COPY_MOD
#define SDL_COPY_MOD
Definition: SDL_blit.h:38
SDL_BlitInfo::src_fmt
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
ASSEMBLE_RGBA
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a)
Definition: SDL_blit.h:401
SDL_BlitInfo::src_h
int src_h
Definition: SDL_blit.h:58
SDL_BlitInfo::dst_pitch
int dst_pitch
Definition: SDL_blit.h:63
SDL_BlitInfo::src_w
int src_w
Definition: SDL_blit.h:58
SDL_BlitInfo::dst_h
int dst_h
Definition: SDL_blit.h:62
blit_table::dstbpp
int dstbpp
Definition: SDL_blit_N.c:2461
SDL_COPY_ADD
#define SDL_COPY_ADD
Definition: SDL_blit.h:37
SDL_BlitInfo::colorkey
Uint32 colorkey
Definition: SDL_blit.h:69
SDL_BlitInfo::dst
Uint8 * dst
Definition: SDL_blit.h:61
blit_table::srcR
Uint32 srcR
Definition: SDL_blit_N.c:2460
DISEMBLE_RGBA
#define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a)
Definition: SDL_blit.h:352
blit_table::dstG
Uint32 dstG
Definition: SDL_blit_N.c:2462
SDL_PixelFormat::Bshift
Uint8 Bshift
Definition: SDL_pixels.h:316
SDL_PixelFormat::Rshift
Uint8 Rshift
Definition: SDL_pixels.h:314
Uint8
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
ASSEMBLE_RGB
#define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b)
Definition: SDL_blit.h:260
SDL_BlitInfo::src
Uint8 * src
Definition: SDL_blit.h:57
SDL_BlitInfo::dst_fmt
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
SDL_BlitInfo::src_pitch
int src_pitch
Definition: SDL_blit.h:59
SDL_PixelFormat::Gshift
Uint8 Gshift
Definition: SDL_pixels.h:315
SDL_COPY_MODULATE_ALPHA
#define SDL_COPY_MODULATE_ALPHA
Definition: SDL_blit.h:35
SDL_PixelFormat
Definition: SDL_pixels.h:299
DISEMBLE_RGB
#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b)
Definition: SDL_blit.h:176
flags
GLbitfield flags
Definition: SDL_opengl_glext.h:1480
SDL_PixelFormat::Amask
Uint32 Amask
Definition: SDL_pixels.h:309
SDL_BlitInfo::dst_w
int dst_w
Definition: SDL_blit.h:62
src
GLenum src
Definition: SDL_opengl_glext.h:1737
SDL_COPY_BLEND
#define SDL_COPY_BLEND
Definition: SDL_blit.h:36
SDL_BlitInfo::a
Uint8 a
Definition: SDL_blit.h:70