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()   ((SDL_HasMMX() ? BLIT_FEATURE_HAS_MMX : 0) | (SDL_HasARMSIMD() ? BLIT_FEATURE_HAS_ARM_SIMD : 0))
 
#define HI   1
 
#define LO   0
 
#define RGB888_RGB332(dst, src)
 
#define RGB101010_RGB332(dst, src)
 
#define RGB888_RGB555(dst, src)
 
#define RGB888_RGB555_TWO(dst, src)
 
#define RGB888_RGB565(dst, src)
 
#define RGB888_RGB565_TWO(dst, src)
 
#define RGB565_32(dst, src, map)   (map[src[LO]*2] + map[src[HI]*2+1])
 
#define MASKOK(x, y)   (((x) == (y)) || ((y) == 0x00000000))
 

Enumerations

enum  blit_features {
  BLIT_FEATURE_HAS_MMX = 1,
  BLIT_FEATURE_HAS_ALTIVEC = 2,
  BLIT_FEATURE_ALTIVEC_DONT_USE_PREFETCH = 4,
  BLIT_FEATURE_HAS_ARM_SIMD = 8
}
 

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 const struct blit_table normal_blit_1 []
 
static const struct blit_table normal_blit_2 []
 
static const struct blit_table normal_blit_3 []
 
static const struct blit_table normal_blit_4 []
 
static const struct blit_table *const normal_blit []
 

Macro Definition Documentation

◆ GetBlitFeatures

#define GetBlitFeatures ( )    ((SDL_HasMMX() ? BLIT_FEATURE_HAS_MMX : 0) | (SDL_HasARMSIMD() ? BLIT_FEATURE_HAS_ARM_SIMD : 0))

Definition at line 882 of file SDL_blit_N.c.

Referenced by SDL_CalculateBlitN().

◆ HI

#define HI   1

Definition at line 919 of file SDL_blit_N.c.

◆ LO

#define LO   0

Definition at line 920 of file SDL_blit_N.c.

◆ MASKOK

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

Definition at line 2572 of file SDL_blit_N.c.

Referenced by SDL_CalculateBlitN().

◆ RGB101010_RGB332

#define RGB101010_RGB332 (   dst,
  src 
)
Value:
{ \
dst = (Uint8)((((src)&0x38000000)>>22)| \
(((src)&0x000E0000)>>15)| \
(((src)&0x00000300)>>8)); \
}
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
GLenum src

Definition at line 1037 of file SDL_blit_N.c.

Referenced by Blit_RGB101010_index8().

◆ RGB565_32

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

Definition at line 1396 of file SDL_blit_N.c.

Referenced by Blit_RGB565_32().

◆ RGB888_RGB332

#define RGB888_RGB332 (   dst,
  src 
)
Value:
{ \
dst = (Uint8)((((src)&0x00E00000)>>16)| \
(((src)&0x0000E000)>>11)| \
(((src)&0x000000C0)>>6)); \
}
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
GLenum src

Definition at line 927 of file SDL_blit_N.c.

Referenced by Blit_RGB888_index8().

◆ RGB888_RGB555

#define RGB888_RGB555 (   dst,
  src 
)
Value:
{ \
*(Uint16 *)(dst) = (Uint16)((((*src)&0x00F80000)>>9)| \
(((*src)&0x0000F800)>>6)| \
(((*src)&0x000000F8)>>3)); \
}
GLenum GLenum dst
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:151
GLenum src

Definition at line 1147 of file SDL_blit_N.c.

Referenced by Blit_RGB888_RGB555().

◆ RGB888_RGB555_TWO

#define RGB888_RGB555_TWO (   dst,
  src 
)
Value:
{ \
*(Uint32 *)(dst) = (((((src[HI])&0x00F80000)>>9)| \
(((src[HI])&0x0000F800)>>6)| \
(((src[HI])&0x000000F8)>>3))<<16)| \
(((src[LO])&0x00F80000)>>9)| \
(((src[LO])&0x0000F800)>>6)| \
(((src[LO])&0x000000F8)>>3); \
}
GLenum GLenum dst
#define HI
Definition: SDL_blit_N.c:919
#define LO
Definition: SDL_blit_N.c:920
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLenum src

Definition at line 1152 of file SDL_blit_N.c.

Referenced by Blit_RGB888_RGB555().

◆ RGB888_RGB565

#define RGB888_RGB565 (   dst,
  src 
)
Value:
{ \
*(Uint16 *)(dst) = (Uint16)((((*src)&0x00F80000)>>8)| \
(((*src)&0x0000FC00)>>5)| \
(((*src)&0x000000F8)>>3)); \
}
GLenum GLenum dst
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:151
GLenum src

Definition at line 1271 of file SDL_blit_N.c.

Referenced by Blit_RGB888_RGB565().

◆ RGB888_RGB565_TWO

#define RGB888_RGB565_TWO (   dst,
  src 
)
Value:
{ \
*(Uint32 *)(dst) = (((((src[HI])&0x00F80000)>>8)| \
(((src[HI])&0x0000FC00)>>5)| \
(((src[HI])&0x000000F8)>>3))<<16)| \
(((src[LO])&0x00F80000)>>8)| \
(((src[LO])&0x0000FC00)>>5)| \
(((src[LO])&0x000000F8)>>3); \
}
GLenum GLenum dst
#define HI
Definition: SDL_blit_N.c:919
#define LO
Definition: SDL_blit_N.c:920
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLenum src

Definition at line 1276 of file SDL_blit_N.c.

Referenced by Blit_RGB888_RGB565().

Enumeration Type Documentation

◆ blit_features

Enumerator
BLIT_FEATURE_HAS_MMX 
BLIT_FEATURE_HAS_ALTIVEC 
BLIT_FEATURE_ALTIVEC_DONT_USE_PREFETCH 
BLIT_FEATURE_HAS_ARM_SIMD 

Definition at line 32 of file SDL_blit_N.c.

Function Documentation

◆ Blit2101010toN()

static void Blit2101010toN ( SDL_BlitInfo info)
static

Definition at line 2435 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().

2436 {
2437  int width = info->dst_w;
2438  int height = info->dst_h;
2439  Uint8 *src = info->src;
2440  int srcskip = info->src_skip;
2441  Uint8 *dst = info->dst;
2442  int dstskip = info->dst_skip;
2443  SDL_PixelFormat *dstfmt = info->dst_fmt;
2444  int dstbpp = dstfmt->BytesPerPixel;
2445  Uint32 Pixel;
2446  unsigned sR, sG, sB, sA;
2447 
2448  while (height--) {
2449  /* *INDENT-OFF* */
2450  DUFFS_LOOP(
2451  {
2452  Pixel = *(Uint32 *)src;
2453  RGBA_FROM_ARGB2101010(Pixel, sR, sG, sB, sA);
2454  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, sA);
2455  dst += dstbpp;
2456  src += 4;
2457  },
2458  width);
2459  /* *INDENT-ON* */
2460  src += srcskip;
2461  dst += dstskip;
2462  }
2463 }
GLenum GLenum dst
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
int src_skip
Definition: SDL_blit.h:60
Uint8 BytesPerPixel
Definition: SDL_pixels.h:318
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a)
Definition: SDL_blit.h:401
#define RGBA_FROM_ARGB2101010(Pixel, r, g, b, a)
Definition: SDL_blit.h:345
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
Uint8 * dst
Definition: SDL_blit.h:61
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:499
Uint8 * src
Definition: SDL_blit.h:57
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
GLenum src

◆ Blit2to2Key()

static void Blit2to2Key ( SDL_BlitInfo info)
static

Definition at line 2315 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().

