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_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))
 

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

◆ COPY_ALPHA

#define COPY_ALPHA   4

Definition at line 2561 of file SDL_blit_N.c.

Referenced by SDL_CalculateBlitN().

◆ GetBlitFeatures

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

Definition at line 886 of file SDL_blit_N.c.

Referenced by SDL_CalculateBlitN().

◆ HI

#define HI   1

Definition at line 923 of file SDL_blit_N.c.

Referenced by Blit1to2().

◆ LO

#define LO   0

Definition at line 924 of file SDL_blit_N.c.

Referenced by Blit1to2().

◆ MASKOK

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

Definition at line 2635 of file SDL_blit_N.c.

Referenced by SDL_CalculateBlitN().

◆ NO_ALPHA

#define NO_ALPHA   1

Definition at line 2559 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)); \
}
GLenum src
uint8_t Uint8
Definition: SDL_stdinc.h:179

Definition at line 1041 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 1404 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)); \
}
GLenum src
uint8_t Uint8
Definition: SDL_stdinc.h:179

Definition at line 931 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
Definition: SDL_stdinc.h:191
GLenum src

Definition at line 1151 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
Definition: SDL_stdinc.h:191
GLenum src

Definition at line 1277 of file SDL_blit_N.c.

Referenced by Blit_RGB888_RGB565().

◆ SET_ALPHA

#define SET_ALPHA   2

Definition at line 2560 of file SDL_blit_N.c.

Referenced by SDL_CalculateBlitN().

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 2496 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().

2497 {
2498  int width = info->dst_w;
2499  int height = info->dst_h;
2500  Uint8 *src = info->src;
2501  int srcskip = info->src_skip;
2502  Uint8 *dst = info->dst;
2503  int dstskip = info->dst_skip;
2504  SDL_PixelFormat *dstfmt = info->dst_fmt;
2505  int dstbpp = dstfmt->BytesPerPixel;
2506  Uint32 Pixel;
2507  unsigned sR, sG, sB, sA;
2508 
2509  while (height--) {
2510  /* *INDENT-OFF* */
2511  DUFFS_LOOP(
2512  {
2513  Pixel = *(Uint32 *)src;
2514  RGBA_FROM_ARGB2101010(Pixel, sR, sG, sB, sA);
2515  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, sA);
2516  dst += dstbpp;
2517  src += 4;
2518  },
2519  width);
2520  /* *INDENT-ON* */
2521  src += srcskip;
2522  dst += dstskip;
2523  }
2524 }
int src_skip
Definition: SDL_blit.h:60
GLenum GLenum dst
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a)
Definition: SDL_blit.h:402
#define RGBA_FROM_ARGB2101010(Pixel, r, g, b, a)
Definition: SDL_blit.h:346
int dst_skip
Definition: SDL_blit.h:64
GLenum src
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint8 * dst
Definition: SDL_blit.h:61
uint8_t Uint8
Definition: SDL_stdinc.h:179
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:500
Uint8 * src
Definition: SDL_blit.h:57
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:203

◆ Blit2to2Key()

static void Blit2to2Key ( SDL_BlitInfo info)
static

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

2324 {
2325  int width = info->dst_w;
2326  int height = info->dst_h;
2327  Uint16 *srcp = (Uint16 *) info->src;
2328  int srcskip = info->src_skip;
2329  Uint16 *dstp = (Uint16 *) info->dst;
2330  int dstskip = info->dst_skip;
2331  Uint32 ckey = info->colorkey;
2332  Uint32 rgbmask = ~info->src_fmt->Amask;
2333 
2334  /* Set up some basic variables */
2335  srcskip /= 2;
2336  dstskip /= 2;
2337  ckey &= rgbmask;
2338 
2339  while (height--) {
2340  /* *INDENT-OFF* */
2341  DUFFS_LOOP(
2342  {
2343  if ( (*srcp & rgbmask) != ckey ) {
2344  *dstp = *srcp;
2345  }
2346  dstp++;
2347  srcp++;
2348  },
2349  width);
2350  /* *INDENT-ON* */
2351  srcp += srcskip;
2352  dstp += dstskip;
2353  }
2354 }
int src_skip
Definition: SDL_blit.h:60
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
uint16_t Uint16
Definition: SDL_stdinc.h:191
int dst_skip
Definition: SDL_blit.h:64
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
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:500
Uint8 * src
Definition: SDL_blit.h:57
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:203

◆ Blit4to4CopyAlpha()

static void Blit4to4CopyAlpha ( SDL_BlitInfo info)
static

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

2168 {
2169  int width = info->dst_w;
2170  int height = info->dst_h;
2171  Uint32 *src = (Uint32 *) info->src;
2172  int srcskip = info->src_skip;
2173  Uint32 *dst = (Uint32 *) info->dst;
2174  int dstskip = info->dst_skip;
2175 
2176  /* RGBA->RGBA, COPY_ALPHA */
2177  while (height--) {
2178  /* *INDENT-OFF* */
2179  DUFFS_LOOP(
2180  {
2181  *dst = *src;
2182  ++dst;
2183  ++src;
2184  },
2185  width);
2186  /* *INDENT-ON* */
2187  src = (Uint32 *) ((Uint8 *) src + srcskip);
2188  dst = (Uint32 *) ((Uint8 *) dst + dstskip);
2189  }
2190 }
int src_skip
Definition: SDL_blit.h:60
GLenum GLenum dst
int dst_skip
Definition: SDL_blit.h:64
GLenum src
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint8 * dst
Definition: SDL_blit.h:61
uint8_t Uint8
Definition: SDL_stdinc.h:179
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:500
Uint8 * src
Definition: SDL_blit.h:57
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:203

