SDL  2.0
SDL_blit_N.c File Reference
#include "../SDL_internal.h"
#include "SDL_video.h"
#include "SDL_endian.h"
#include "SDL_cpuinfo.h"
#include "SDL_blit.h"
#include "SDL_assert.h"
+ Include dependency graph for SDL_blit_N.c:

Go to the source code of this file.

Data Structures

struct  blit_table

Macros

#define GetBlitFeatures()   ((Uint32)(SDL_HasMMX() ? 1 : 0))
#define HI   1
#define LO   0
#define RGB888_RGB332(dst, src)
#define RGB101010_RGB332(dst, src)
#define RGB888_RGB555(dst, src)
#define RGB888_RGB565(dst, src)
#define RGB565_32(dst, src, map)   (map[src[LO]*2] + map[src[HI]*2+1])
#define NO_ALPHA   1
#define SET_ALPHA   2
#define COPY_ALPHA   4
#define MASKOK(x, y)   (((x) == (y)) || ((y) == 0x00000000))

Functions

static void Blit_RGB888_index8 (SDL_BlitInfo *info)
static void Blit_RGB101010_index8 (SDL_BlitInfo *info)
static void Blit_RGB888_RGB555 (SDL_BlitInfo *info)
static void Blit_RGB888_RGB565 (SDL_BlitInfo *info)
static void Blit_RGB565_32 (SDL_BlitInfo *info, const Uint32 *map)
static void Blit_RGB565_ARGB8888 (SDL_BlitInfo *info)
static void Blit_RGB565_ABGR8888 (SDL_BlitInfo *info)
static void Blit_RGB565_RGBA8888 (SDL_BlitInfo *info)
static void Blit_RGB565_BGRA8888 (SDL_BlitInfo *info)
static void BlitNto1 (SDL_BlitInfo *info)
static void Blit4to4MaskAlpha (SDL_BlitInfo *info)
static void Blit4to4CopyAlpha (SDL_BlitInfo *info)
static void BlitNtoN (SDL_BlitInfo *info)
static void BlitNtoNCopyAlpha (SDL_BlitInfo *info)
static void BlitNto1Key (SDL_BlitInfo *info)
static void Blit2to2Key (SDL_BlitInfo *info)
static void BlitNtoNKey (SDL_BlitInfo *info)
static void BlitNtoNKeyCopyAlpha (SDL_BlitInfo *info)
static void Blit2101010toN (SDL_BlitInfo *info)
static void BlitNto2101010 (SDL_BlitInfo *info)
SDL_BlitFunc SDL_CalculateBlitN (SDL_Surface *surface)

Variables

static const Uint32 RGB565_ARGB8888_LUT [512]
static const Uint32 RGB565_ABGR8888_LUT [512]
static const Uint32 RGB565_RGBA8888_LUT [512]
static const Uint32 RGB565_BGRA8888_LUT [512]
static struct blit_table normal_blit_1 []
static struct blit_table normal_blit_2 []
static struct blit_table normal_blit_3 []
static struct blit_table normal_blit_4 []
static struct blit_table *const normal_blit []

Macro Definition Documentation

#define COPY_ALPHA   4

Definition at line 2521 of file SDL_blit_N.c.

Referenced by SDL_CalculateBlitN().

#define GetBlitFeatures ( )    ((Uint32)(SDL_HasMMX() ? 1 : 0))

Definition at line 878 of file SDL_blit_N.c.

Referenced by SDL_CalculateBlitN().

#define HI   1

Definition at line 883 of file SDL_blit_N.c.

Referenced by Blit1to2().

#define LO   0

Definition at line 884 of file SDL_blit_N.c.

Referenced by Blit1to2().

#define MASKOK (   x,
  y 
)    (((x) == (y)) || ((y) == 0x00000000))

Definition at line 2587 of file SDL_blit_N.c.

Referenced by SDL_CalculateBlitN().

#define NO_ALPHA   1

Definition at line 2519 of file SDL_blit_N.c.

Referenced by SDL_CalculateBlitN().

#define RGB101010_RGB332 (   dst,
  src 
)
Value:
{ \
dst = (Uint8)((((src)&0x38000000)>>22)| \
(((src)&0x000E0000)>>15)| \
(((src)&0x00000300)>>8)); \
}

Definition at line 1001 of file SDL_blit_N.c.

Referenced by Blit_RGB101010_index8().

#define RGB565_32 (   dst,
  src,
  map 
)    (map[src[LO]*2] + map[src[HI]*2+1])

Definition at line 1364 of file SDL_blit_N.c.

Referenced by Blit_RGB565_32().

#define RGB888_RGB332 (   dst,
  src 
)
Value:
{ \
dst = (Uint8)((((src)&0x00E00000)>>16)| \
(((src)&0x0000E000)>>11)| \
(((src)&0x000000C0)>>6)); \
}

Definition at line 891 of file SDL_blit_N.c.

Referenced by Blit_RGB888_index8().

#define RGB888_RGB555 (   dst,
  src 
)
Value:
{ \
*(Uint16 *)(dst) = (Uint16)((((*src)&0x00F80000)>>9)| \
(((*src)&0x0000F800)>>6)| \
(((*src)&0x000000F8)>>3)); \
}