2316 {
2317  int width = info->dst_w;
2318  int height = info->dst_h;
2319  Uint16 *srcp = (Uint16 *) info->src;
2320  int srcskip = info->src_skip;
2321  Uint16 *dstp = (Uint16 *) info->dst;
2322  int dstskip = info->dst_skip;
2323  Uint32 ckey = info->colorkey;
2324  Uint32 rgbmask = ~info->src_fmt->Amask;
2325 
2326  /* Set up some basic variables */
2327  srcskip /= 2;
2328  dstskip /= 2;
2329  ckey &= rgbmask;
2330 
2331  while (height--) {
2332  /* *INDENT-OFF* */
2333  DUFFS_LOOP(
2334  {
2335  if ( (*srcp & rgbmask) != ckey ) {
2336  *dstp = *srcp;
2337  }
2338  dstp++;
2339  srcp++;
2340  },
2341  width);
2342  /* *INDENT-ON* */
2343  srcp += srcskip;
2344  dstp += dstskip;
2345  }
2346 }
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
int src_skip
Definition: SDL_blit.h:60
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
Uint32 colorkey
Definition: SDL_blit.h:69
Uint8 * dst
Definition: SDL_blit.h:61
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:499
Uint8 * src
Definition: SDL_blit.h:57
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:151

◆ Blit4to4CopyAlpha()

static void Blit4to4CopyAlpha ( SDL_BlitInfo info)
static

Definition at line 2159 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().

2160 {
2161  int width = info->dst_w;
2162  int height = info->dst_h;
2163  Uint32 *src = (Uint32 *) info->src;
2164  int srcskip = info->src_skip;
2165  Uint32 *dst = (Uint32 *) info->dst;
2166  int dstskip = info->dst_skip;
2167 
2168  /* RGBA->RGBA, COPY_ALPHA */
2169  while (height--) {
2170  /* *INDENT-OFF* */
2171  DUFFS_LOOP(
2172  {
2173  *dst = *src;
2174  ++dst;
2175  ++src;
2176  },
2177  width);
2178  /* *INDENT-ON* */
2179  src = (Uint32 *) ((Uint8 *) src + srcskip);
2180  dst = (Uint32 *) ((Uint8 *) dst + dstskip);
2181  }
2182 }
GLenum GLenum dst
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
int src_skip
Definition: SDL_blit.h:60
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
Uint8 * dst
Definition: SDL_blit.h:61
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:499
Uint8 * src
Definition: SDL_blit.h:57
GLenum src

◆ Blit4to4MaskAlpha()

static void Blit4to4MaskAlpha ( SDL_BlitInfo info)
static

Definition at line 2109 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().

2110 {
2111  int width = info->dst_w;
2112  int height = info->dst_h;
2113  Uint32 *src = (Uint32 *) info->src;
2114  int srcskip = info->src_skip;
2115  Uint32 *dst = (Uint32 *) info->dst;
2116  int dstskip = info->dst_skip;
2117  SDL_PixelFormat *srcfmt = info->src_fmt;
2118  SDL_PixelFormat *dstfmt = info->dst_fmt;
2119 
2120  if (dstfmt->Amask) {
2121  /* RGB->RGBA, SET_ALPHA */
2122  Uint32 mask = (info->a >> dstfmt->Aloss) << dstfmt->Ashift;
2123 
2124  while (height--) {
2125  /* *INDENT-OFF* */
2126  DUFFS_LOOP(
2127  {
2128  *dst = *src | mask;
2129  ++dst;
2130  ++src;
2131  },
2132  width);
2133  /* *INDENT-ON* */
2134  src = (Uint32 *) ((Uint8 *) src + srcskip);
2135  dst = (Uint32 *) ((Uint8 *) dst + dstskip);
2136  }
2137  } else {
2138  /* RGBA->RGB, NO_ALPHA */
2139  Uint32 mask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
2140 
2141  while (height--) {
2142  /* *INDENT-OFF* */
2143  DUFFS_LOOP(
2144  {
2145  *dst = *src & mask;
2146  ++dst;
2147  ++src;
2148  },
2149  width);
2150  /* *INDENT-ON* */
2151  src = (Uint32 *) ((Uint8 *) src + srcskip);
2152  dst = (Uint32 *) ((Uint8 *) dst + dstskip);
2153  }
2154  }
2155 }
GLenum GLenum dst
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
int src_skip
Definition: SDL_blit.h:60
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
Uint8 * dst
Definition: SDL_blit.h:61
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:499
Uint8 * src
Definition: SDL_blit.h:57
GLenum GLint GLuint mask
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
GLenum src
Uint8 a
Definition: SDL_blit.h:70

◆ Blit_RGB101010_index8()

static void Blit_RGB101010_index8 ( SDL_BlitInfo info)
static

Definition at line 1043 of file SDL_blit_N.c.

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

Referenced by SDL_CalculateBlitN().