◆ Blit4to4MaskAlpha()

static void Blit4to4MaskAlpha ( SDL_BlitInfo info)
static

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

2118 {
2119  int width = info->dst_w;
2120  int height = info->dst_h;
2121  Uint32 *src = (Uint32 *) info->src;
2122  int srcskip = info->src_skip;
2123  Uint32 *dst = (Uint32 *) info->dst;
2124  int dstskip = info->dst_skip;
2125  SDL_PixelFormat *srcfmt = info->src_fmt;
2126  SDL_PixelFormat *dstfmt = info->dst_fmt;
2127 
2128  if (dstfmt->Amask) {
2129  /* RGB->RGBA, SET_ALPHA */
2130  Uint32 mask = (info->a >> dstfmt->Aloss) << dstfmt->Ashift;
2131 
2132  while (height--) {
2133  /* *INDENT-OFF* */
2134  DUFFS_LOOP(
2135  {
2136  *dst = *src | mask;
2137  ++dst;
2138  ++src;
2139  },
2140  width);
2141  /* *INDENT-ON* */
2142  src = (Uint32 *) ((Uint8 *) src + srcskip);
2143  dst = (Uint32 *) ((Uint8 *) dst + dstskip);
2144  }
2145  } else {
2146  /* RGBA->RGB, NO_ALPHA */
2147  Uint32 mask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
2148 
2149  while (height--) {
2150  /* *INDENT-OFF* */
2151  DUFFS_LOOP(
2152  {
2153  *dst = *src & mask;
2154  ++dst;
2155  ++src;
2156  },
2157  width);
2158  /* *INDENT-ON* */
2159  src = (Uint32 *) ((Uint8 *) src + srcskip);
2160  dst = (Uint32 *) ((Uint8 *) dst + dstskip);
2161  }
2162  }
2163 }
int src_skip
Definition: SDL_blit.h:60
GLenum GLenum dst
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
int dst_skip
Definition: SDL_blit.h:64
GLenum src
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint8 * dst
Definition: SDL_blit.h:61
uint8_t Uint8
Definition: SDL_stdinc.h:179
GLenum GLint GLuint mask
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:500
Uint8 * src
Definition: SDL_blit.h:57
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:203
Uint8 a
Definition: SDL_blit.h:70

◆ Blit_RGB101010_index8()

static void Blit_RGB101010_index8 ( SDL_BlitInfo info)
static

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

1048 {
1049 #ifndef USE_DUFFS_LOOP
1050  int c;
1051 #endif
1052  int width, height;
1053  Uint32 *src;
1054  const Uint8 *map;
1055  Uint8 *dst;
1056  int srcskip, dstskip;
1057 
1058  /* Set up some basic variables */
1059  width = info->dst_w;
1060  height = info->dst_h;
1061  src = (Uint32 *) info->src;
1062  srcskip = info->src_skip / 4;
1063  dst = info->dst;
1064  dstskip = info->dst_skip;
1065  map = info->table;
1066 
1067  if (map == NULL) {
1068  while (height--) {
1069 #ifdef USE_DUFFS_LOOP
1070  /* *INDENT-OFF* */
1071  DUFFS_LOOP(
1072  RGB101010_RGB332(*dst++, *src);
1073  , width);
1074  /* *INDENT-ON* */
1075 #else
1076  for (c = width / 4; c; --c) {
1077  /* Pack RGB into 8bit pixel */
1078  ++src;
1079  RGB101010_RGB332(*dst++, *src);
1080  ++src;
1081  RGB101010_RGB332(*dst++, *src);
1082  ++src;
1083  RGB101010_RGB332(*dst++, *src);
1084  ++src;
1085  }
1086  switch (width & 3) {
1087  case 3:
1088  RGB101010_RGB332(*dst++, *src);
1089  ++src;
1090  case 2:
1091  RGB101010_RGB332(*dst++, *src);
1092  ++src;
1093  case 1:
1094  RGB101010_RGB332(*dst++, *src);
1095  ++src;
1096  }
1097 #endif /* USE_DUFFS_LOOP */
1098  src += srcskip;
1099  dst += dstskip;
1100  }
1101  } else {
1102  int Pixel;
1103 
1104  while (height--) {
1105 #ifdef USE_DUFFS_LOOP
1106  /* *INDENT-OFF* */
1107  DUFFS_LOOP(
1108  RGB101010_RGB332(Pixel, *src);
1109  *dst++ = map[Pixel];
1110  ++src;
1111  , width);
1112  /* *INDENT-ON* */
1113 #else
1114  for (c = width / 4; c; --c) {
1115  /* Pack RGB into 8bit pixel */
1116  RGB101010_RGB332(Pixel, *src);
1117  *dst++ = map[Pixel];
1118  ++src;
1119  RGB101010_RGB332(Pixel, *src);
1120  *dst++ = map[Pixel];
1121  ++src;
1122  RGB101010_RGB332(Pixel, *src);
1123  *dst++ = map[Pixel];
1124  ++src;
1125  RGB101010_RGB332(Pixel, *src);
1126  *dst++ = map[Pixel];
1127  ++src;
1128  }
1129  switch (width & 3) {
1130  case 3:
1131  RGB101010_RGB332(Pixel, *src);
1132  *dst++ = map[Pixel];
1133  ++src;
1134  case 2:
1135  RGB101010_RGB332(Pixel, *src);
1136  *dst++ = map[Pixel];
1137  ++src;
1138  case 1:
1139  RGB101010_RGB332(Pixel, *src);
1140  *dst++ = map[Pixel];
1141  ++src;
1142  }
1143 #endif /* USE_DUFFS_LOOP */
1144  src += srcskip;
1145  dst += dstskip;
1146  }
1147  }
1148 }
Uint8 * table
Definition: SDL_blit.h:67
int src_skip
Definition: SDL_blit.h:60
GLenum GLenum dst
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
GLenum src
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint8 * dst
Definition: SDL_blit.h:61
#define RGB101010_RGB332(dst, src)
Definition: SDL_blit_N.c:1041
uint8_t Uint8
Definition: SDL_stdinc.h:179
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:500
const GLubyte * c
Uint8 * src
Definition: SDL_blit.h:57
#define NULL
Definition: begin_code.h:164
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:203
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:290