Definition at line 1111 of file SDL_blit_N.c.

Referenced by Blit_RGB888_RGB555().

#define RGB888_RGB565 (   dst,
  src 
)
Value:
{ \
*(Uint16 *)(dst) = (Uint16)((((*src)&0x00F80000)>>8)| \
(((*src)&0x0000FC00)>>5)| \
(((*src)&0x000000F8)>>3)); \
}

Definition at line 1237 of file SDL_blit_N.c.

Referenced by Blit_RGB888_RGB565().

#define SET_ALPHA   2

Definition at line 2520 of file SDL_blit_N.c.

Referenced by SDL_CalculateBlitN().

Function Documentation

static void Blit2101010toN ( SDL_BlitInfo info)
static

Definition at line 2456 of file SDL_blit_N.c.

References ASSEMBLE_RGBA, SDL_PixelFormat::BytesPerPixel, SDL_BlitInfo::dst, SDL_BlitInfo::dst_fmt, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, RGBA_FROM_ARGB2101010, SDL_BlitInfo::src, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitN().

{
int width = info->dst_w;
int height = info->dst_h;
Uint8 *src = info->src;
int srcskip = info->src_skip;
Uint8 *dst = info->dst;
int dstskip = info->dst_skip;
SDL_PixelFormat *dstfmt = info->dst_fmt;
int dstbpp = dstfmt->BytesPerPixel;
Uint32 Pixel;
unsigned sR, sG, sB, sA;
while (height--) {
/* *INDENT-OFF* */
{
Pixel = *(Uint32 *)src;
RGBA_FROM_ARGB2101010(Pixel, sR, sG, sB, sA);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, sA);
dst += dstbpp;
src += 4;
},
/* *INDENT-ON* */
src += srcskip;
dst += dstskip;
}
}
static void Blit2to2Key ( SDL_BlitInfo info)
static

Definition at line 2283 of file SDL_blit_N.c.

References SDL_PixelFormat::Amask, SDL_BlitInfo::colorkey, SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitN().

{
int width = info->dst_w;
int height = info->dst_h;
Uint16 *srcp = (Uint16 *) info->src;
int srcskip = info->src_skip;
Uint16 *dstp = (Uint16 *) info->dst;
int dstskip = info->dst_skip;
Uint32 ckey = info->colorkey;
Uint32 rgbmask = ~info->src_fmt->Amask;
/* Set up some basic variables */
srcskip /= 2;
dstskip /= 2;
ckey &= rgbmask;
while (height--) {
/* *INDENT-OFF* */
{
if ( (*srcp & rgbmask) != ckey ) {
*dstp = *srcp;
}
dstp++;
srcp++;
},
/* *INDENT-ON* */
srcp += srcskip;
dstp += dstskip;
}
}
static void Blit4to4CopyAlpha ( SDL_BlitInfo info)
static

Definition at line 2127 of file SDL_blit_N.c.

References SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, SDL_BlitInfo::src, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitN().

{
int width = info->dst_w;
int height = info->dst_h;
Uint32 *src = (Uint32 *) info->src;
int srcskip = info->src_skip;
Uint32 *dst = (Uint32 *) info->dst;
int dstskip = info->dst_skip;
/* RGBA->RGBA, COPY_ALPHA */
while (height--) {
/* *INDENT-OFF* */
{
*dst = *src;
++dst;
++src;
},
/* *INDENT-ON* */
src = (Uint32 *) ((Uint8 *) src + srcskip);
dst = (Uint32 *) ((Uint8 *) dst + dstskip);
}
}
static void Blit4to4MaskAlpha ( SDL_BlitInfo info)
static

Definition at line 2077 of file SDL_blit_N.c.

References SDL_BlitInfo::a, SDL_PixelFormat::Aloss, SDL_PixelFormat::Amask, SDL_PixelFormat::Ashift, SDL_PixelFormat::Bmask, SDL_BlitInfo::dst, SDL_BlitInfo::dst_fmt, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, SDL_PixelFormat::Gmask, SDL_PixelFormat::Rmask, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitN().

{
int width = info->dst_w;
int height = info->dst_h;
Uint32 *src = (Uint32 *) info->src;
int srcskip = info->src_skip;
Uint32 *dst = (Uint32 *) info->dst;
int dstskip = info->dst_skip;
SDL_PixelFormat *srcfmt = info->src_fmt;
SDL_PixelFormat *dstfmt = info->dst_fmt;
if (dstfmt->Amask) {
/* RGB->RGBA, SET_ALPHA */
Uint32 mask = (info->a >> dstfmt->Aloss) << dstfmt->Ashift;
while (height--) {
/* *INDENT-OFF* */
{
*dst = *src | mask;
++dst;
++src;
},
/* *INDENT-ON* */
src = (Uint32 *) ((Uint8 *) src + srcskip);
dst = (Uint32 *) ((Uint8 *) dst + dstskip);
}
} else {
/* RGBA->RGB, NO_ALPHA */
Uint32 mask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
while (height--) {
/* *INDENT-OFF* */
{
*dst = *src & mask;
++dst;
++src;
},
/* *INDENT-ON* */
src = (Uint32 *) ((Uint8 *) src + srcskip);
dst = (Uint32 *) ((Uint8 *) dst + dstskip);
}
}
}
static void Blit_RGB101010_index8 ( SDL_BlitInfo info)
static