1044 {
1045 #ifndef USE_DUFFS_LOOP
1046  int c;
1047 #endif
1048  int width, height;
1049  Uint32 *src;
1050  const Uint8 *map;
1051  Uint8 *dst;
1052  int srcskip, dstskip;
1053 
1054  /* Set up some basic variables */
1055  width = info->dst_w;
1056  height = info->dst_h;
1057  src = (Uint32 *) info->src;
1058  srcskip = info->src_skip / 4;
1059  dst = info->dst;
1060  dstskip = info->dst_skip;
1061  map = info->table;
1062 
1063  if (map == NULL) {
1064  while (height--) {
1065 #ifdef USE_DUFFS_LOOP
1066  /* *INDENT-OFF* */
1067  DUFFS_LOOP(
1068  RGB101010_RGB332(*dst++, *src);
1069  , width);
1070  /* *INDENT-ON* */
1071 #else
1072  for (c = width / 4; c; --c) {
1073  /* Pack RGB into 8bit pixel */
1074  ++src;
1075  RGB101010_RGB332(*dst++, *src);
1076  ++src;
1077  RGB101010_RGB332(*dst++, *src);
1078  ++src;
1079  RGB101010_RGB332(*dst++, *src);
1080  ++src;
1081  }
1082  switch (width & 3) {
1083  case 3:
1084  RGB101010_RGB332(*dst++, *src);
1085  ++src;
1086  case 2:
1087  RGB101010_RGB332(*dst++, *src);
1088  ++src;
1089  case 1:
1090  RGB101010_RGB332(*dst++, *src);
1091  ++src;
1092  }
1093 #endif /* USE_DUFFS_LOOP */
1094  src += srcskip;
1095  dst += dstskip;
1096  }
1097  } else {
1098  int Pixel;
1099 
1100  while (height--) {
1101 #ifdef USE_DUFFS_LOOP
1102  /* *INDENT-OFF* */
1103  DUFFS_LOOP(
1104  RGB101010_RGB332(Pixel, *src);
1105  *dst++ = map[Pixel];
1106  ++src;
1107  , width);
1108  /* *INDENT-ON* */
1109 #else
1110  for (c = width / 4; c; --c) {
1111  /* Pack RGB into 8bit pixel */
1112  RGB101010_RGB332(Pixel, *src);
1113  *dst++ = map[Pixel];
1114  ++src;
1115  RGB101010_RGB332(Pixel, *src);
1116  *dst++ = map[Pixel];
1117  ++src;
1118  RGB101010_RGB332(Pixel, *src);
1119  *dst++ = map[Pixel];
1120  ++src;
1121  RGB101010_RGB332(Pixel, *src);
1122  *dst++ = map[Pixel];
1123  ++src;
1124  }
1125  switch (width & 3) {
1126  case 3:
1127  RGB101010_RGB332(Pixel, *src);
1128  *dst++ = map[Pixel];
1129  ++src;
1130  case 2:
1131  RGB101010_RGB332(Pixel, *src);
1132  *dst++ = map[Pixel];
1133  ++src;
1134  case 1:
1135  RGB101010_RGB332(Pixel, *src);
1136  *dst++ = map[Pixel];
1137  ++src;
1138  }
1139 #endif /* USE_DUFFS_LOOP */
1140  src += srcskip;
1141  dst += dstskip;
1142  }
1143  }
1144 }
Uint8 * table
Definition: SDL_blit.h:67
GLenum GLenum dst
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
int src_skip
Definition: SDL_blit.h:60
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld [DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp local skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
Uint8 * dst
Definition: SDL_blit.h:61
#define RGB101010_RGB332(dst, src)
Definition: SDL_blit_N.c:1037
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:499
const GLubyte * c
Uint8 * src
Definition: SDL_blit.h:57
#define NULL
Definition: begin_code.h:143
const GLubyte GLuint GLuint GLuint GLuint alpha GLboolean GLboolean GLboolean GLboolean alpha GLint GLint GLsizei GLsizei GLenum type GLenum GLint GLenum GLint GLint GLsizei GLsizei GLint border GLenum GLint GLint GLint GLint GLint GLsizei GLsizei height GLsizei GLsizei GLenum GLenum const GLvoid *pixels GLenum GLint GLint GLint GLint j2 GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLfloat *params GLenum GLint GLenum GLenum GLvoid *pixels GLenum GLint GLenum GLint *params GLenum GLenum GLint *params GLenum GLsizei const GLvoid *pointer GLenum GLenum const GLint *params GLenum GLfloat GLfloat GLint GLint const GLfloat *points GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat *points GLint GLfloat GLfloat GLint GLfloat GLfloat v2 GLenum GLenum const GLint *params GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum map
Definition: SDL_glfuncs.h:289
GLenum src

◆ Blit_RGB565_32()

static void Blit_RGB565_32 ( SDL_BlitInfo info,
const Uint32 map 
)
static

Definition at line 1398 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().

1399 {
1400 #ifndef USE_DUFFS_LOOP
1401  int c;
1402 #endif
1403  int width, height;
1404  Uint8 *src;
1405  Uint32 *dst;
1406  int srcskip, dstskip;
1407 
1408  /* Set up some basic variables */
1409  width = info->dst_w;
1410  height = info->dst_h;
1411  src = (Uint8 *) info->src;
1412  srcskip = info->src_skip;
1413  dst = (Uint32 *) info->dst;
1414  dstskip = info->dst_skip / 4;
1415 
1416 #ifdef USE_DUFFS_LOOP
1417  while (height--) {
1418  /* *INDENT-OFF* */
1419  DUFFS_LOOP(
1420  {
1421  *dst++ = RGB565_32(dst, src, map);
1422  src += 2;
1423  },
1424  width);
1425  /* *INDENT-ON* */
1426  src += srcskip;
1427  dst += dstskip;
1428  }
1429 #else
1430  while (height--) {
1431  /* Copy in 4 pixel chunks */
1432  for (c = width / 4; c; --c) {
1433  *dst++ = RGB565_32(dst, src, map);
1434  src += 2;
1435  *dst++ = RGB565_32(dst, src, map);
1436  src += 2;
1437  *dst++ = RGB565_32(dst, src, map);
1438  src += 2;
1439  *dst++ = RGB565_32(dst, src, map);
1440  src += 2;
1441  }
1442  /* Get any leftovers */
1443  switch (width & 3) {
1444  case 3:
1445  *dst++ = RGB565_32(dst, src, map);
1446  src += 2;
1447  case 2:
1448  *dst++ = RGB565_32(dst, src, map);
1449  src += 2;
1450  case 1:
1451  *dst++ = RGB565_32(dst, src, map);
1452  src += 2;
1453  break;
1454  }
1455  src += srcskip;
1456  dst += dstskip;
1457  }
1458 #endif /* USE_DUFFS_LOOP */
1459 }
GLenum GLenum dst
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
int src_skip
Definition: SDL_blit.h:60
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
Uint8 * dst
Definition: SDL_blit.h:61
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:499
const GLubyte * c
Uint8 * src
Definition: SDL_blit.h:57
#define RGB565_32(dst, src, map)
Definition: SDL_blit_N.c:1396
const GLubyte GLuint GLuint GLuint GLuint alpha GLboolean GLboolean GLboolean GLboolean alpha GLint GLint GLsizei GLsizei GLenum type GLenum GLint GLenum GLint GLint GLsizei GLsizei GLint border GLenum GLint GLint GLint GLint GLint GLsizei GLsizei height GLsizei GLsizei GLenum GLenum const GLvoid *pixels GLenum GLint GLint GLint GLint j2 GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLfloat *params GLenum GLint GLenum GLenum GLvoid *pixels GLenum GLint GLenum GLint *params GLenum GLenum GLint *params GLenum GLsizei const GLvoid *pointer GLenum GLenum const GLint *params GLenum GLfloat GLfloat GLint GLint const GLfloat *points GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat *points GLint GLfloat GLfloat GLint GLfloat GLfloat v2 GLenum GLenum const GLint *params GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum map
Definition: SDL_glfuncs.h:289
GLenum src

◆ Blit_RGB565_ABGR8888()

static void Blit_RGB565_ABGR8888 ( SDL_BlitInfo info)
static

Definition at line 1732 of file SDL_blit_N.c.

References Blit_RGB565_32(), and RGB565_ABGR8888_LUT.

1733 {
1735 }
static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map)
Definition: SDL_blit_N.c:1398
static const Uint32 RGB565_ABGR8888_LUT[512]
Definition: SDL_blit_N.c:1600

◆ Blit_RGB565_ARGB8888()

static void Blit_RGB565_ARGB8888 ( SDL_BlitInfo info)
static

Definition at line 1594 of file SDL_blit_N.c.

References Blit_RGB565_32(), and RGB565_ARGB8888_LUT.

1595 {
1597 }
static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map)
Definition: SDL_blit_N.c:1398
static const Uint32 RGB565_ARGB8888_LUT[512]
Definition: SDL_blit_N.c:1462

◆ Blit_RGB565_BGRA8888()

static void Blit_RGB565_BGRA8888 ( SDL_BlitInfo info)
static

Definition at line 2008 of file SDL_blit_N.c.

References Blit_RGB565_32(), and RGB565_BGRA8888_LUT.

2009 {
2011 }
static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map)
Definition: SDL_blit_N.c:1398
static const Uint32 RGB565_BGRA8888_LUT[512]
Definition: SDL_blit_N.c:1876

◆ Blit_RGB565_RGBA8888()

static void Blit_RGB565_RGBA8888 ( SDL_BlitInfo info)
static

Definition at line 1870 of file SDL_blit_N.c.

References Blit_RGB565_32(), and RGB565_RGBA8888_LUT.

1871 {
1873 }
static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map)
Definition: SDL_blit_N.c:1398
static const Uint32 RGB565_RGBA8888_LUT[512]
Definition: SDL_blit_N.c:1738

◆ Blit_RGB888_index8()

static void Blit_RGB888_index8 ( SDL_BlitInfo info)
static

Definition at line 933 of file SDL_blit_N.c.

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

Referenced by SDL_CalculateBlitN().