◆ Blit_RGB565_32()

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

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

1407 {
1408 #ifndef USE_DUFFS_LOOP
1409  int c;
1410 #endif
1411  int width, height;
1412  Uint8 *src;
1413  Uint32 *dst;
1414  int srcskip, dstskip;
1415 
1416  /* Set up some basic variables */
1417  width = info->dst_w;
1418  height = info->dst_h;
1419  src = (Uint8 *) info->src;
1420  srcskip = info->src_skip;
1421  dst = (Uint32 *) info->dst;
1422  dstskip = info->dst_skip / 4;
1423 
1424 #ifdef USE_DUFFS_LOOP
1425  while (height--) {
1426  /* *INDENT-OFF* */
1427  DUFFS_LOOP(
1428  {
1429  *dst++ = RGB565_32(dst, src, map);
1430  src += 2;
1431  },
1432  width);
1433  /* *INDENT-ON* */
1434  src += srcskip;
1435  dst += dstskip;
1436  }
1437 #else
1438  while (height--) {
1439  /* Copy in 4 pixel chunks */
1440  for (c = width / 4; c; --c) {
1441  *dst++ = RGB565_32(dst, src, map);
1442  src += 2;
1443  *dst++ = RGB565_32(dst, src, map);
1444  src += 2;
1445  *dst++ = RGB565_32(dst, src, map);
1446  src += 2;
1447  *dst++ = RGB565_32(dst, src, map);
1448  src += 2;
1449  }
1450  /* Get any leftovers */
1451  switch (width & 3) {
1452  case 3:
1453  *dst++ = RGB565_32(dst, src, map);
1454  src += 2;
1455  case 2:
1456  *dst++ = RGB565_32(dst, src, map);
1457  src += 2;
1458  case 1:
1459  *dst++ = RGB565_32(dst, src, map);
1460  src += 2;
1461  break;
1462  }
1463  src += srcskip;
1464  dst += dstskip;
1465  }
1466 #endif /* USE_DUFFS_LOOP */
1467 }
int src_skip
Definition: SDL_blit.h:60
GLenum GLenum dst
int dst_skip
Definition: SDL_blit.h:64
GLenum src
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint8 * dst
Definition: SDL_blit.h:61
uint8_t Uint8
Definition: SDL_stdinc.h:179
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:500
const GLubyte * c
Uint8 * src
Definition: SDL_blit.h:57
#define RGB565_32(dst, src, map)
Definition: SDL_blit_N.c:1404
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:203
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:290

◆ Blit_RGB565_ABGR8888()

static void Blit_RGB565_ABGR8888 ( SDL_BlitInfo info)
static

Definition at line 1740 of file SDL_blit_N.c.

References Blit_RGB565_32(), and RGB565_ABGR8888_LUT.

1741 {
1743 }
static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map)
Definition: SDL_blit_N.c:1406
static const Uint32 RGB565_ABGR8888_LUT[512]
Definition: SDL_blit_N.c:1608

◆ Blit_RGB565_ARGB8888()

static void Blit_RGB565_ARGB8888 ( SDL_BlitInfo info)
static

Definition at line 1602 of file SDL_blit_N.c.

References Blit_RGB565_32(), and RGB565_ARGB8888_LUT.

1603 {
1605 }
static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map)
Definition: SDL_blit_N.c:1406
static const Uint32 RGB565_ARGB8888_LUT[512]
Definition: SDL_blit_N.c:1470

◆ Blit_RGB565_BGRA8888()

static void Blit_RGB565_BGRA8888 ( SDL_BlitInfo info)
static

Definition at line 2016 of file SDL_blit_N.c.

References Blit_RGB565_32(), and RGB565_BGRA8888_LUT.

2017 {
2019 }
static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map)
Definition: SDL_blit_N.c:1406
static const Uint32 RGB565_BGRA8888_LUT[512]
Definition: SDL_blit_N.c:1884

◆ Blit_RGB565_RGBA8888()

static void Blit_RGB565_RGBA8888 ( SDL_BlitInfo info)
static

Definition at line 1878 of file SDL_blit_N.c.

References Blit_RGB565_32(), and RGB565_RGBA8888_LUT.

1879 {
1881 }
static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map)
Definition: SDL_blit_N.c:1406
static const Uint32 RGB565_RGBA8888_LUT[512]
Definition: SDL_blit_N.c:1746

◆ Blit_RGB888_index8()

static void Blit_RGB888_index8 ( SDL_BlitInfo info)
static

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