Definition at line 1007 of file SDL_blit_N.c.

References SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, map, NULL, RGB101010_RGB332, SDL_BlitInfo::src, SDL_BlitInfo::src_skip, and SDL_BlitInfo::table.

Referenced by SDL_CalculateBlitN().

{
#ifndef USE_DUFFS_LOOP
int c;
#endif
int width, height;
const Uint8 *map;
int srcskip, dstskip;
/* Set up some basic variables */
width = info->dst_w;
height = info->dst_h;
src = (Uint32 *) info->src;
srcskip = info->src_skip / 4;
dst = info->dst;
dstskip = info->dst_skip;
map = info->table;
if (map == NULL) {
while (height--) {
#ifdef USE_DUFFS_LOOP
/* *INDENT-OFF* */
RGB101010_RGB332(*dst++, *src);
, width);
/* *INDENT-ON* */
#else
for (c = width / 4; c; --c) {
/* Pack RGB into 8bit pixel */
++src;
RGB101010_RGB332(*dst++, *src);
++src;
RGB101010_RGB332(*dst++, *src);
++src;
RGB101010_RGB332(*dst++, *src);
++src;
}
switch (width & 3) {
case 3:
RGB101010_RGB332(*dst++, *src);
++src;
case 2:
RGB101010_RGB332(*dst++, *src);
++src;
case 1:
RGB101010_RGB332(*dst++, *src);
++src;
}
#endif /* USE_DUFFS_LOOP */
src += srcskip;
dst += dstskip;
}
} else {
int Pixel;
while (height--) {
#ifdef USE_DUFFS_LOOP
/* *INDENT-OFF* */
RGB101010_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
, width);
/* *INDENT-ON* */
#else
for (c = width / 4; c; --c) {
/* Pack RGB into 8bit pixel */
RGB101010_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
RGB101010_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
RGB101010_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
RGB101010_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
}
switch (width & 3) {
case 3:
RGB101010_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
case 2:
RGB101010_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
case 1:
RGB101010_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
}
#endif /* USE_DUFFS_LOOP */
src += srcskip;
dst += dstskip;
}
}
}
static void Blit_RGB565_32 ( SDL_BlitInfo info,
const Uint32 map 
)
static

Definition at line 1366 of file SDL_blit_N.c.

References SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, RGB565_32, SDL_BlitInfo::src, and SDL_BlitInfo::src_skip.

Referenced by Blit_RGB565_ABGR8888(), Blit_RGB565_ARGB8888(), Blit_RGB565_BGRA8888(), and Blit_RGB565_RGBA8888().

{
#ifndef USE_DUFFS_LOOP
int c;
#endif
int width, height;
int srcskip, dstskip;
/* Set up some basic variables */
width = info->dst_w;
height = info->dst_h;
src = (Uint8 *) info->src;
srcskip = info->src_skip;
dst = (Uint32 *) info->dst;
dstskip = info->dst_skip / 4;
#ifdef USE_DUFFS_LOOP
while (height--) {
/* *INDENT-OFF* */
{
*dst++ = RGB565_32(dst, src, map);
src += 2;
},
/* *INDENT-ON* */
src += srcskip;
dst += dstskip;
}
#else
while (height--) {
/* Copy in 4 pixel chunks */
for (c = width / 4; c; --c) {
*dst++ = RGB565_32(dst, src, map);
src += 2;
*dst++ = RGB565_32(dst, src, map);
src += 2;
*dst++ = RGB565_32(dst, src, map);
src += 2;
*dst++ = RGB565_32(dst, src, map);
src += 2;
}
/* Get any leftovers */
switch (width & 3) {
case 3:
*dst++ = RGB565_32(dst, src, map);
src += 2;
case 2:
*dst++ = RGB565_32(dst, src, map);
src += 2;
case 1:
*dst++ = RGB565_32(dst, src, map);
src += 2;
break;
}
src += srcskip;
dst += dstskip;
}
#endif /* USE_DUFFS_LOOP */
}
static void Blit_RGB565_ABGR8888 ( SDL_BlitInfo info)
static

Definition at line 1700 of file SDL_blit_N.c.

References Blit_RGB565_32().

static void Blit_RGB565_ARGB8888 ( SDL_BlitInfo info)
static

Definition at line 1562 of file SDL_blit_N.c.

References Blit_RGB565_32().

static void Blit_RGB565_BGRA8888 ( SDL_BlitInfo info)
static

Definition at line 1976 of file SDL_blit_N.c.

References Blit_RGB565_32().

static void Blit_RGB565_RGBA8888 ( SDL_BlitInfo info)
static

Definition at line 1838 of file SDL_blit_N.c.

References Blit_RGB565_32().

static void Blit_RGB888_index8 ( SDL_BlitInfo info)
static

Definition at line 897 of file SDL_blit_N.c.

References SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, map, NULL, RGB888_RGB332, SDL_BlitInfo::src, SDL_BlitInfo::src_skip, and SDL_BlitInfo::table.

Referenced by SDL_CalculateBlitN().