934 {
935 #ifndef USE_DUFFS_LOOP
936  int c;
937 #endif
938  int width, height;
939  Uint32 *src;
940  const Uint8 *map;
941  Uint8 *dst;
942  int srcskip, dstskip;
943 
944  /* Set up some basic variables */
945  width = info->dst_w;
946  height = info->dst_h;
947  src = (Uint32 *) info->src;
948  srcskip = info->src_skip / 4;
949  dst = info->dst;
950  dstskip = info->dst_skip;
951  map = info->table;
952 
953  if (map == NULL) {
954  while (height--) {
955 #ifdef USE_DUFFS_LOOP
956  /* *INDENT-OFF* */
957  DUFFS_LOOP(
958  RGB888_RGB332(*dst++, *src);
959  , width);
960  /* *INDENT-ON* */
961 #else
962  for (c = width / 4; c; --c) {
963  /* Pack RGB into 8bit pixel */
964  ++src;
965  RGB888_RGB332(*dst++, *src);
966  ++src;
967  RGB888_RGB332(*dst++, *src);
968  ++src;
969  RGB888_RGB332(*dst++, *src);
970  ++src;
971  }
972  switch (width & 3) {
973  case 3:
974  RGB888_RGB332(*dst++, *src);
975  ++src;
976  case 2:
977  RGB888_RGB332(*dst++, *src);
978  ++src;
979  case 1:
980  RGB888_RGB332(*dst++, *src);
981  ++src;
982  }
983 #endif /* USE_DUFFS_LOOP */
984  src += srcskip;
985  dst += dstskip;
986  }
987  } else {
988  int Pixel;
989 
990  while (height--) {
991 #ifdef USE_DUFFS_LOOP
992  /* *INDENT-OFF* */
993  DUFFS_LOOP(
994  RGB888_RGB332(Pixel, *src);
995  *dst++ = map[Pixel];
996  ++src;
997  , width);
998  /* *INDENT-ON* */
999 #else
1000  for (c = width / 4; c; --c) {
1001  /* Pack RGB into 8bit pixel */
1002  RGB888_RGB332(Pixel, *src);
1003  *dst++ = map[Pixel];
1004  ++src;
1005  RGB888_RGB332(Pixel, *src);
1006  *dst++ = map[Pixel];
1007  ++src;
1008  RGB888_RGB332(Pixel, *src);
1009  *dst++ = map[Pixel];
1010  ++src;
1011  RGB888_RGB332(Pixel, *src);
1012  *dst++ = map[Pixel];
1013  ++src;
1014  }
1015  switch (width & 3) {
1016  case 3:
1017  RGB888_RGB332(Pixel, *src);
1018  *dst++ = map[Pixel];
1019  ++src;
1020  case 2:
1021  RGB888_RGB332(Pixel, *src);
1022  *dst++ = map[Pixel];
1023  ++src;
1024  case 1:
1025  RGB888_RGB332(Pixel, *src);
1026  *dst++ = map[Pixel];
1027  ++src;
1028  }
1029 #endif /* USE_DUFFS_LOOP */
1030  src += srcskip;
1031  dst += dstskip;
1032  }
1033  }
1034 }
Uint8 * table
Definition: SDL_blit.h:67
GLenum GLenum dst
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
int src_skip
Definition: SDL_blit.h:60
#define RGB888_RGB332(dst, src)
Definition: SDL_blit_N.c:927
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld [DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp local skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
Uint8 * dst
Definition: SDL_blit.h:61
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:499
const GLubyte * c
Uint8 * src
Definition: SDL_blit.h:57
#define NULL
Definition: begin_code.h:143
const GLubyte GLuint GLuint GLuint GLuint alpha GLboolean GLboolean GLboolean GLboolean alpha GLint GLint GLsizei GLsizei GLenum type GLenum GLint GLenum GLint GLint GLsizei GLsizei GLint border GLenum GLint GLint GLint GLint GLint GLsizei GLsizei height GLsizei GLsizei GLenum GLenum const GLvoid *pixels GLenum GLint GLint GLint GLint j2 GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLfloat *params GLenum GLint GLenum GLenum GLvoid *pixels GLenum GLint GLenum GLint *params GLenum GLenum GLint *params GLenum GLsizei const GLvoid *pointer GLenum GLenum const GLint *params GLenum GLfloat GLfloat GLint GLint const GLfloat *points GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat *points GLint GLfloat GLfloat GLint GLfloat GLfloat v2 GLenum GLenum const GLint *params GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum map
Definition: SDL_glfuncs.h:289
GLenum src

◆ Blit_RGB888_RGB555()

static void Blit_RGB888_RGB555 ( SDL_BlitInfo info)
static

Definition at line 1161 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, RGB888_RGB555_TWO, SDL_BlitInfo::src, and SDL_BlitInfo::src_skip.

1162 {
1163 #ifndef USE_DUFFS_LOOP
1164  int c;
1165 #endif
1166  int width, height;
1167  Uint32 *src;
1168  Uint16 *dst;
1169  int srcskip, dstskip;
1170 
1171  /* Set up some basic variables */
1172  width = info->dst_w;
1173  height = info->dst_h;
1174  src = (Uint32 *) info->src;
1175  srcskip = info->src_skip / 4;
1176  dst = (Uint16 *) info->dst;
1177  dstskip = info->dst_skip / 2;
1178 
1179 #ifdef USE_DUFFS_LOOP
1180  while (height--) {
1181  /* *INDENT-OFF* */
1182  DUFFS_LOOP(
1183  RGB888_RGB555(dst, src);
1184  ++src;
1185  ++dst;
1186  , width);
1187  /* *INDENT-ON* */
1188  src += srcskip;
1189  dst += dstskip;
1190  }
1191 #else
1192  /* Memory align at 4-byte boundary, if necessary */
1193  if ((long) dst & 0x03) {
1194  /* Don't do anything if width is 0 */
1195  if (width == 0) {
1196  return;
1197  }
1198  --width;
1199 
1200  while (height--) {
1201  /* Perform copy alignment */
1202  RGB888_RGB555(dst, src);
1203  ++src;
1204  ++dst;
1205 
1206  /* Copy in 4 pixel chunks */
1207  for (c = width / 4; c; --c) {
1208  RGB888_RGB555_TWO(dst, src);
1209  src += 2;
1210  dst += 2;
1211  RGB888_RGB555_TWO(dst, src);
1212  src += 2;
1213  dst += 2;
1214  }
1215  /* Get any leftovers */
1216  switch (width & 3) {
1217  case 3:
1218  RGB888_RGB555(dst, src);
1219  ++src;
1220  ++dst;
1221  case 2:
1222  RGB888_RGB555_TWO(dst, src);
1223  src += 2;
1224  dst += 2;
1225  break;
1226  case 1:
1227  RGB888_RGB555(dst, src);
1228  ++src;
1229  ++dst;
1230  break;
1231  }
1232  src += srcskip;
1233  dst += dstskip;
1234  }
1235  } else {
1236  while (height--) {
1237  /* Copy in 4 pixel chunks */
1238  for (c = width / 4; c; --c) {
1239  RGB888_RGB555_TWO(dst, src);
1240  src += 2;
1241  dst += 2;
1242  RGB888_RGB555_TWO(dst, src);
1243  src += 2;
1244  dst += 2;
1245  }
1246  /* Get any leftovers */
1247  switch (width & 3) {
1248  case 3:
1249  RGB888_RGB555(dst, src);
1250  ++src;
1251  ++dst;
1252  case 2:
1253  RGB888_RGB555_TWO(dst, src);
1254  src += 2;
1255  dst += 2;
1256  break;
1257  case 1:
1258  RGB888_RGB555(dst, src);
1259  ++src;
1260  ++dst;
1261  break;
1262  }
1263  src += srcskip;
1264  dst += dstskip;
1265  }
1266  }
1267 #endif /* USE_DUFFS_LOOP */
1268 }
GLenum GLenum dst
#define RGB888_RGB555_TWO(dst, src)
Definition: SDL_blit_N.c:1152
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
int src_skip
Definition: SDL_blit.h:60
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
Uint8 * dst
Definition: SDL_blit.h:61
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:499
const GLubyte * c
Uint8 * src
Definition: SDL_blit.h:57
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:151
GLenum src
#define RGB888_RGB555(dst, src)
Definition: SDL_blit_N.c:1147

◆ Blit_RGB888_RGB565()

static void Blit_RGB888_RGB565 ( SDL_BlitInfo info)
static

Definition at line 1285 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, RGB888_RGB565_TWO, SDL_BlitInfo::src, and SDL_BlitInfo::src_skip.

1286 {
1287 #ifndef USE_DUFFS_LOOP
1288  int c;
1289 #endif
1290  int width, height;
1291  Uint32 *src;
1292  Uint16 *dst;
1293  int srcskip, dstskip;
1294 
1295  /* Set up some basic variables */
1296  width = info->dst_w;
1297  height = info->dst_h;
1298  src = (Uint32 *) info->src;
1299  srcskip = info->src_skip / 4;
1300  dst = (Uint16 *) info->dst;
1301  dstskip = info->dst_skip / 2;
1302 
1303 #ifdef USE_DUFFS_LOOP
1304  while (height--) {
1305  /* *INDENT-OFF* */
1306  DUFFS_LOOP(
1307  RGB888_RGB565(dst, src);
1308  ++src;
1309  ++dst;
1310  , width);
1311  /* *INDENT-ON* */
1312  src += srcskip;
1313  dst += dstskip;
1314  }
1315 #else
1316  /* Memory align at 4-byte boundary, if necessary */
1317  if ((long) dst & 0x03) {
1318  /* Don't do anything if width is 0 */
1319  if (width == 0) {
1320  return;
1321  }
1322  --width;
1323 
1324  while (height--) {
1325  /* Perform copy alignment */
1326  RGB888_RGB565(dst, src);
1327  ++src;
1328  ++dst;
1329 
1330  /* Copy in 4 pixel chunks */
1331  for (c = width / 4; c; --c) {
1332  RGB888_RGB565_TWO(dst, src);
1333  src += 2;
1334  dst += 2;
1335  RGB888_RGB565_TWO(dst, src);
1336  src += 2;
1337  dst += 2;
1338  }
1339  /* Get any leftovers */
1340  switch (width & 3) {
1341  case 3:
1342  RGB888_RGB565(dst, src);
1343  ++src;
1344  ++dst;
1345  case 2:
1346  RGB888_RGB565_TWO(dst, src);
1347  src += 2;
1348  dst += 2;
1349  break;
1350  case 1:
1351  RGB888_RGB565(dst, src);
1352  ++src;
1353  ++dst;
1354  break;
1355  }
1356  src += srcskip;
1357  dst += dstskip;
1358  }
1359  } else {
1360  while (height--) {
1361  /* Copy in 4 pixel chunks */
1362  for (c = width / 4; c; --c) {
1363  RGB888_RGB565_TWO(dst, src);
1364  src += 2;
1365  dst += 2;
1366  RGB888_RGB565_TWO(dst, src);
1367  src += 2;
1368  dst += 2;
1369  }
1370  /* Get any leftovers */
1371  switch (width & 3) {
1372  case 3:
1373  RGB888_RGB565(dst, src);
1374  ++src;
1375  ++dst;
1376  case 2:
1377  RGB888_RGB565_TWO(dst, src);
1378  src += 2;
1379  dst += 2;
1380  break;
1381  case 1:
1382  RGB888_RGB565(dst, src);
1383  ++src;
1384  ++dst;
1385  break;
1386  }
1387  src += srcskip;
1388  dst += dstskip;
1389  }
1390  }
1391 #endif /* USE_DUFFS_LOOP */
1392 }
GLenum GLenum dst
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
int src_skip
Definition: SDL_blit.h:60
#define RGB888_RGB565(dst, src)
Definition: SDL_blit_N.c:1271
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
Uint8 * dst
Definition: SDL_blit.h:61
#define RGB888_RGB565_TWO(dst, src)
Definition: SDL_blit_N.c:1276
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:499
const GLubyte * c
Uint8 * src
Definition: SDL_blit.h:57
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:151
GLenum src

◆ BlitNto1()

static void BlitNto1 ( SDL_BlitInfo info)
static

Definition at line 2014 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().

2015 {
2016 #ifndef USE_DUFFS_LOOP
2017  int c;
2018 #endif
2019  int width, height;
2020  Uint8 *src;
2021  const Uint8 *map;
2022  Uint8 *dst;
2023  int srcskip, dstskip;
2024  int srcbpp;
2025  Uint32 Pixel;
2026  int sR, sG, sB;
2027  SDL_PixelFormat *srcfmt;
2028 
2029  /* Set up some basic variables */
2030  width = info->dst_w;
2031  height = info->dst_h;
2032  src = info->src;
2033  srcskip = info->src_skip;
2034  dst = info->dst;
2035  dstskip = info->dst_skip;
2036  map = info->table;
2037  srcfmt = info->src_fmt;
2038  srcbpp = srcfmt->BytesPerPixel;
2039 
2040  if (map == NULL) {
2041  while (height--) {
2042 #ifdef USE_DUFFS_LOOP
2043  /* *INDENT-OFF* */
2044  DUFFS_LOOP(
2045  DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
2046  sR, sG, sB);
2047  if ( 1 ) {
2048  /* Pack RGB into 8bit pixel */
2049  *dst = ((sR>>5)<<(3+2))|
2050  ((sG>>5)<<(2)) |
2051  ((sB>>6)<<(0)) ;
2052  }
2053  dst++;
2054  src += srcbpp;
2055  , width);
2056  /* *INDENT-ON* */
2057 #else
2058  for (c = width; c; --c) {
2059  DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
2060  if (1) {
2061  /* Pack RGB into 8bit pixel */
2062  *dst = ((sR >> 5) << (3 + 2)) |
2063  ((sG >> 5) << (2)) | ((sB >> 6) << (0));
2064  }
2065  dst++;
2066  src += srcbpp;
2067  }
2068 #endif
2069  src += srcskip;
2070  dst += dstskip;
2071  }
2072  } else {
2073  while (height--) {
2074 #ifdef USE_DUFFS_LOOP
2075  /* *INDENT-OFF* */
2076  DUFFS_LOOP(
2077  DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
2078  sR, sG, sB);
2079  if ( 1 ) {
2080  /* Pack RGB into 8bit pixel */
2081  *dst = map[((sR>>5)<<(3+2))|
2082  ((sG>>5)<<(2)) |
2083  ((sB>>6)<<(0)) ];
2084  }
2085  dst++;
2086  src += srcbpp;
2087  , width);
2088  /* *INDENT-ON* */
2089 #else
2090  for (c = width; c; --c) {
2091  DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
2092  if (1) {
2093  /* Pack RGB into 8bit pixel */
2094  *dst = map[((sR >> 5) << (3 + 2)) |
2095  ((sG >> 5) << (2)) | ((sB >> 6) << (0))];
2096  }
2097  dst++;
2098  src += srcbpp;
2099  }
2100 #endif /* USE_DUFFS_LOOP */
2101  src += srcskip;
2102  dst += dstskip;
2103  }
2104  }
2105 }
Uint8 * table
Definition: SDL_blit.h:67
GLenum GLenum dst
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
int src_skip
Definition: SDL_blit.h:60
Uint8 BytesPerPixel
Definition: SDL_pixels.h:318
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
Uint8 * dst
Definition: SDL_blit.h:61
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:499
const GLubyte * c
Uint8 * src
Definition: SDL_blit.h:57
#define NULL
Definition: begin_code.h:143
#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b)
Definition: SDL_blit.h:176
const GLubyte GLuint GLuint GLuint GLuint alpha GLboolean GLboolean GLboolean GLboolean alpha GLint GLint GLsizei GLsizei GLenum type GLenum GLint GLenum GLint GLint GLsizei GLsizei GLint border GLenum GLint GLint GLint GLint GLint GLsizei GLsizei height GLsizei GLsizei GLenum GLenum const GLvoid *pixels GLenum GLint GLint GLint GLint j2 GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLfloat *params GLenum GLint GLenum GLenum GLvoid *pixels GLenum GLint GLenum GLint *params GLenum GLenum GLint *params GLenum GLsizei const GLvoid *pointer GLenum GLenum const GLint *params GLenum GLfloat GLfloat GLint GLint const GLfloat *points GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat *points GLint GLfloat GLfloat GLint GLfloat GLfloat v2 GLenum GLenum const GLint *params GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum map
Definition: SDL_glfuncs.h:289
GLenum src