938 {
939 #ifndef USE_DUFFS_LOOP
940  int c;
941 #endif
942  int width, height;
943  Uint32 *src;
944  const Uint8 *map;
945  Uint8 *dst;
946  int srcskip, dstskip;
947 
948  /* Set up some basic variables */
949  width = info->dst_w;
950  height = info->dst_h;
951  src = (Uint32 *) info->src;
952  srcskip = info->src_skip / 4;
953  dst = info->dst;
954  dstskip = info->dst_skip;
955  map = info->table;
956 
957  if (map == NULL) {
958  while (height--) {
959 #ifdef USE_DUFFS_LOOP
960  /* *INDENT-OFF* */
961  DUFFS_LOOP(
962  RGB888_RGB332(*dst++, *src);
963  , width);
964  /* *INDENT-ON* */
965 #else
966  for (c = width / 4; c; --c) {
967  /* Pack RGB into 8bit pixel */
968  ++src;
969  RGB888_RGB332(*dst++, *src);
970  ++src;
971  RGB888_RGB332(*dst++, *src);
972  ++src;
973  RGB888_RGB332(*dst++, *src);
974  ++src;
975  }
976  switch (width & 3) {
977  case 3:
978  RGB888_RGB332(*dst++, *src);
979  ++src;
980  case 2:
981  RGB888_RGB332(*dst++, *src);
982  ++src;
983  case 1:
984  RGB888_RGB332(*dst++, *src);
985  ++src;
986  }
987 #endif /* USE_DUFFS_LOOP */
988  src += srcskip;
989  dst += dstskip;
990  }
991  } else {
992  int Pixel;
993 
994  while (height--) {
995 #ifdef USE_DUFFS_LOOP
996  /* *INDENT-OFF* */
997  DUFFS_LOOP(
998  RGB888_RGB332(Pixel, *src);
999  *dst++ = map[Pixel];
1000  ++src;
1001  , width);
1002  /* *INDENT-ON* */
1003 #else
1004  for (c = width / 4; c; --c) {
1005  /* Pack RGB into 8bit pixel */
1006  RGB888_RGB332(Pixel, *src);
1007  *dst++ = map[Pixel];
1008  ++src;
1009  RGB888_RGB332(Pixel, *src);
1010  *dst++ = map[Pixel];
1011  ++src;
1012  RGB888_RGB332(Pixel, *src);
1013  *dst++ = map[Pixel];
1014  ++src;
1015  RGB888_RGB332(Pixel, *src);
1016  *dst++ = map[Pixel];
1017  ++src;
1018  }
1019  switch (width & 3) {
1020  case 3:
1021  RGB888_RGB332(Pixel, *src);
1022  *dst++ = map[Pixel];
1023  ++src;
1024  case 2:
1025  RGB888_RGB332(Pixel, *src);
1026  *dst++ = map[Pixel];
1027  ++src;
1028  case 1:
1029  RGB888_RGB332(Pixel, *src);
1030  *dst++ = map[Pixel];
1031  ++src;
1032  }
1033 #endif /* USE_DUFFS_LOOP */
1034  src += srcskip;
1035  dst += dstskip;
1036  }
1037  }
1038 }
Uint8 * table
Definition: SDL_blit.h:67
int src_skip
Definition: SDL_blit.h:60
#define RGB888_RGB332(dst, src)
Definition: SDL_blit_N.c:931
GLenum GLenum dst
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
GLenum src
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint8 * dst
Definition: SDL_blit.h:61
uint8_t Uint8
Definition: SDL_stdinc.h:179
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:500
const GLubyte * c
Uint8 * src
Definition: SDL_blit.h:57
#define NULL
Definition: begin_code.h:164
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:203
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:290

◆ Blit_RGB888_RGB555()

static void Blit_RGB888_RGB555 ( SDL_BlitInfo info)
static

Definition at line 1167 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.

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

◆ Blit_RGB888_RGB565()

static void Blit_RGB888_RGB565 ( SDL_BlitInfo info)
static

Definition at line 1293 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.

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

◆ BlitNto1()

static void BlitNto1 ( SDL_BlitInfo info)
static

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

2023 {
2024 #ifndef USE_DUFFS_LOOP
2025  int c;
2026 #endif
2027  int width, height;
2028  Uint8 *src;
2029  const Uint8 *map;
2030  Uint8 *dst;
2031  int srcskip, dstskip;
2032  int srcbpp;
2033  Uint32 Pixel;
2034  int sR, sG, sB;
2035  SDL_PixelFormat *srcfmt;
2036 
2037  /* Set up some basic variables */
2038  width = info->dst_w;
2039  height = info->dst_h;
2040  src = info->src;
2041  srcskip = info->src_skip;
2042  dst = info->dst;
2043  dstskip = info->dst_skip;
2044  map = info->table;
2045  srcfmt = info->src_fmt;
2046  srcbpp = srcfmt->BytesPerPixel;
2047 
2048  if (map == NULL) {
2049  while (height--) {
2050 #ifdef USE_DUFFS_LOOP
2051  /* *INDENT-OFF* */
2052  DUFFS_LOOP(
2053  DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
2054  sR, sG, sB);
2055  if ( 1 ) {
2056  /* Pack RGB into 8bit pixel */
2057  *dst = ((sR>>5)<<(3+2))|
2058  ((sG>>5)<<(2)) |
2059  ((sB>>6)<<(0)) ;
2060  }
2061  dst++;
2062  src += srcbpp;
2063  , width);
2064  /* *INDENT-ON* */
2065 #else
2066  for (c = width; c; --c) {
2067  DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
2068  if (1) {
2069  /* Pack RGB into 8bit pixel */
2070  *dst = ((sR >> 5) << (3 + 2)) |
2071  ((sG >> 5) << (2)) | ((sB >> 6) << (0));
2072  }
2073  dst++;
2074  src += srcbpp;
2075  }
2076 #endif
2077  src += srcskip;
2078  dst += dstskip;
2079  }
2080  } else {
2081  while (height--) {
2082 #ifdef USE_DUFFS_LOOP
2083  /* *INDENT-OFF* */
2084  DUFFS_LOOP(
2085  DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
2086  sR, sG, sB);
2087  if ( 1 ) {
2088  /* Pack RGB into 8bit pixel */
2089  *dst = map[((sR>>5)<<(3+2))|
2090  ((sG>>5)<<(2)) |
2091  ((sB>>6)<<(0)) ];
2092  }
2093  dst++;
2094  src += srcbpp;
2095  , width);
2096  /* *INDENT-ON* */
2097 #else
2098  for (c = width; c; --c) {
2099  DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
2100  if (1) {
2101  /* Pack RGB into 8bit pixel */
2102  *dst = map[((sR >> 5) << (3 + 2)) |
2103  ((sG >> 5) << (2)) | ((sB >> 6) << (0))];
2104  }
2105  dst++;
2106  src += srcbpp;
2107  }
2108 #endif /* USE_DUFFS_LOOP */
2109  src += srcskip;
2110  dst += dstskip;
2111  }
2112  }
2113 }
Uint8 * table
Definition: SDL_blit.h:67
int src_skip
Definition: SDL_blit.h:60
GLenum GLenum dst
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
int dst_skip
Definition: SDL_blit.h:64
GLenum src
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint8 * dst
Definition: SDL_blit.h:61
uint8_t Uint8
Definition: SDL_stdinc.h:179
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:500
const GLubyte * c
Uint8 * src
Definition: SDL_blit.h:57
#define NULL
Definition: begin_code.h:164
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:203
#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b)
Definition: SDL_blit.h:177
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:290