{
#ifndef USE_DUFFS_LOOP
int c;
#endif
int width, height;
const Uint8 *map;
int srcskip, dstskip;
/* Set up some basic variables */
width = info->dst_w;
height = info->dst_h;
src = (Uint32 *) info->src;
srcskip = info->src_skip / 4;
dst = info->dst;
dstskip = info->dst_skip;
map = info->table;
if (map == NULL) {
while (height--) {
#ifdef USE_DUFFS_LOOP
/* *INDENT-OFF* */
RGB888_RGB332(*dst++, *src);
, width);
/* *INDENT-ON* */
#else
for (c = width / 4; c; --c) {
/* Pack RGB into 8bit pixel */
++src;
RGB888_RGB332(*dst++, *src);
++src;
RGB888_RGB332(*dst++, *src);
++src;
RGB888_RGB332(*dst++, *src);
++src;
}
switch (width & 3) {
case 3:
RGB888_RGB332(*dst++, *src);
++src;
case 2:
RGB888_RGB332(*dst++, *src);
++src;
case 1:
RGB888_RGB332(*dst++, *src);
++src;
}
#endif /* USE_DUFFS_LOOP */
src += srcskip;
dst += dstskip;
}
} else {
int Pixel;
while (height--) {
#ifdef USE_DUFFS_LOOP
/* *INDENT-OFF* */
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
, width);
/* *INDENT-ON* */
#else
for (c = width / 4; c; --c) {
/* Pack RGB into 8bit pixel */
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
}
switch (width & 3) {
case 3:
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
case 2:
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
case 1:
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
}
#endif /* USE_DUFFS_LOOP */
src += srcskip;
dst += dstskip;
}
}
}
static void Blit_RGB888_RGB555 ( SDL_BlitInfo info)
static

Definition at line 1127 of file SDL_blit_N.c.

References SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, RGB888_RGB555, SDL_BlitInfo::src, and SDL_BlitInfo::src_skip.

{
#ifndef USE_DUFFS_LOOP
int c;
#endif
int width, height;
int srcskip, dstskip;
/* Set up some basic variables */
width = info->dst_w;
height = info->dst_h;
src = (Uint32 *) info->src;
srcskip = info->src_skip / 4;
dst = (Uint16 *) info->dst;
dstskip = info->dst_skip / 2;
#ifdef USE_DUFFS_LOOP
while (height--) {
/* *INDENT-OFF* */
RGB888_RGB555(dst, src);
++src;
++dst;
, width);
/* *INDENT-ON* */
src += srcskip;
dst += dstskip;
}
#else
/* Memory align at 4-byte boundary, if necessary */
if ((long) dst & 0x03) {
/* Don't do anything if width is 0 */
if (width == 0) {
return;
}
--width;
while (height--) {
/* Perform copy alignment */
RGB888_RGB555(dst, src);
++src;
++dst;
/* Copy in 4 pixel chunks */
for (c = width / 4; c; --c) {
RGB888_RGB555_TWO(dst, src);
src += 2;
dst += 2;
RGB888_RGB555_TWO(dst, src);
src += 2;
dst += 2;
}
/* Get any leftovers */
switch (width & 3) {
case 3:
RGB888_RGB555(dst, src);
++src;
++dst;
case 2:
RGB888_RGB555_TWO(dst, src);
src += 2;
dst += 2;
break;
case 1:
RGB888_RGB555(dst, src);
++src;
++dst;
break;
}
src += srcskip;
dst += dstskip;
}
} else {
while (height--) {
/* Copy in 4 pixel chunks */
for (c = width / 4; c; --c) {
RGB888_RGB555_TWO(dst, src);
src += 2;
dst += 2;
RGB888_RGB555_TWO(dst, src);
src += 2;
dst += 2;
}
/* Get any leftovers */
switch (width & 3) {
case 3:
RGB888_RGB555(dst, src);
++src;
++dst;
case 2:
RGB888_RGB555_TWO(dst, src);
src += 2;
dst += 2;
break;
case 1:
RGB888_RGB555(dst, src);
++src;
++dst;
break;
}
src += srcskip;
dst += dstskip;
}
}
#endif /* USE_DUFFS_LOOP */
}
static void Blit_RGB888_RGB565 ( SDL_BlitInfo info)
static

Definition at line 1253 of file SDL_blit_N.c.

References SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, RGB888_RGB565, SDL_BlitInfo::src, and SDL_BlitInfo::src_skip.