◆ BlitNto1Key()

static void BlitNto1Key ( SDL_BlitInfo info)
static

Definition at line 2249 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().

2250 {
2251  int width = info->dst_w;
2252  int height = info->dst_h;
2253  Uint8 *src = info->src;
2254  int srcskip = info->src_skip;
2255  Uint8 *dst = info->dst;
2256  int dstskip = info->dst_skip;
2257  SDL_PixelFormat *srcfmt = info->src_fmt;
2258  const Uint8 *palmap = info->table;
2259  Uint32 ckey = info->colorkey;
2260  Uint32 rgbmask = ~srcfmt->Amask;
2261  int srcbpp;
2262  Uint32 Pixel;
2263  unsigned sR, sG, sB;
2264 
2265  /* Set up some basic variables */
2266  srcbpp = srcfmt->BytesPerPixel;
2267  ckey &= rgbmask;
2268 
2269  if (palmap == NULL) {
2270  while (height--) {
2271  /* *INDENT-OFF* */
2272  DUFFS_LOOP(
2273  {
2274  DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
2275  sR, sG, sB);
2276  if ( (Pixel & rgbmask) != ckey ) {
2277  /* Pack RGB into 8bit pixel */
2278  *dst = (Uint8)(((sR>>5)<<(3+2))|
2279  ((sG>>5)<<(2)) |
2280  ((sB>>6)<<(0)));
2281  }
2282  dst++;
2283  src += srcbpp;
2284  },
2285  width);
2286  /* *INDENT-ON* */
2287  src += srcskip;
2288  dst += dstskip;
2289  }
2290  } else {
2291  while (height--) {
2292  /* *INDENT-OFF* */
2293  DUFFS_LOOP(
2294  {
2295  DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
2296  sR, sG, sB);
2297  if ( (Pixel & rgbmask) != ckey ) {
2298  /* Pack RGB into 8bit pixel */
2299  *dst = (Uint8)palmap[((sR>>5)<<(3+2))|
2300  ((sG>>5)<<(2)) |
2301  ((sB>>6)<<(0)) ];
2302  }
2303  dst++;
2304  src += srcbpp;
2305  },
2306  width);
2307  /* *INDENT-ON* */
2308  src += srcskip;
2309  dst += dstskip;
2310  }
2311  }
2312 }
Uint8 * table
Definition: SDL_blit.h:67
GLenum GLenum dst
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
int src_skip
Definition: SDL_blit.h:60
Uint8 BytesPerPixel
Definition: SDL_pixels.h:318
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
Uint32 colorkey
Definition: SDL_blit.h:69
Uint8 * dst
Definition: SDL_blit.h:61
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:499
Uint8 * src
Definition: SDL_blit.h:57
#define NULL
Definition: begin_code.h:143
#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b)
Definition: SDL_blit.h:176
GLenum src