◆ BlitNto1Key()

static void BlitNto1Key ( SDL_BlitInfo info)
static

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

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

◆ BlitNto2101010()

static void BlitNto2101010 ( SDL_BlitInfo info)
static

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

2529 {
2530  int width = info->dst_w;
2531  int height = info->dst_h;
2532  Uint8 *src = info->src;
2533  int srcskip = info->src_skip;
2534  Uint8 *dst = info->dst;
2535  int dstskip = info->dst_skip;
2536  SDL_PixelFormat *srcfmt = info->src_fmt;
2537  int srcbpp = srcfmt->BytesPerPixel;
2538  Uint32 Pixel;
2539  unsigned sR, sG, sB, sA;
2540 
2541  while (height--) {
2542  /* *INDENT-OFF* */
2543  DUFFS_LOOP(
2544  {
2545  DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
2546  ARGB2101010_FROM_RGBA(Pixel, sR, sG, sB, sA);
2547  *(Uint32 *)dst = Pixel;
2548  dst += 4;
2549  src += srcbpp;
2550  },
2551  width);
2552  /* *INDENT-ON* */
2553  src += srcskip;
2554  dst += dstskip;
2555  }
2556 }
int src_skip
Definition: SDL_blit.h:60
GLenum GLenum dst
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
int dst_skip
Definition: SDL_blit.h:64
GLenum src
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint8 * dst
Definition: SDL_blit.h:61
#define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a)
Definition: SDL_blit.h:353
uint8_t Uint8
Definition: SDL_stdinc.h:179
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:500
Uint8 * src
Definition: SDL_blit.h:57
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:203
#define ARGB2101010_FROM_RGBA(Pixel, r, g, b, a)
Definition: SDL_blit.h:253

◆ BlitNtoN()

static void BlitNtoN ( SDL_BlitInfo info)
static

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

2194 {
2195  int width = info->dst_w;
2196  int height = info->dst_h;
2197  Uint8 *src = info->src;
2198  int srcskip = info->src_skip;
2199  Uint8 *dst = info->dst;
2200  int dstskip = info->dst_skip;
2201  SDL_PixelFormat *srcfmt = info->src_fmt;
2202  int srcbpp = srcfmt->BytesPerPixel;
2203  SDL_PixelFormat *dstfmt = info->dst_fmt;
2204  int dstbpp = dstfmt->BytesPerPixel;
2205  unsigned alpha = dstfmt->Amask ? info->a : 0;
2206 
2207  while (height--) {
2208  /* *INDENT-OFF* */
2209  DUFFS_LOOP(
2210  {
2211  Uint32 Pixel;
2212  unsigned sR;
2213  unsigned sG;
2214  unsigned sB;
2215  DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
2216  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha);
2217  dst += dstbpp;
2218  src += srcbpp;
2219  },
2220  width);
2221  /* *INDENT-ON* */
2222  src += srcskip;
2223  dst += dstskip;
2224  }
2225 }
int src_skip
Definition: SDL_blit.h:60
GLenum GLenum dst
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a)
Definition: SDL_blit.h:402
int dst_skip
Definition: SDL_blit.h:64
GLenum src
GLfloat GLfloat GLfloat alpha
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint8 * dst
Definition: SDL_blit.h:61
uint8_t Uint8
Definition: SDL_stdinc.h:179
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:500
Uint8 * src
Definition: SDL_blit.h:57
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:203
#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b)
Definition: SDL_blit.h:177
Uint8 a
Definition: SDL_blit.h:70

◆ BlitNtoNCopyAlpha()

static void BlitNtoNCopyAlpha ( SDL_BlitInfo info)
static

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