{
#ifndef USE_DUFFS_LOOP
int c;
#endif
int width, height;
int srcskip, dstskip;
/* Set up some basic variables */
width = info->dst_w;
height = info->dst_h;
src = (Uint32 *) info->src;
srcskip = info->src_skip / 4;
dst = (Uint16 *) info->dst;
dstskip = info->dst_skip / 2;
#ifdef USE_DUFFS_LOOP
while (height--) {
/* *INDENT-OFF* */
RGB888_RGB565(dst, src);
++src;
++dst;
, width);
/* *INDENT-ON* */
src += srcskip;
dst += dstskip;
}
#else
/* Memory align at 4-byte boundary, if necessary */
if ((long) dst & 0x03) {
/* Don't do anything if width is 0 */
if (width == 0) {
return;
}
--width;
while (height--) {
/* Perform copy alignment */
RGB888_RGB565(dst, src);
++src;
++dst;
/* Copy in 4 pixel chunks */
for (c = width / 4; c; --c) {
RGB888_RGB565_TWO(dst, src);
src += 2;
dst += 2;
RGB888_RGB565_TWO(dst, src);
src += 2;
dst += 2;
}
/* Get any leftovers */
switch (width & 3) {
case 3:
RGB888_RGB565(dst, src);
++src;
++dst;
case 2:
RGB888_RGB565_TWO(dst, src);
src += 2;
dst += 2;
break;
case 1:
RGB888_RGB565(dst, src);
++src;
++dst;
break;
}
src += srcskip;
dst += dstskip;
}
} else {
while (height--) {
/* Copy in 4 pixel chunks */
for (c = width / 4; c; --c) {
RGB888_RGB565_TWO(dst, src);
src += 2;
dst += 2;
RGB888_RGB565_TWO(dst, src);
src += 2;
dst += 2;
}
/* Get any leftovers */
switch (width & 3) {
case 3:
RGB888_RGB565(dst, src);
++src;
++dst;
case 2:
RGB888_RGB565_TWO(dst, src);
src += 2;
dst += 2;
break;
case 1:
RGB888_RGB565(dst, src);
++src;
++dst;
break;
}
src += srcskip;
dst += dstskip;
}
}
#endif /* USE_DUFFS_LOOP */
}
static void BlitNto1 ( SDL_BlitInfo info)
static

Definition at line 1982 of file SDL_blit_N.c.

References SDL_PixelFormat::BytesPerPixel, DISEMBLE_RGB, SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, map, NULL, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, SDL_BlitInfo::src_skip, and SDL_BlitInfo::table.

Referenced by SDL_CalculateBlitN().

{
#ifndef USE_DUFFS_LOOP
int c;
#endif
int width, height;
const Uint8 *map;
int srcskip, dstskip;
int srcbpp;
Uint32 Pixel;
int sR, sG, sB;
SDL_PixelFormat *srcfmt;
/* Set up some basic variables */
width = info->dst_w;
height = info->dst_h;
src = info->src;
srcskip = info->src_skip;
dst = info->dst;
dstskip = info->dst_skip;
map = info->table;
srcfmt = info->src_fmt;
srcbpp = srcfmt->BytesPerPixel;
if (map == NULL) {
while (height--) {
#ifdef USE_DUFFS_LOOP
/* *INDENT-OFF* */
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
sR, sG, sB);
if ( 1 ) {
/* Pack RGB into 8bit pixel */
*dst = ((sR>>5)<<(3+2))|
((sG>>5)<<(2)) |
((sB>>6)<<(0)) ;
}
dst++;
src += srcbpp;
, width);
/* *INDENT-ON* */
#else
for (c = width; c; --c) {
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
if (1) {
/* Pack RGB into 8bit pixel */
*dst = ((sR >> 5) << (3 + 2)) |
((sG >> 5) << (2)) | ((sB >> 6) << (0));
}
dst++;
src += srcbpp;
}
#endif
src += srcskip;
dst += dstskip;
}
} else {
while (height--) {
#ifdef USE_DUFFS_LOOP
/* *INDENT-OFF* */
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
sR, sG, sB);
if ( 1 ) {
/* Pack RGB into 8bit pixel */
*dst = map[((sR>>5)<<(3+2))|
((sG>>5)<<(2)) |
((sB>>6)<<(0)) ];
}
dst++;
src += srcbpp;
, width);
/* *INDENT-ON* */
#else
for (c = width; c; --c) {
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
if (1) {
/* Pack RGB into 8bit pixel */
*dst = map[((sR >> 5) << (3 + 2)) |
((sG >> 5) << (2)) | ((sB >> 6) << (0))];
}
dst++;
src += srcbpp;
}
#endif /* USE_DUFFS_LOOP */
src += srcskip;
dst += dstskip;
}
}
}
static void BlitNto1Key ( SDL_BlitInfo info)
static

Definition at line 2217 of file SDL_blit_N.c.

References SDL_PixelFormat::Amask, SDL_PixelFormat::BytesPerPixel, SDL_BlitInfo::colorkey, DISEMBLE_RGB, SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, NULL, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, SDL_BlitInfo::src_skip, and SDL_BlitInfo::table.

Referenced by SDL_CalculateBlitN().