◆ BlitNto2101010()

static void BlitNto2101010 ( SDL_BlitInfo info)
static

Definition at line 2467 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().

2468 {
2469  int width = info->dst_w;
2470  int height = info->dst_h;
2471  Uint8 *src = info->src;
2472  int srcskip = info->src_skip;
2473  Uint8 *dst = info->dst;
2474  int dstskip = info->dst_skip;
2475  SDL_PixelFormat *srcfmt = info->src_fmt;
2476  int srcbpp = srcfmt->BytesPerPixel;
2477  Uint32 Pixel;
2478  unsigned sR, sG, sB, sA;
2479 
2480  while (height--) {
2481  /* *INDENT-OFF* */
2482  DUFFS_LOOP(
2483  {
2484  DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
2485  ARGB2101010_FROM_RGBA(Pixel, sR, sG, sB, sA);
2486  *(Uint32 *)dst = Pixel;
2487  dst += 4;
2488  src += srcbpp;
2489  },
2490  width);
2491  /* *INDENT-ON* */
2492  src += srcskip;
2493  dst += dstskip;
2494  }
2495 }
GLenum GLenum dst
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
int src_skip
Definition: SDL_blit.h:60
Uint8 BytesPerPixel
Definition: SDL_pixels.h:318
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
Uint8 * dst
Definition: SDL_blit.h:61
#define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a)
Definition: SDL_blit.h:352
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:499
Uint8 * src
Definition: SDL_blit.h:57
#define ARGB2101010_FROM_RGBA(Pixel, r, g, b, a)
Definition: SDL_blit.h:252
GLenum src

◆ BlitNtoN()

static void BlitNtoN ( SDL_BlitInfo info)
static

Definition at line 2185 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().

2186 {
2187  int width = info->dst_w;
2188  int height = info->dst_h;
2189  Uint8 *src = info->src;
2190  int srcskip = info->src_skip;
2191  Uint8 *dst = info->dst;
2192  int dstskip = info->dst_skip;
2193  SDL_PixelFormat *srcfmt = info->src_fmt;
2194  int srcbpp = srcfmt->BytesPerPixel;
2195  SDL_PixelFormat *dstfmt = info->dst_fmt;
2196  int dstbpp = dstfmt->BytesPerPixel;
2197  unsigned alpha = dstfmt->Amask ? info->a : 0;
2198 
2199  while (height--) {
2200  /* *INDENT-OFF* */
2201  DUFFS_LOOP(
2202  {
2203  Uint32 Pixel;
2204  unsigned sR;
2205  unsigned sG;
2206  unsigned sB;
2207  DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
2208  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha);
2209  dst += dstbpp;
2210  src += srcbpp;
2211  },
2212  width);
2213  /* *INDENT-ON* */
2214  src += srcskip;
2215  dst += dstskip;
2216  }
2217 }
GLenum GLenum dst
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
int src_skip
Definition: SDL_blit.h:60
Uint8 BytesPerPixel
Definition: SDL_pixels.h:318
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a)
Definition: SDL_blit.h:401
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
GLfloat GLfloat GLfloat alpha
Uint8 * dst
Definition: SDL_blit.h:61
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:499
Uint8 * src
Definition: SDL_blit.h:57
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b)
Definition: SDL_blit.h:176
GLenum src
Uint8 a
Definition: SDL_blit.h:70

◆ BlitNtoNCopyAlpha()

static void BlitNtoNCopyAlpha ( SDL_BlitInfo info)
static

Definition at line 2220 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().

2221 {
2222  int width = info->dst_w;
2223  int height = info->dst_h;
2224  Uint8 *src = info->src;
2225  int srcskip = info->src_skip;
2226  Uint8 *dst = info->dst;
2227  int dstskip = info->dst_skip;
2228  SDL_PixelFormat *srcfmt = info->src_fmt;
2229  int srcbpp = srcfmt->BytesPerPixel;
2230  SDL_PixelFormat *dstfmt = info->dst_fmt;
2231  int dstbpp = dstfmt->BytesPerPixel;
2232  int c;
2233 
2234  while (height--) {
2235  for (c = width; c; --c) {
2236  Uint32 Pixel;
2237  unsigned sR, sG, sB, sA;
2238  DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
2239  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, sA);
2240  dst += dstbpp;
2241  src += srcbpp;
2242  }
2243  src += srcskip;
2244  dst += dstskip;
2245  }
2246 }
GLenum GLenum dst
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
int src_skip
Definition: SDL_blit.h:60
Uint8 BytesPerPixel
Definition: SDL_pixels.h:318
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a)
Definition: SDL_blit.h:401
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
Uint8 * dst
Definition: SDL_blit.h:61
#define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a)
Definition: SDL_blit.h:352
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
const GLubyte * c
Uint8 * src
Definition: SDL_blit.h:57
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
GLenum src