2229 {
2230  int width = info->dst_w;
2231  int height = info->dst_h;
2232  Uint8 *src = info->src;
2233  int srcskip = info->src_skip;
2234  Uint8 *dst = info->dst;
2235  int dstskip = info->dst_skip;
2236  SDL_PixelFormat *srcfmt = info->src_fmt;
2237  int srcbpp = srcfmt->BytesPerPixel;
2238  SDL_PixelFormat *dstfmt = info->dst_fmt;
2239  int dstbpp = dstfmt->BytesPerPixel;
2240  int c;
2241 
2242  while (height--) {
2243  for (c = width; c; --c) {
2244  Uint32 Pixel;
2245  unsigned sR, sG, sB, sA;
2246  DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
2247  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, sA);
2248  dst += dstbpp;
2249  src += srcbpp;
2250  }
2251  src += srcskip;
2252  dst += dstskip;
2253  }
2254 }
int src_skip
Definition: SDL_blit.h:60
GLenum GLenum dst
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a)
Definition: SDL_blit.h:402
int dst_skip
Definition: SDL_blit.h:64
GLenum src
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint8 * dst
Definition: SDL_blit.h:61
#define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a)
Definition: SDL_blit.h:353
uint8_t Uint8
Definition: SDL_stdinc.h:179
const GLubyte * c
Uint8 * src
Definition: SDL_blit.h:57
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:203

◆ BlitNtoNKey()

static void BlitNtoNKey ( SDL_BlitInfo info)
static

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

2358 {
2359  int width = info->dst_w;
2360  int height = info->dst_h;
2361  Uint8 *src = info->src;
2362  int srcskip = info->src_skip;
2363  Uint8 *dst = info->dst;
2364  int dstskip = info->dst_skip;
2365  Uint32 ckey = info->colorkey;
2366  SDL_PixelFormat *srcfmt = info->src_fmt;
2367  SDL_PixelFormat *dstfmt = info->dst_fmt;
2368  int srcbpp = srcfmt->BytesPerPixel;
2369  int dstbpp = dstfmt->BytesPerPixel;
2370  unsigned alpha = dstfmt->Amask ? info->a : 0;
2371  Uint32 rgbmask = ~srcfmt->Amask;
2372 
2373  /* Set up some basic variables */
2374  ckey &= rgbmask;
2375 
2376  /* Fastpath: same source/destination format, no Amask, bpp 32, loop is vectorized. ~10x faster */
2377  if (srcfmt->format == dstfmt->format &&
2378  (srcfmt->format == SDL_PIXELFORMAT_RGB888 || srcfmt->format == SDL_PIXELFORMAT_BGR888)) {
2379  Uint32 *src32 = (Uint32*)src;
2380  Uint32 *dst32 = (Uint32*)dst;
2381  srcskip /= sizeof(Uint32);
2382  dstskip /= sizeof(Uint32);
2383  while (height--) {
2384  /* *INDENT-OFF* */
2385  DUFFS_LOOP(
2386  {
2387  if (*src32 != ckey) {
2388  *dst32 = *src32;
2389  }
2390  ++src32;
2391  ++dst32;
2392  },
2393  width);
2394  /* *INDENT-ON* */
2395  src32 += srcskip;
2396  dst32 += dstskip;
2397  }
2398  return;
2399  }
2400 
2401  while (height--) {
2402  /* *INDENT-OFF* */
2403  DUFFS_LOOP(
2404  {
2405  Uint32 Pixel;
2406  unsigned sR;
2407  unsigned sG;
2408  unsigned sB;
2409  RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
2410  if ( (Pixel & rgbmask) != ckey ) {
2411  RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB);
2412  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha);
2413  }
2414  dst += dstbpp;
2415  src += srcbpp;
2416  },
2417  width);
2418  /* *INDENT-ON* */
2419  src += srcskip;
2420  dst += dstskip;
2421  }
2422 }
int src_skip
Definition: SDL_blit.h:60
#define RETRIEVE_RGB_PIXEL(buf, bpp, Pixel)
Definition: SDL_blit.h:146
GLenum GLenum dst
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a)
Definition: SDL_blit.h:402
int dst_skip
Definition: SDL_blit.h:64
GLenum src
GLfloat GLfloat GLfloat alpha
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint32 colorkey
Definition: SDL_blit.h:69
Uint8 * dst
Definition: SDL_blit.h:61
uint8_t Uint8
Definition: SDL_stdinc.h:179
#define RGB_FROM_PIXEL(Pixel, fmt, r, g, b)
Definition: SDL_blit.h:122
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:500
Uint8 * src
Definition: SDL_blit.h:57
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:203
Uint8 a
Definition: SDL_blit.h:70

◆ BlitNtoNKeyCopyAlpha()

static void BlitNtoNKeyCopyAlpha ( SDL_BlitInfo info)
static

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