{
int width = info->dst_w;
int height = info->dst_h;
Uint8 *src = info->src;
int srcskip = info->src_skip;
Uint8 *dst = info->dst;
int dstskip = info->dst_skip;
SDL_PixelFormat *srcfmt = info->src_fmt;
const Uint8 *palmap = info->table;
Uint32 ckey = info->colorkey;
Uint32 rgbmask = ~srcfmt->Amask;
int srcbpp;
Uint32 Pixel;
unsigned sR, sG, sB;
/* Set up some basic variables */
srcbpp = srcfmt->BytesPerPixel;
ckey &= rgbmask;
if (palmap == NULL) {
while (height--) {
/* *INDENT-OFF* */
{
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
sR, sG, sB);
if ( (Pixel & rgbmask) != ckey ) {
/* Pack RGB into 8bit pixel */
*dst = (Uint8)(((sR>>5)<<(3+2))|
((sG>>5)<<(2)) |
((sB>>6)<<(0)));
}
dst++;
src += srcbpp;
},
/* *INDENT-ON* */
src += srcskip;
dst += dstskip;
}
} else {
while (height--) {
/* *INDENT-OFF* */
{
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
sR, sG, sB);
if ( (Pixel & rgbmask) != ckey ) {
/* Pack RGB into 8bit pixel */
*dst = (Uint8)palmap[((sR>>5)<<(3+2))|
((sG>>5)<<(2)) |
((sB>>6)<<(0)) ];
}
dst++;
src += srcbpp;
},
/* *INDENT-ON* */
src += srcskip;
dst += dstskip;
}
}
}
static void BlitNto2101010 ( SDL_BlitInfo info)
static

Definition at line 2488 of file SDL_blit_N.c.

References ARGB2101010_FROM_RGBA, SDL_PixelFormat::BytesPerPixel, DISEMBLE_RGBA, SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitN().

{
int width = info->dst_w;
int height = info->dst_h;
Uint8 *src = info->src;
int srcskip = info->src_skip;
Uint8 *dst = info->dst;
int dstskip = info->dst_skip;
SDL_PixelFormat *srcfmt = info->src_fmt;
int srcbpp = srcfmt->BytesPerPixel;
Uint32 Pixel;
unsigned sR, sG, sB, sA;
while (height--) {
/* *INDENT-OFF* */
{
DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
ARGB2101010_FROM_RGBA(Pixel, sR, sG, sB, sA);
*(Uint32 *)dst = Pixel;
dst += 4;
src += srcbpp;
},
/* *INDENT-ON* */
src += srcskip;
dst += dstskip;
}
}
static void BlitNtoN ( SDL_BlitInfo info)
static

Definition at line 2153 of file SDL_blit_N.c.

References SDL_BlitInfo::a, SDL_PixelFormat::Amask, ASSEMBLE_RGBA, SDL_PixelFormat::BytesPerPixel, DISEMBLE_RGB, SDL_BlitInfo::dst, SDL_BlitInfo::dst_fmt, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitN().

{
int width = info->dst_w;
int height = info->dst_h;
Uint8 *src = info->src;
int srcskip = info->src_skip;
Uint8 *dst = info->dst;
int dstskip = info->dst_skip;
SDL_PixelFormat *srcfmt = info->src_fmt;
int srcbpp = srcfmt->BytesPerPixel;
SDL_PixelFormat *dstfmt = info->dst_fmt;
int dstbpp = dstfmt->BytesPerPixel;
unsigned alpha = dstfmt->Amask ? info->a : 0;
while (height--) {
/* *INDENT-OFF* */
{
Uint32 Pixel;
unsigned sR;
unsigned sG;
unsigned sB;
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha);
dst += dstbpp;
src += srcbpp;
},
/* *INDENT-ON* */
src += srcskip;
dst += dstskip;
}
}
static void BlitNtoNCopyAlpha ( SDL_BlitInfo info)
static

Definition at line 2188 of file SDL_blit_N.c.

References ASSEMBLE_RGBA, SDL_PixelFormat::BytesPerPixel, DISEMBLE_RGBA, SDL_BlitInfo::dst, SDL_BlitInfo::dst_fmt, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitN().

{
int width = info->dst_w;
int height = info->dst_h;
Uint8 *src = info->src;
int srcskip = info->src_skip;
Uint8 *dst = info->dst;
int dstskip = info->dst_skip;
SDL_PixelFormat *srcfmt = info->src_fmt;
int srcbpp = srcfmt->BytesPerPixel;
SDL_PixelFormat *dstfmt = info->dst_fmt;
int dstbpp = dstfmt->BytesPerPixel;
int c;
while (height--) {
for (c = width; c; --c) {
Uint32 Pixel;
unsigned sR, sG, sB, sA;
DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, sA);
dst += dstbpp;
src += srcbpp;
}
src += srcskip;
dst += dstskip;
}
}
static void BlitNtoNKey ( SDL_BlitInfo info)
static

Definition at line 2317 of file SDL_blit_N.c.

References SDL_BlitInfo::a, SDL_PixelFormat::Amask, ASSEMBLE_RGBA, SDL_PixelFormat::BytesPerPixel, SDL_BlitInfo::colorkey, SDL_BlitInfo::dst, SDL_BlitInfo::dst_fmt, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, SDL_PixelFormat::format, RETRIEVE_RGB_PIXEL, RGB_FROM_PIXEL, SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitN().