◆ BlitNtoNKey()

static void BlitNtoNKey ( SDL_BlitInfo info)
static

Definition at line 2349 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, RETRIEVE_RGB_PIXEL, RGB_FROM_PIXEL, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitN().

2350 {
2351  int width = info->dst_w;
2352  int height = info->dst_h;
2353  Uint8 *src = info->src;
2354  int srcskip = info->src_skip;
2355  Uint8 *dst = info->dst;
2356  int dstskip = info->dst_skip;
2357  Uint32 ckey = info->colorkey;
2358  SDL_PixelFormat *srcfmt = info->src_fmt;
2359  SDL_PixelFormat *dstfmt = info->dst_fmt;
2360  int srcbpp = srcfmt->BytesPerPixel;
2361  int dstbpp = dstfmt->BytesPerPixel;
2362  unsigned alpha = dstfmt->Amask ? info->a : 0;
2363  Uint32 rgbmask = ~srcfmt->Amask;
2364 
2365  /* Set up some basic variables */
2366  ckey &= rgbmask;
2367 
2368  while (height--) {
2369  /* *INDENT-OFF* */
2370  DUFFS_LOOP(
2371  {
2372  Uint32 Pixel;
2373  unsigned sR;
2374  unsigned sG;
2375  unsigned sB;
2376  RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
2377  if ( (Pixel & rgbmask) != ckey ) {
2378  RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB);
2379  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha);
2380  }
2381  dst += dstbpp;
2382  src += srcbpp;
2383  },
2384  width);
2385  /* *INDENT-ON* */
2386  src += srcskip;
2387  dst += dstskip;
2388  }
2389 }
GLenum GLenum dst
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
int src_skip
Definition: SDL_blit.h:60
#define RETRIEVE_RGB_PIXEL(buf, bpp, Pixel)
Definition: SDL_blit.h:145
Uint8 BytesPerPixel
Definition: SDL_pixels.h:318
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a)
Definition: SDL_blit.h:401
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
GLfloat GLfloat GLfloat alpha
Uint32 colorkey
Definition: SDL_blit.h:69
Uint8 * dst
Definition: SDL_blit.h:61
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
#define RGB_FROM_PIXEL(Pixel, fmt, r, g, b)
Definition: SDL_blit.h:121
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:499
Uint8 * src
Definition: SDL_blit.h:57
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
GLenum src
Uint8 a
Definition: SDL_blit.h:70

◆ BlitNtoNKeyCopyAlpha()

static void BlitNtoNKeyCopyAlpha ( SDL_BlitInfo info)
static

Definition at line 2392 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_BlitInfo::src, SDL_BlitInfo::src_fmt, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitN().

2393 {
2394  int width = info->dst_w;
2395  int height = info->dst_h;
2396  Uint8 *src = info->src;
2397  int srcskip = info->src_skip;
2398  Uint8 *dst = info->dst;
2399  int dstskip = info->dst_skip;
2400  Uint32 ckey = info->colorkey;
2401  SDL_PixelFormat *srcfmt = info->src_fmt;
2402  SDL_PixelFormat *dstfmt = info->dst_fmt;
2403  Uint32 rgbmask = ~srcfmt->Amask;
2404 
2405  Uint8 srcbpp;
2406  Uint8 dstbpp;
2407  Uint32 Pixel;
2408  unsigned sR, sG, sB, sA;
2409 
2410  /* Set up some basic variables */
2411  srcbpp = srcfmt->BytesPerPixel;
2412  dstbpp = dstfmt->BytesPerPixel;
2413  ckey &= rgbmask;
2414 
2415  while (height--) {
2416  /* *INDENT-OFF* */
2417  DUFFS_LOOP(
2418  {
2419  DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
2420  if ( (Pixel & rgbmask) != ckey ) {
2421  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, sA);
2422  }
2423  dst += dstbpp;
2424  src += srcbpp;
2425  },
2426  width);
2427  /* *INDENT-ON* */
2428  src += srcskip;
2429  dst += dstskip;
2430  }
2431 }
GLenum GLenum dst
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
int src_skip
Definition: SDL_blit.h:60
Uint8 BytesPerPixel
Definition: SDL_pixels.h:318
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a)
Definition: SDL_blit.h:401
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
Uint32 colorkey
Definition: SDL_blit.h:69
Uint8 * dst
Definition: SDL_blit.h:61
#define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a)
Definition: SDL_blit.h:352
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:499
Uint8 * src
Definition: SDL_blit.h:57
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
GLenum src

◆ SDL_CalculateBlitN()

SDL_BlitFunc SDL_CalculateBlitN ( SDL_Surface surface)

Definition at line 2575 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, blit_table::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, blit_table::NO_ALPHA, NULL, SDL_PixelFormat::Rmask, SDL_COPY_COLORKEY, SDL_COPY_RLE_MASK, SDL_HasAltiVec, SDL_PIXELFORMAT_ARGB2101010, blit_table::SET_ALPHA, blit_table::srcB, blit_table::srcG, and blit_table::srcR.

Referenced by SDL_CalculateBlit().