2426 {
2427  int width = info->dst_w;
2428  int height = info->dst_h;
2429  Uint8 *src = info->src;
2430  int srcskip = info->src_skip;
2431  Uint8 *dst = info->dst;
2432  int dstskip = info->dst_skip;
2433  Uint32 ckey = info->colorkey;
2434  SDL_PixelFormat *srcfmt = info->src_fmt;
2435  SDL_PixelFormat *dstfmt = info->dst_fmt;
2436  Uint32 rgbmask = ~srcfmt->Amask;
2437 
2438  Uint8 srcbpp;
2439  Uint8 dstbpp;
2440  Uint32 Pixel;
2441  unsigned sR, sG, sB, sA;
2442 
2443  /* Set up some basic variables */
2444  srcbpp = srcfmt->BytesPerPixel;
2445  dstbpp = dstfmt->BytesPerPixel;
2446  ckey &= rgbmask;
2447 
2448  /* Fastpath: same source/destination format, with Amask, bpp 32, loop is vectorized. ~10x faster */
2449  if (srcfmt->format == dstfmt->format &&
2450  (srcfmt->format == SDL_PIXELFORMAT_ARGB8888 ||
2451  srcfmt->format == SDL_PIXELFORMAT_ABGR8888 ||
2452  srcfmt->format == SDL_PIXELFORMAT_BGRA8888 ||
2453  srcfmt->format == SDL_PIXELFORMAT_RGBA8888)) {
2454  Uint32 *src32 = (Uint32*)src;
2455  Uint32 *dst32 = (Uint32*)dst;
2456  srcskip /= sizeof(Uint32);
2457  dstskip /= sizeof(Uint32);
2458  while (height--) {
2459  /* *INDENT-OFF* */
2460  DUFFS_LOOP(
2461  {
2462  if ((*src32 & rgbmask) != ckey) {
2463  *dst32 = *src32;
2464  }
2465  ++src32;
2466  ++dst32;
2467  },
2468  width);
2469  /* *INDENT-ON* */
2470  src32 += srcskip;
2471  dst32 += dstskip;
2472  }
2473  return;
2474  }
2475 
2476  while (height--) {
2477  /* *INDENT-OFF* */
2478  DUFFS_LOOP(
2479  {
2480  DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
2481  if ( (Pixel & rgbmask) != ckey ) {
2482  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, sA);
2483  }
2484  dst += dstbpp;
2485  src += srcbpp;
2486  },
2487  width);
2488  /* *INDENT-ON* */
2489  src += srcskip;
2490  dst += dstskip;
2491  }
2492 }
int src_skip
Definition: SDL_blit.h:60
GLenum GLenum dst
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a)
Definition: SDL_blit.h:402
int dst_skip
Definition: SDL_blit.h:64
GLenum src
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
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:353
uint8_t Uint8
Definition: SDL_stdinc.h:179
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:500
Uint8 * src
Definition: SDL_blit.h:57
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:203

◆ SDL_CalculateBlitN()

SDL_BlitFunc SDL_CalculateBlitN ( SDL_Surface surface)

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