{
int width = info->dst_w;
int height = info->dst_h;
Uint8 *src = info->src;
int srcskip = info->src_skip;
Uint8 *dst = info->dst;
int dstskip = info->dst_skip;
Uint32 ckey = info->colorkey;
SDL_PixelFormat *srcfmt = info->src_fmt;
SDL_PixelFormat *dstfmt = info->dst_fmt;
int srcbpp = srcfmt->BytesPerPixel;
int dstbpp = dstfmt->BytesPerPixel;
unsigned alpha = dstfmt->Amask ? info->a : 0;
Uint32 rgbmask = ~srcfmt->Amask;
/* Set up some basic variables */
ckey &= rgbmask;
/* Fastpath: same source/destination format, no Amask, bpp 32, loop is vectorized. ~10x faster */
if (srcfmt->format == dstfmt->format &&
Uint32 *src32 = (Uint32*)src;
Uint32 *dst32 = (Uint32*)dst;
srcskip /= sizeof(Uint32);
dstskip /= sizeof(Uint32);
while (height--) {
/* *INDENT-OFF* */
{
if (*src32 != ckey) {
*dst32 = *src32;
}
++src32;
++dst32;
},
/* *INDENT-ON* */
src32 += srcskip;
dst32 += dstskip;
}
return;
}
while (height--) {
/* *INDENT-OFF* */
{
Uint32 Pixel;
unsigned sR;
unsigned sG;
unsigned sB;
RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
if ( (Pixel & rgbmask) != ckey ) {
RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha);
}
dst += dstbpp;
src += srcbpp;
},
/* *INDENT-ON* */
src += srcskip;
dst += dstskip;
}
}
static void BlitNtoNKeyCopyAlpha ( SDL_BlitInfo info)
static

Definition at line 2385 of file SDL_blit_N.c.

References SDL_PixelFormat::Amask, ASSEMBLE_RGBA, SDL_PixelFormat::BytesPerPixel, SDL_BlitInfo::colorkey, DISEMBLE_RGBA, SDL_BlitInfo::dst, SDL_BlitInfo::dst_fmt, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, SDL_PixelFormat::format, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGBA8888, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitN().

{
int width = info->dst_w;
int height = info->dst_h;
Uint8 *src = info->src;
int srcskip = info->src_skip;
Uint8 *dst = info->dst;
int dstskip = info->dst_skip;
Uint32 ckey = info->colorkey;
SDL_PixelFormat *srcfmt = info->src_fmt;
SDL_PixelFormat *dstfmt = info->dst_fmt;
Uint32 rgbmask = ~srcfmt->Amask;
Uint8 srcbpp;
Uint32 Pixel;
unsigned sR, sG, sB, sA;
/* Set up some basic variables */
srcbpp = srcfmt->BytesPerPixel;
dstbpp = dstfmt->BytesPerPixel;
ckey &= rgbmask;
/* Fastpath: same source/destination format, with Amask, bpp 32, loop is vectorized. ~10x faster */
if (srcfmt->format == dstfmt->format &&
Uint32 *src32 = (Uint32*)src;
Uint32 *dst32 = (Uint32*)dst;
srcskip /= sizeof(Uint32);
dstskip /= sizeof(Uint32);
while (height--) {
/* *INDENT-OFF* */
{
if ((*src32 & rgbmask) != ckey) {
*dst32 = *src32;
}
++src32;
++dst32;
},
/* *INDENT-ON* */
src32 += srcskip;
dst32 += dstskip;
}
return;
}
while (height--) {
/* *INDENT-OFF* */
{
DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
if ( (Pixel & rgbmask) != ckey ) {
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, sA);
}
dst += dstbpp;
src += srcbpp;
},
/* *INDENT-ON* */
src += srcskip;
dst += dstskip;
}
}
SDL_BlitFunc SDL_CalculateBlitN ( SDL_Surface surface)

Definition at line 2590 of file SDL_blit_N.c.

References blit_table::alpha, SDL_PixelFormat::Amask, SDL_PixelFormat::BitsPerPixel, Blit2101010toN(), Blit2to2Key(), Blit4to4CopyAlpha(), Blit4to4MaskAlpha(), blit_table::blit_features, Blit_RGB101010_index8(), Blit_RGB888_index8(), blit_table::blitfunc, BlitNto1(), BlitNto1Key(), BlitNto2101010(), BlitNtoN(), BlitNtoNCopyAlpha(), BlitNtoNKey(), BlitNtoNKeyCopyAlpha(), SDL_PixelFormat::Bmask, SDL_PixelFormat::BytesPerPixel, COPY_ALPHA, SDL_BlitMap::dst, blit_table::dstB, blit_table::dstbpp, blit_table::dstG, blit_table::dstR, SDL_BlitInfo::flags, SDL_Surface::format, SDL_PixelFormat::format, GetBlitFeatures, SDL_PixelFormat::Gmask, SDL_BlitMap::identity, SDL_BlitMap::info, SDL_Surface::map, MASKOK, NO_ALPHA, NULL, SDL_PixelFormat::Rmask, SDL_COPY_COLORKEY, SDL_COPY_RLE_MASK, SDL_HasAltiVec, SDL_PIXELFORMAT_ARGB2101010, SET_ALPHA, blit_table::srcB, blit_table::srcG, and blit_table::srcR.

Referenced by SDL_CalculateBlit().