2576 {
2577  SDL_PixelFormat *srcfmt;
2578  SDL_PixelFormat *dstfmt;
2579  const struct blit_table *table;
2580  int which;
2581  SDL_BlitFunc blitfun;
2582 
2583  /* Set up data for choosing the blit */
2584  srcfmt = surface->format;
2585  dstfmt = surface->map->dst->format;
2586 
2587  /* We don't support destinations less than 8-bits */
2588  if (dstfmt->BitsPerPixel < 8) {
2589  return (NULL);
2590  }
2591 
2592  switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
2593  case 0:
2594  blitfun = NULL;
2595  if (dstfmt->BitsPerPixel == 8) {
2596  if ((srcfmt->BytesPerPixel == 4) &&
2597  (srcfmt->Rmask == 0x00FF0000) &&
2598  (srcfmt->Gmask == 0x0000FF00) &&
2599  (srcfmt->Bmask == 0x000000FF)) {
2600  blitfun = Blit_RGB888_index8;
2601  } else if ((srcfmt->BytesPerPixel == 4) &&
2602  (srcfmt->Rmask == 0x3FF00000) &&
2603  (srcfmt->Gmask == 0x000FFC00) &&
2604  (srcfmt->Bmask == 0x000003FF)) {
2605  blitfun = Blit_RGB101010_index8;
2606  } else {
2607  blitfun = BlitNto1;
2608  }
2609  } else {
2610  /* Now the meat, choose the blitter we want */
2611  int a_need = NO_ALPHA;
2612  if (dstfmt->Amask)
2613  a_need = srcfmt->Amask ? COPY_ALPHA : SET_ALPHA;
2614  table = normal_blit[srcfmt->BytesPerPixel - 1];
2615  for (which = 0; table[which].dstbpp; ++which) {
2616  if (MASKOK(srcfmt->Rmask, table[which].srcR) &&
2617  MASKOK(srcfmt->Gmask, table[which].srcG) &&
2618  MASKOK(srcfmt->Bmask, table[which].srcB) &&
2619  MASKOK(dstfmt->Rmask, table[which].dstR) &&
2620  MASKOK(dstfmt->Gmask, table[which].dstG) &&
2621  MASKOK(dstfmt->Bmask, table[which].dstB) &&
2622  dstfmt->BytesPerPixel == table[which].dstbpp &&
2623  (a_need & table[which].alpha) == a_need &&
2624  ((table[which].blit_features & GetBlitFeatures()) ==
2625  table[which].blit_features))
2626  break;
2627  }
2628  blitfun = table[which].blitfunc;
2629 
2630  if (blitfun == BlitNtoN) { /* default C fallback catch-all. Slow! */
2631  if (srcfmt->format == SDL_PIXELFORMAT_ARGB2101010) {
2632  blitfun = Blit2101010toN;
2633  } else if (dstfmt->format == SDL_PIXELFORMAT_ARGB2101010) {
2634  blitfun = BlitNto2101010;
2635  } else if (srcfmt->BytesPerPixel == 4 &&
2636  dstfmt->BytesPerPixel == 4 &&
2637  srcfmt->Rmask == dstfmt->Rmask &&
2638  srcfmt->Gmask == dstfmt->Gmask &&
2639  srcfmt->Bmask == dstfmt->Bmask) {
2640  if (a_need == COPY_ALPHA) {
2641  if (srcfmt->Amask == dstfmt->Amask) {
2642  /* Fastpath C fallback: 32bit RGBA<->RGBA blit with matching RGBA */
2643  blitfun = Blit4to4CopyAlpha;
2644  } else {
2645  blitfun = BlitNtoNCopyAlpha;
2646  }
2647  } else {
2648  /* Fastpath C fallback: 32bit RGB<->RGBA blit with matching RGB */
2649  blitfun = Blit4to4MaskAlpha;
2650  }
2651  } else if (a_need == COPY_ALPHA) {
2652  blitfun = BlitNtoNCopyAlpha;
2653  }
2654  }
2655  }
2656  return (blitfun);
2657 
2658  case SDL_COPY_COLORKEY:
2659  /* colorkey blit: Here we don't have too many options, mostly
2660  because RLE is the preferred fast way to deal with this.
2661  If a particular case turns out to be useful we'll add it. */
2662 
2663  if (srcfmt->BytesPerPixel == 2 && surface->map->identity)
2664  return Blit2to2Key;
2665  else if (dstfmt->BytesPerPixel == 1)
2666  return BlitNto1Key;
2667  else {
2668 #if SDL_ALTIVEC_BLITTERS
2669  if ((srcfmt->BytesPerPixel == 4) && (dstfmt->BytesPerPixel == 4)
2670  && SDL_HasAltiVec()) {
2671  return Blit32to32KeyAltivec;
2672  } else
2673 #endif
2674  if (srcfmt->Amask && dstfmt->Amask) {
2675  return BlitNtoNKeyCopyAlpha;
2676  } else {
2677  return BlitNtoNKey;
2678  }
2679  }
2680  }
2681 
2682  return NULL;
2683 }
SDL_BlitFunc blitfunc
Definition: SDL_blit_N.c:2504
#define SDL_HasAltiVec
Uint32 srcG
Definition: SDL_blit_N.c:2500
Uint32 srcB
Definition: SDL_blit_N.c:2500
#define MASKOK(x, y)
Definition: SDL_blit_N.c:2572
GLenum GLsizei GLenum GLenum const void * table
#define SDL_COPY_COLORKEY
Definition: SDL_blit.h:39
Uint32 dstB
Definition: SDL_blit_N.c:2502
Uint32 dstR
Definition: SDL_blit_N.c:2502
Uint8 BytesPerPixel
Definition: SDL_pixels.h:318
static void BlitNto2101010(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2467
#define SDL_COPY_RLE_MASK
Definition: SDL_blit.h:44
enum blit_features blit_features
Definition: SDL_blit_N.c:2503
Uint32 srcR
Definition: SDL_blit_N.c:2500
static void BlitNtoNCopyAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2220
struct SDL_BlitMap * map
Definition: SDL_surface.h:88
Uint32 dstG
Definition: SDL_blit_N.c:2502
static void Blit2to2Key(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2315
Uint8 BitsPerPixel
Definition: SDL_pixels.h:317
static void Blit4to4MaskAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2109
static void BlitNto1Key(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2249
static void Blit_RGB888_index8(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:933
SDL_Surface * dst
Definition: SDL_blit.h:87
#define NULL
Definition: begin_code.h:143
SDL_PixelFormat * format
Definition: SDL_surface.h:72
static const struct blit_table *const normal_blit[]
Definition: SDL_blit_N.c:2567
static void BlitNtoNKey(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2349
static void Blit2101010toN(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2435
static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2392
#define GetBlitFeatures()
Definition: SDL_blit_N.c:882
void(* SDL_BlitFunc)(SDL_BlitInfo *info)
Definition: SDL_blit.h:73
static void Blit_RGB101010_index8(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1043
blit_features
Definition: SDL_blit_N.c:32
static void Blit4to4CopyAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2159
static void BlitNtoN(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2185
enum blit_table::@27 alpha
int identity
Definition: SDL_blit.h:88
SDL_BlitInfo info
Definition: SDL_blit.h:91
static void BlitNto1(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2014

Variable Documentation

◆ normal_blit

const struct blit_table* const normal_blit[]
static
Initial value:
= {
}
static const struct blit_table normal_blit_2[]
Definition: SDL_blit_N.c:2513
static const struct blit_table normal_blit_3[]
Definition: SDL_blit_N.c:2538
static const struct blit_table normal_blit_1[]
Definition: SDL_blit_N.c:2508
static const struct blit_table normal_blit_4[]
Definition: SDL_blit_N.c:2543

Definition at line 2567 of file SDL_blit_N.c.

◆ normal_blit_1

const struct blit_table normal_blit_1[]
static
Initial value:
= {
{0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0}
}
static void BlitNtoN(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2185

Definition at line 2508 of file SDL_blit_N.c.

◆ normal_blit_2

const 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}
}
static void Blit_RGB565_ARGB8888(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1594
static void Blit_RGB565_RGBA8888(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1870
static void Blit_RGB565_BGRA8888(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2008
static void BlitNtoN(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2185
static void Blit_RGB565_ABGR8888(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1732

Definition at line 2513 of file SDL_blit_N.c.

◆ normal_blit_3

const struct blit_table normal_blit_3[]
static
Initial value:
= {
{0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0}
}
static void BlitNtoN(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2185

Definition at line 2538 of file SDL_blit_N.c.

◆ normal_blit_4

const struct blit_table normal_blit_4[]
static
Initial value:
= {
{0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x0000F800, 0x000007E0, 0x0000001F,
{0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x00007C00, 0x000003E0, 0x0000001F,
0, Blit_RGB888_RGB555, NO_ALPHA},
{0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0}
}
static void BlitNtoN(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2185
static void Blit_RGB888_RGB555(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1161
static void Blit_RGB888_RGB565(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1285

Definition at line 2543 of file SDL_blit_N.c.

◆ RGB565_ABGR8888_LUT

const Uint32 RGB565_ABGR8888_LUT[512]
static

Definition at line 1600 of file SDL_blit_N.c.

Referenced by Blit_RGB565_ABGR8888().

◆ RGB565_ARGB8888_LUT

const Uint32 RGB565_ARGB8888_LUT[512]
static

Definition at line 1462 of file SDL_blit_N.c.

Referenced by Blit_RGB565_ARGB8888().

◆ RGB565_BGRA8888_LUT

const Uint32 RGB565_BGRA8888_LUT[512]
static

Definition at line 1876 of file SDL_blit_N.c.

Referenced by Blit_RGB565_BGRA8888().

◆ RGB565_RGBA8888_LUT

const Uint32 RGB565_RGBA8888_LUT[512]
static

Definition at line 1738 of file SDL_blit_N.c.

Referenced by Blit_RGB565_RGBA8888().