2639 {
2640  SDL_PixelFormat *srcfmt;
2641  SDL_PixelFormat *dstfmt;
2642  const struct blit_table *table;
2643  int which;
2644  SDL_BlitFunc blitfun;
2645 
2646  /* Set up data for choosing the blit */
2647  srcfmt = surface->format;
2648  dstfmt = surface->map->dst->format;
2649 
2650  /* We don't support destinations less than 8-bits */
2651  if (dstfmt->BitsPerPixel < 8) {
2652  return (NULL);
2653  }
2654 
2655  switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
2656  case 0:
2657  blitfun = NULL;
2658  if (dstfmt->BitsPerPixel == 8) {
2659  if ((srcfmt->BytesPerPixel == 4) &&
2660  (srcfmt->Rmask == 0x00FF0000) &&
2661  (srcfmt->Gmask == 0x0000FF00) &&
2662  (srcfmt->Bmask == 0x000000FF)) {
2663  blitfun = Blit_RGB888_index8;
2664  } else if ((srcfmt->BytesPerPixel == 4) &&
2665  (srcfmt->Rmask == 0x3FF00000) &&
2666  (srcfmt->Gmask == 0x000FFC00) &&
2667  (srcfmt->Bmask == 0x000003FF)) {
2668  blitfun = Blit_RGB101010_index8;
2669  } else {
2670  blitfun = BlitNto1;
2671  }
2672  } else {
2673  /* Now the meat, choose the blitter we want */
2674  int a_need = NO_ALPHA;
2675  if (dstfmt->Amask)
2676  a_need = srcfmt->Amask ? COPY_ALPHA : SET_ALPHA;
2677  table = normal_blit[srcfmt->BytesPerPixel - 1];
2678  for (which = 0; table[which].dstbpp; ++which) {
2679  if (MASKOK(srcfmt->Rmask, table[which].srcR) &&
2680  MASKOK(srcfmt->Gmask, table[which].srcG) &&
2681  MASKOK(srcfmt->Bmask, table[which].srcB) &&
2682  MASKOK(dstfmt->Rmask, table[which].dstR) &&
2683  MASKOK(dstfmt->Gmask, table[which].dstG) &&
2684  MASKOK(dstfmt->Bmask, table[which].dstB) &&
2685  dstfmt->BytesPerPixel == table[which].dstbpp &&
2686  (a_need & table[which].alpha) == a_need &&
2687  ((table[which].blit_features & GetBlitFeatures()) ==
2688  table[which].blit_features))
2689  break;
2690  }
2691  blitfun = table[which].blitfunc;
2692 
2693  if (blitfun == BlitNtoN) { /* default C fallback catch-all. Slow! */
2694  if (srcfmt->format == SDL_PIXELFORMAT_ARGB2101010) {
2695  blitfun = Blit2101010toN;
2696  } else if (dstfmt->format == SDL_PIXELFORMAT_ARGB2101010) {
2697  blitfun = BlitNto2101010;
2698  } else if (srcfmt->BytesPerPixel == 4 &&
2699  dstfmt->BytesPerPixel == 4 &&
2700  srcfmt->Rmask == dstfmt->Rmask &&
2701  srcfmt->Gmask == dstfmt->Gmask &&
2702  srcfmt->Bmask == dstfmt->Bmask) {
2703  if (a_need == COPY_ALPHA) {
2704  if (srcfmt->Amask == dstfmt->Amask) {
2705  /* Fastpath C fallback: 32bit RGBA<->RGBA blit with matching RGBA */
2706  blitfun = Blit4to4CopyAlpha;
2707  } else {
2708  blitfun = BlitNtoNCopyAlpha;
2709  }
2710  } else {
2711  /* Fastpath C fallback: 32bit RGB<->RGBA blit with matching RGB */
2712  blitfun = Blit4to4MaskAlpha;
2713  }
2714  } else if (a_need == COPY_ALPHA) {
2715  blitfun = BlitNtoNCopyAlpha;
2716  }
2717  }
2718  }
2719  return (blitfun);
2720 
2721  case SDL_COPY_COLORKEY:
2722  /* colorkey blit: Here we don't have too many options, mostly
2723  because RLE is the preferred fast way to deal with this.
2724  If a particular case turns out to be useful we'll add it. */
2725 
2726  if (srcfmt->BytesPerPixel == 2 && surface->map->identity)
2727  return Blit2to2Key;
2728  else if (dstfmt->BytesPerPixel == 1)
2729  return BlitNto1Key;
2730  else {
2731 #if SDL_ALTIVEC_BLITTERS
2732  if ((srcfmt->BytesPerPixel == 4) && (dstfmt->BytesPerPixel == 4)
2733  && SDL_HasAltiVec()) {
2734  return Blit32to32KeyAltivec;
2735  } else
2736 #endif
2737  if (srcfmt->Amask && dstfmt->Amask) {
2738  return BlitNtoNKeyCopyAlpha;
2739  } else {
2740  return BlitNtoNKey;
2741  }
2742  }
2743  }
2744 
2745  return NULL;
2746 }
SDL_BlitFunc blitfunc
Definition: SDL_blit_N.c:2568
#define SDL_HasAltiVec
Uint32 srcG
Definition: SDL_blit_N.c:2564
Uint32 srcB
Definition: SDL_blit_N.c:2564
#define MASKOK(x, y)
Definition: SDL_blit_N.c:2635
GLenum GLsizei GLenum GLenum const void * table
#define SDL_COPY_COLORKEY
Definition: SDL_blit.h:39
Uint32 dstB
Definition: SDL_blit_N.c:2566
Uint32 dstR
Definition: SDL_blit_N.c:2566
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
#define NO_ALPHA
Definition: SDL_blit_N.c:2559
static void BlitNto2101010(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2528
#define SDL_COPY_RLE_MASK
Definition: SDL_blit.h:44
enum blit_features blit_features
Definition: SDL_blit_N.c:2567
Uint32 srcR
Definition: SDL_blit_N.c:2564
static void BlitNtoNCopyAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2228
struct SDL_BlitMap * map
Definition: SDL_surface.h:88
#define SET_ALPHA
Definition: SDL_blit_N.c:2560
Uint32 dstG
Definition: SDL_blit_N.c:2566
static void Blit2to2Key(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2323
Uint8 BitsPerPixel
Definition: SDL_pixels.h:319
static void Blit4to4MaskAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2117
static void BlitNto1Key(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2257
static void Blit_RGB888_index8(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:937
SDL_Surface * dst
Definition: SDL_blit.h:88
#define NULL
Definition: begin_code.h:164
SDL_PixelFormat * format
Definition: SDL_surface.h:72
static const struct blit_table *const normal_blit[]
Definition: SDL_blit_N.c:2630
static void BlitNtoNKey(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2357
#define COPY_ALPHA
Definition: SDL_blit_N.c:2561
static void Blit2101010toN(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2496
static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2425
#define GetBlitFeatures()
Definition: SDL_blit_N.c:886
void(* SDL_BlitFunc)(SDL_BlitInfo *info)
Definition: SDL_blit.h:73
Uint32 alpha
Definition: SDL_blit_N.c:2569
static void Blit_RGB101010_index8(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1047
blit_features
Definition: SDL_blit_N.c:32
static void Blit4to4CopyAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2167
static void BlitNtoN(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2193
int identity
Definition: SDL_blit.h:89
SDL_BlitInfo info
Definition: SDL_blit.h:92
static void BlitNto1(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2022

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:2576
static const struct blit_table normal_blit_3[]
Definition: SDL_blit_N.c:2601
static const struct blit_table normal_blit_1[]
Definition: SDL_blit_N.c:2571
static const struct blit_table normal_blit_4[]
Definition: SDL_blit_N.c:2606

Definition at line 2630 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:2193

Definition at line 2571 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}
}
#define NO_ALPHA
Definition: SDL_blit_N.c:2559
static void Blit_RGB565_ARGB8888(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1602
#define SET_ALPHA
Definition: SDL_blit_N.c:2560
static void Blit_RGB565_RGBA8888(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1878
static void Blit_RGB565_BGRA8888(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2016
#define COPY_ALPHA
Definition: SDL_blit_N.c:2561
static void BlitNtoN(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2193
static void Blit_RGB565_ABGR8888(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1740

Definition at line 2576 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:2193

Definition at line 2601 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}
}
#define NO_ALPHA
Definition: SDL_blit_N.c:2559
static void BlitNtoN(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2193
static void Blit_RGB888_RGB555(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1167
static void Blit_RGB888_RGB565(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1293

Definition at line 2606 of file SDL_blit_N.c.

◆ RGB565_ABGR8888_LUT

const Uint32 RGB565_ABGR8888_LUT[512]
static

Definition at line 1608 of file SDL_blit_N.c.

Referenced by Blit_RGB565_ABGR8888().

◆ RGB565_ARGB8888_LUT

const Uint32 RGB565_ARGB8888_LUT[512]
static

Definition at line 1470 of file SDL_blit_N.c.

Referenced by Blit_RGB565_ARGB8888().

◆ RGB565_BGRA8888_LUT

const Uint32 RGB565_BGRA8888_LUT[512]
static

Definition at line 1884 of file SDL_blit_N.c.

Referenced by Blit_RGB565_BGRA8888().

◆ RGB565_RGBA8888_LUT

const Uint32 RGB565_RGBA8888_LUT[512]
static

Definition at line 1746 of file SDL_blit_N.c.

Referenced by Blit_RGB565_RGBA8888().