{
SDL_PixelFormat *srcfmt;
SDL_PixelFormat *dstfmt;
const struct blit_table *table;
int which;
SDL_BlitFunc blitfun;
/* Set up data for choosing the blit */
srcfmt = surface->format;
dstfmt = surface->map->dst->format;
/* We don't support destinations less than 8-bits */
if (dstfmt->BitsPerPixel < 8) {
return (NULL);
}
switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
case 0:
blitfun = NULL;
if (dstfmt->BitsPerPixel == 8) {
if ((srcfmt->BytesPerPixel == 4) &&
(srcfmt->Rmask == 0x00FF0000) &&
(srcfmt->Gmask == 0x0000FF00) &&
(srcfmt->Bmask == 0x000000FF)) {
blitfun = Blit_RGB888_index8;
} else if ((srcfmt->BytesPerPixel == 4) &&
(srcfmt->Rmask == 0x3FF00000) &&
(srcfmt->Gmask == 0x000FFC00) &&
(srcfmt->Bmask == 0x000003FF)) {
} else {
blitfun = BlitNto1;
}
} else {
/* Now the meat, choose the blitter we want */
int a_need = NO_ALPHA;
if (dstfmt->Amask)
a_need = srcfmt->Amask ? COPY_ALPHA : SET_ALPHA;
table = normal_blit[srcfmt->BytesPerPixel - 1];
for (which = 0; table[which].dstbpp; ++which) {
if (MASKOK(srcfmt->Rmask, table[which].srcR) &&
MASKOK(srcfmt->Gmask, table[which].srcG) &&
MASKOK(srcfmt->Bmask, table[which].srcB) &&
MASKOK(dstfmt->Rmask, table[which].dstR) &&
MASKOK(dstfmt->Gmask, table[which].dstG) &&
MASKOK(dstfmt->Bmask, table[which].dstB) &&
dstfmt->BytesPerPixel == table[which].dstbpp &&
(a_need & table[which].alpha) == a_need &&
((table[which].blit_features & GetBlitFeatures()) ==
table[which].blit_features))
break;
}
blitfun = table[which].blitfunc;
if (blitfun == BlitNtoN) { /* default C fallback catch-all. Slow! */
blitfun = Blit2101010toN;
} else if (dstfmt->format == SDL_PIXELFORMAT_ARGB2101010) {
blitfun = BlitNto2101010;
} else if (srcfmt->BytesPerPixel == 4 &&
dstfmt->BytesPerPixel == 4 &&
srcfmt->Rmask == dstfmt->Rmask &&
srcfmt->Gmask == dstfmt->Gmask &&
srcfmt->Bmask == dstfmt->Bmask) {
if (a_need == COPY_ALPHA) {
if (srcfmt->Amask == dstfmt->Amask) {
/* Fastpath C fallback: 32bit RGBA<->RGBA blit with matching RGBA */
blitfun = Blit4to4CopyAlpha;
} else {
blitfun = BlitNtoNCopyAlpha;
}
} else {
/* Fastpath C fallback: 32bit RGB<->RGBA blit with matching RGB */
blitfun = Blit4to4MaskAlpha;
}
} else if (a_need == COPY_ALPHA) {
blitfun = BlitNtoNCopyAlpha;
}
}
}
return (blitfun);
/* colorkey blit: Here we don't have too many options, mostly
because RLE is the preferred fast way to deal with this.
If a particular case turns out to be useful we'll add it. */
if (srcfmt->BytesPerPixel == 2 && surface->map->identity)
return Blit2to2Key;
else if (dstfmt->BytesPerPixel == 1)
return BlitNto1Key;
else {
#if SDL_ALTIVEC_BLITTERS
if ((srcfmt->BytesPerPixel == 4) && (dstfmt->BytesPerPixel == 4)
return Blit32to32KeyAltivec;
} else
#endif
if (srcfmt->Amask && dstfmt->Amask) {
} else {
return BlitNtoNKey;
}
}
}
return NULL;
}

Variable Documentation

struct blit_table* const normal_blit[]
static
Initial value:

Definition at line 2582 of file SDL_blit_N.c.

struct blit_table normal_blit_1[]
static
Initial value:
{
{0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0}
}

Definition at line 2531 of file SDL_blit_N.c.

struct blit_table normal_blit_2[]
static
Initial value:
{
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00FF0000, 0x0000FF00, 0x000000FF,
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0x000000FF, 0x0000FF00, 0x00FF0000,
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0xFF000000, 0x00FF0000, 0x0000FF00,
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0x0000FF00, 0x00FF0000, 0xFF000000,
{0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0}
}

Definition at line 2536 of file SDL_blit_N.c.

struct blit_table normal_blit_3[]
static
Initial value:
{
{0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0}
}

Definition at line 2557 of file SDL_blit_N.c.

struct blit_table normal_blit_4[]
static
Initial value:
{
{0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x0000F800, 0x000007E0, 0x0000001F,
{0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x00007C00, 0x000003E0, 0x0000001F,
{0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0}
}

Definition at line 2562 of file SDL_blit_N.c.

const Uint32 RGB565_ABGR8888_LUT[512]
static

Definition at line 1568 of file SDL_blit_N.c.

const Uint32 RGB565_ARGB8888_LUT[512]
static

Definition at line 1430 of file SDL_blit_N.c.

const Uint32 RGB565_BGRA8888_LUT[512]
static

Definition at line 1844 of file SDL_blit_N.c.

const Uint32 RGB565_RGBA8888_LUT[512]
static

Definition at line 1706 of file SDL_blit_N.c.