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

Go to the source code of this file.

Macros

#define BLEND16_50(d, s, mask)   ((((s & mask) + (d & mask)) >> 1) + (s & d & (~mask & 0xffff)))
 
#define BLEND2x16_50(d, s, mask)
 

Functions

static void BlitNto1SurfaceAlpha (SDL_BlitInfo *info)
 
static void BlitNto1PixelAlpha (SDL_BlitInfo *info)
 
static void BlitNto1SurfaceAlphaKey (SDL_BlitInfo *info)
 
static void BlitRGBtoRGBSurfaceAlpha128 (SDL_BlitInfo *info)
 
static void BlitRGBtoRGBSurfaceAlpha (SDL_BlitInfo *info)
 
static void BlitRGBtoRGBPixelAlpha (SDL_BlitInfo *info)
 
static void Blit16to16SurfaceAlpha128 (SDL_BlitInfo *info, Uint16 mask)
 
static void Blit565to565SurfaceAlpha (SDL_BlitInfo *info)
 
static void Blit555to555SurfaceAlpha (SDL_BlitInfo *info)
 
static void BlitARGBto565PixelAlpha (SDL_BlitInfo *info)
 
static void BlitARGBto555PixelAlpha (SDL_BlitInfo *info)
 
static void BlitNtoNSurfaceAlpha (SDL_BlitInfo *info)
 
static void BlitNtoNSurfaceAlphaKey (SDL_BlitInfo *info)
 
static void BlitNtoNPixelAlpha (SDL_BlitInfo *info)
 
SDL_BlitFunc SDL_CalculateBlitA (SDL_Surface *surface)
 

Macro Definition Documentation

◆ BLEND16_50

#define BLEND16_50 (   d,
  s,
  mask 
)    ((((s & mask) + (d & mask)) >> 1) + (s & d & (~mask & 0xffff)))

Definition at line 652 of file SDL_blit_A.c.

Referenced by Blit16to16SurfaceAlpha128().

◆ BLEND2x16_50

#define BLEND2x16_50 (   d,
  s,
  mask 
)
Value:
(((s & (mask | mask << 16)) >> 1) + ((d & (mask | mask << 16)) >> 1) \
+ (s & d & (~(mask | mask << 16))))
GLdouble s
Definition: SDL_opengl.h:2063
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
GLenum GLint GLuint mask

Definition at line 656 of file SDL_blit_A.c.

Referenced by Blit16to16SurfaceAlpha128().

Function Documentation

◆ Blit16to16SurfaceAlpha128()

static void Blit16to16SurfaceAlpha128 ( SDL_BlitInfo info,
Uint16  mask 
)
static

Definition at line 661 of file SDL_blit_A.c.

References SDL_BlitInfo::a, BLEND16_50, BLEND2x16_50, d, SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP_124, SDL_BlitInfo::src, and SDL_BlitInfo::src_skip.

Referenced by Blit555to555SurfaceAlpha(), and Blit565to565SurfaceAlpha().

662 {
663  int width = info->dst_w;
664  int height = info->dst_h;
665  Uint16 *srcp = (Uint16 *) info->src;
666  int srcskip = info->src_skip >> 1;
667  Uint16 *dstp = (Uint16 *) info->dst;
668  int dstskip = info->dst_skip >> 1;
669 
670  while (height--) {
671  if (((uintptr_t) srcp ^ (uintptr_t) dstp) & 2) {
672  /*
673  * Source and destination not aligned, pipeline it.
674  * This is mostly a win for big blits but no loss for
675  * small ones
676  */
677  Uint32 prev_sw;
678  int w = width;
679 
680  /* handle odd destination */
681  if ((uintptr_t) dstp & 2) {
682  Uint16 d = *dstp, s = *srcp;
683  *dstp = BLEND16_50(d, s, mask);
684  dstp++;
685  srcp++;
686  w--;
687  }
688  srcp++; /* srcp is now 32-bit aligned */
689 
690  /* bootstrap pipeline with first halfword */
691  prev_sw = ((Uint32 *) srcp)[-1];
692 
693  while (w > 1) {
694  Uint32 sw, dw, s;
695  sw = *(Uint32 *) srcp;
696  dw = *(Uint32 *) dstp;
697 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
698  s = (prev_sw << 16) + (sw >> 16);
699 #else
700  s = (prev_sw >> 16) + (sw << 16);
701 #endif
702  prev_sw = sw;
703  *(Uint32 *) dstp = BLEND2x16_50(dw, s, mask);
704  dstp += 2;
705  srcp += 2;
706  w -= 2;
707  }
708 
709  /* final pixel if any */
710  if (w) {
711  Uint16 d = *dstp, s;
712 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
713  s = (Uint16) prev_sw;
714 #else
715  s = (Uint16) (prev_sw >> 16);
716 #endif
717  *dstp = BLEND16_50(d, s, mask);
718  srcp++;
719  dstp++;
720  }
721  srcp += srcskip - 1;
722  dstp += dstskip;
723  } else {
724  /* source and destination are aligned */
725  int w = width;
726 
727  /* first odd pixel? */
728  if ((uintptr_t) srcp & 2) {
729  Uint16 d = *dstp, s = *srcp;
730  *dstp = BLEND16_50(d, s, mask);
731  srcp++;
732  dstp++;
733  w--;
734  }
735  /* srcp and dstp are now 32-bit aligned */
736 
737  while (w > 1) {
738  Uint32 sw = *(Uint32 *) srcp;
739  Uint32 dw = *(Uint32 *) dstp;
740  *(Uint32 *) dstp = BLEND2x16_50(dw, sw, mask);
741  srcp += 2;
742  dstp += 2;
743  w -= 2;
744  }
745 
746  /* last odd pixel? */
747  if (w) {
748  Uint16 d = *dstp, s = *srcp;
749  *dstp = BLEND16_50(d, s, mask);
750  srcp++;
751  dstp++;
752  }
753  srcp += srcskip;
754  dstp += dstskip;
755  }
756  }
757 }
#define BLEND16_50(d, s, mask)
Definition: SDL_blit_A.c:652
GLdouble s
Definition: SDL_opengl.h:2063
int src_skip
Definition: SDL_blit.h:60
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
Uint8 * dst
Definition: SDL_blit.h:61
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
GLenum GLint GLuint mask
GLubyte GLubyte GLubyte GLubyte w
unsigned int uintptr_t
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 BLEND2x16_50(d, s, mask)
Definition: SDL_blit_A.c:656

◆ Blit555to555SurfaceAlpha()

static void Blit555to555SurfaceAlpha ( SDL_BlitInfo info)
static

Definition at line 1079 of file SDL_blit_A.c.

References SDL_BlitInfo::a, Blit16to16SurfaceAlpha128(), d, SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP4, SDL_BlitInfo::src, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitA().

1080 {
1081  unsigned alpha = info->a; /* downscale alpha to 5 bits */
1082  if (alpha == 128) {
1083  Blit16to16SurfaceAlpha128(info, 0xfbde);
1084  } else {
1085  int width = info->dst_w;
1086  int height = info->dst_h;
1087  Uint16 *srcp = (Uint16 *) info->src;
1088  int srcskip = info->src_skip >> 1;
1089  Uint16 *dstp = (Uint16 *) info->dst;
1090  int dstskip = info->dst_skip >> 1;
1091  alpha >>= 3; /* downscale alpha to 5 bits */
1092 
1093  while (height--) {
1094  /* *INDENT-OFF* */
1095  DUFFS_LOOP4({
1096  Uint32 s = *srcp++;
1097  Uint32 d = *dstp;
1098  /*
1099  * shift out the middle component (green) to
1100  * the high 16 bits, and process all three RGB
1101  * components at the same time.
1102  */
1103  s = (s | s << 16) & 0x03e07c1f;
1104  d = (d | d << 16) & 0x03e07c1f;
1105  d += (s - d) * alpha >> 5;
1106  d &= 0x03e07c1f;
1107  *dstp++ = (Uint16)(d | d >> 16);
1108  }, width);
1109  /* *INDENT-ON* */
1110  srcp += srcskip;
1111  dstp += dstskip;
1112  }
1113  }
1114 }
GLdouble s
Definition: SDL_opengl.h:2063
int src_skip
Definition: SDL_blit.h:60
uint16_t Uint16
Definition: SDL_stdinc.h:191
int dst_skip
Definition: SDL_blit.h:64
GLfloat GLfloat GLfloat alpha
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint8 * dst
Definition: SDL_blit.h:61
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
#define DUFFS_LOOP4(pixel_copy_increment, width)
Definition: SDL_blit.h:488
Uint8 * src
Definition: SDL_blit.h:57
static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask)
Definition: SDL_blit_A.c:661
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

◆ Blit565to565SurfaceAlpha()

static void Blit565to565SurfaceAlpha ( SDL_BlitInfo info)
static

Definition at line 1040 of file SDL_blit_A.c.

References SDL_BlitInfo::a, Blit16to16SurfaceAlpha128(), d, SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP4, SDL_BlitInfo::src, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitA().

1041 {
1042  unsigned alpha = info->a;
1043  if (alpha == 128) {
1044  Blit16to16SurfaceAlpha128(info, 0xf7de);
1045  } else {
1046  int width = info->dst_w;
1047  int height = info->dst_h;
1048  Uint16 *srcp = (Uint16 *) info->src;
1049  int srcskip = info->src_skip >> 1;
1050  Uint16 *dstp = (Uint16 *) info->dst;
1051  int dstskip = info->dst_skip >> 1;
1052  alpha >>= 3; /* downscale alpha to 5 bits */
1053 
1054  while (height--) {
1055  /* *INDENT-OFF* */
1056  DUFFS_LOOP4({
1057  Uint32 s = *srcp++;
1058  Uint32 d = *dstp;
1059  /*
1060  * shift out the middle component (green) to
1061  * the high 16 bits, and process all three RGB
1062  * components at the same time.
1063  */
1064  s = (s | s << 16) & 0x07e0f81f;
1065  d = (d | d << 16) & 0x07e0f81f;
1066  d += (s - d) * alpha >> 5;
1067  d &= 0x07e0f81f;
1068  *dstp++ = (Uint16)(d | d >> 16);
1069  }, width);
1070  /* *INDENT-ON* */
1071  srcp += srcskip;
1072  dstp += dstskip;
1073  }
1074  }
1075 }
GLdouble s
Definition: SDL_opengl.h:2063
int src_skip
Definition: SDL_blit.h:60
uint16_t Uint16
Definition: SDL_stdinc.h:191
int dst_skip
Definition: SDL_blit.h:64
GLfloat GLfloat GLfloat alpha
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint8 * dst
Definition: SDL_blit.h:61
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
#define DUFFS_LOOP4(pixel_copy_increment, width)
Definition: SDL_blit.h:488
Uint8 * src
Definition: SDL_blit.h:57
static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask)
Definition: SDL_blit_A.c:661
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

◆ BlitARGBto555PixelAlpha()

static void BlitARGBto555PixelAlpha ( SDL_BlitInfo info)
static

Definition at line 1164 of file SDL_blit_A.c.

References d, SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP4, SDL_ALPHA_OPAQUE, SDL_BlitInfo::src, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitA().

1165 {
1166  int width = info->dst_w;
1167  int height = info->dst_h;
1168  Uint32 *srcp = (Uint32 *) info->src;
1169  int srcskip = info->src_skip >> 2;
1170  Uint16 *dstp = (Uint16 *) info->dst;
1171  int dstskip = info->dst_skip >> 1;
1172 
1173  while (height--) {
1174  /* *INDENT-OFF* */
1175  DUFFS_LOOP4({
1176  unsigned alpha;
1177  Uint32 s = *srcp;
1178  alpha = s >> 27; /* downscale alpha to 5 bits */
1179  /* FIXME: Here we special-case opaque alpha since the
1180  compositioning used (>>8 instead of /255) doesn't handle
1181  it correctly. Also special-case alpha=0 for speed?
1182  Benchmark this! */
1183  if(alpha) {
1184  if(alpha == (SDL_ALPHA_OPAQUE >> 3)) {
1185  *dstp = (Uint16)((s >> 9 & 0x7c00) + (s >> 6 & 0x3e0) + (s >> 3 & 0x1f));
1186  } else {
1187  Uint32 d = *dstp;
1188  /*
1189  * convert source and destination to G0RAB65565
1190  * and blend all components at the same time
1191  */
1192  s = ((s & 0xf800) << 10) + (s >> 9 & 0x7c00)
1193  + (s >> 3 & 0x1f);
1194  d = (d | d << 16) & 0x03e07c1f;
1195  d += (s - d) * alpha >> 5;
1196  d &= 0x03e07c1f;
1197  *dstp = (Uint16)(d | d >> 16);
1198  }
1199  }
1200  srcp++;
1201  dstp++;
1202  }, width);
1203  /* *INDENT-ON* */
1204  srcp += srcskip;
1205  dstp += dstskip;
1206  }
1207 }
GLdouble s
Definition: SDL_opengl.h:2063
int src_skip
Definition: SDL_blit.h:60
uint16_t Uint16
Definition: SDL_stdinc.h:191
int dst_skip
Definition: SDL_blit.h:64
GLfloat GLfloat GLfloat alpha
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint8 * dst
Definition: SDL_blit.h:61
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
#define DUFFS_LOOP4(pixel_copy_increment, width)
Definition: SDL_blit.h:488
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 SDL_ALPHA_OPAQUE
Definition: SDL_pixels.h:46

◆ BlitARGBto565PixelAlpha()

static void BlitARGBto565PixelAlpha ( SDL_BlitInfo info)
static

Definition at line 1118 of file SDL_blit_A.c.

References d, SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP4, SDL_ALPHA_OPAQUE, SDL_BlitInfo::src, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitA().

1119 {
1120  int width = info->dst_w;
1121  int height = info->dst_h;
1122  Uint32 *srcp = (Uint32 *) info->src;
1123  int srcskip = info->src_skip >> 2;
1124  Uint16 *dstp = (Uint16 *) info->dst;
1125  int dstskip = info->dst_skip >> 1;
1126 
1127  while (height--) {
1128  /* *INDENT-OFF* */
1129  DUFFS_LOOP4({
1130  Uint32 s = *srcp;
1131  unsigned alpha = s >> 27; /* downscale alpha to 5 bits */
1132  /* FIXME: Here we special-case opaque alpha since the
1133  compositioning used (>>8 instead of /255) doesn't handle
1134  it correctly. Also special-case alpha=0 for speed?
1135  Benchmark this! */
1136  if(alpha) {
1137  if(alpha == (SDL_ALPHA_OPAQUE >> 3)) {
1138  *dstp = (Uint16)((s >> 8 & 0xf800) + (s >> 5 & 0x7e0) + (s >> 3 & 0x1f));
1139  } else {
1140  Uint32 d = *dstp;
1141  /*
1142  * convert source and destination to G0RAB65565
1143  * and blend all components at the same time
1144  */
1145  s = ((s & 0xfc00) << 11) + (s >> 8 & 0xf800)
1146  + (s >> 3 & 0x1f);
1147  d = (d | d << 16) & 0x07e0f81f;
1148  d += (s - d) * alpha >> 5;
1149  d &= 0x07e0f81f;
1150  *dstp = (Uint16)(d | d >> 16);
1151  }
1152  }
1153  srcp++;
1154  dstp++;
1155  }, width);
1156  /* *INDENT-ON* */
1157  srcp += srcskip;
1158  dstp += dstskip;
1159  }
1160 }
GLdouble s
Definition: SDL_opengl.h:2063
int src_skip
Definition: SDL_blit.h:60
uint16_t Uint16
Definition: SDL_stdinc.h:191
int dst_skip
Definition: SDL_blit.h:64
GLfloat GLfloat GLfloat alpha
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint8 * dst
Definition: SDL_blit.h:61
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
#define DUFFS_LOOP4(pixel_copy_increment, width)
Definition: SDL_blit.h:488
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 SDL_ALPHA_OPAQUE
Definition: SDL_pixels.h:46

◆ BlitNto1PixelAlpha()

static void BlitNto1PixelAlpha ( SDL_BlitInfo info)
static

Definition at line 77 of file SDL_blit_A.c.

References ALPHA_BLEND_RGB, SDL_Color::b, SDL_PixelFormat::BytesPerPixel, SDL_Palette::colors, DISEMBLE_RGBA, SDL_BlitInfo::dst, SDL_BlitInfo::dst_fmt, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP4, SDL_Color::g, NULL, SDL_PixelFormat::palette, SDL_Color::r, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, SDL_BlitInfo::src_skip, and SDL_BlitInfo::table.

Referenced by SDL_CalculateBlitA().

78 {
79  int width = info->dst_w;
80  int height = info->dst_h;
81  Uint8 *src = info->src;
82  int srcskip = info->src_skip;
83  Uint8 *dst = info->dst;
84  int dstskip = info->dst_skip;
85  Uint8 *palmap = info->table;
86  SDL_PixelFormat *srcfmt = info->src_fmt;
87  SDL_PixelFormat *dstfmt = info->dst_fmt;
88  int srcbpp = srcfmt->BytesPerPixel;
89  Uint32 Pixel;
90  unsigned sR, sG, sB, sA;
91  unsigned dR, dG, dB;
92 
93  while (height--) {
94  /* *INDENT-OFF* */
96  {
97  DISEMBLE_RGBA(src,srcbpp,srcfmt,Pixel,sR,sG,sB,sA);
98  dR = dstfmt->palette->colors[*dst].r;
99  dG = dstfmt->palette->colors[*dst].g;
100  dB = dstfmt->palette->colors[*dst].b;
101  ALPHA_BLEND_RGB(sR, sG, sB, sA, dR, dG, dB);
102  dR &= 0xff;
103  dG &= 0xff;
104  dB &= 0xff;
105  /* Pack RGB into 8bit pixel */
106  if ( palmap == NULL ) {
107  *dst =((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0));
108  } else {
109  *dst = palmap[((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))];
110  }
111  dst++;
112  src += srcbpp;
113  },
114  width);
115  /* *INDENT-ON* */
116  src += srcskip;
117  dst += dstskip;
118  }
119 }
Uint8 * table
Definition: SDL_blit.h:67
int src_skip
Definition: SDL_blit.h:60
Uint8 g
Definition: SDL_pixels.h:298
GLenum GLenum dst
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
#define ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB)
Definition: SDL_blit.h:445
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
Uint8 b
Definition: SDL_pixels.h:299
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 r
Definition: SDL_pixels.h:297
uint8_t Uint8
Definition: SDL_stdinc.h:179
#define DUFFS_LOOP4(pixel_copy_increment, width)
Definition: SDL_blit.h:488
Uint8 * src
Definition: SDL_blit.h:57
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
#define NULL
Definition: begin_code.h:164
SDL_Color * colors
Definition: SDL_pixels.h:307
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:203
SDL_Palette * palette
Definition: SDL_pixels.h:318

◆ BlitNto1SurfaceAlpha()

static void BlitNto1SurfaceAlpha ( SDL_BlitInfo info)
static

Definition at line 30 of file SDL_blit_A.c.

References SDL_BlitInfo::a, ALPHA_BLEND_RGB, SDL_Color::b, SDL_PixelFormat::BytesPerPixel, SDL_Palette::colors, DISEMBLE_RGB, SDL_BlitInfo::dst, SDL_BlitInfo::dst_fmt, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP4, SDL_Color::g, NULL, SDL_PixelFormat::palette, SDL_Color::r, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, SDL_BlitInfo::src_skip, and SDL_BlitInfo::table.

Referenced by SDL_CalculateBlitA().

31 {
32  int width = info->dst_w;
33  int height = info->dst_h;
34  Uint8 *src = info->src;
35  int srcskip = info->src_skip;
36  Uint8 *dst = info->dst;
37  int dstskip = info->dst_skip;
38  Uint8 *palmap = info->table;
39  SDL_PixelFormat *srcfmt = info->src_fmt;
40  SDL_PixelFormat *dstfmt = info->dst_fmt;
41  int srcbpp = srcfmt->BytesPerPixel;
42  Uint32 Pixel;
43  unsigned sR, sG, sB;
44  unsigned dR, dG, dB;
45  const unsigned A = info->a;
46 
47  while (height--) {
48  /* *INDENT-OFF* */
50  {
51  DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
52  dR = dstfmt->palette->colors[*dst].r;
53  dG = dstfmt->palette->colors[*dst].g;
54  dB = dstfmt->palette->colors[*dst].b;
55  ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB);
56  dR &= 0xff;
57  dG &= 0xff;
58  dB &= 0xff;
59  /* Pack RGB into 8bit pixel */
60  if ( palmap == NULL ) {
61  *dst =((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0));
62  } else {
63  *dst = palmap[((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))];
64  }
65  dst++;
66  src += srcbpp;
67  },
68  width);
69  /* *INDENT-ON* */
70  src += srcskip;
71  dst += dstskip;
72  }
73 }
Uint8 * table
Definition: SDL_blit.h:67
int src_skip
Definition: SDL_blit.h:60
Uint8 g
Definition: SDL_pixels.h:298
GLenum GLenum dst
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
#define ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB)
Definition: SDL_blit.h:445
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
Uint8 b
Definition: SDL_pixels.h:299
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 r
Definition: SDL_pixels.h:297
uint8_t Uint8
Definition: SDL_stdinc.h:179
#define DUFFS_LOOP4(pixel_copy_increment, width)
Definition: SDL_blit.h:488
Uint8 * src
Definition: SDL_blit.h:57
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
#define NULL
Definition: begin_code.h:164
SDL_Color * colors
Definition: SDL_pixels.h:307
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
SDL_Palette * palette
Definition: SDL_pixels.h:318
Uint8 a
Definition: SDL_blit.h:70

◆ BlitNto1SurfaceAlphaKey()

static void BlitNto1SurfaceAlphaKey ( SDL_BlitInfo info)
static

Definition at line 123 of file SDL_blit_A.c.

References SDL_BlitInfo::a, ALPHA_BLEND_RGB, SDL_PixelFormat::Amask, SDL_PixelFormat::Ashift, SDL_Color::b, SDL_PixelFormat::Bmask, SDL_PixelFormat::Bshift, SDL_PixelFormat::BytesPerPixel, SDL_BlitInfo::colorkey, SDL_Palette::colors, d, DISEMBLE_RGB, SDL_BlitInfo::dst, SDL_BlitInfo::dst_fmt, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, DUFFS_LOOP4, SDL_Color::g, SDL_PixelFormat::Gmask, NULL, SDL_PixelFormat::palette, SDL_Color::r, SDL_PixelFormat::Rmask, SDL_PixelFormat::Rshift, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, SDL_BlitInfo::src_skip, and SDL_BlitInfo::table.

Referenced by SDL_CalculateBlitA().

124 {
125  int width = info->dst_w;
126  int height = info->dst_h;
127  Uint8 *src = info->src;
128  int srcskip = info->src_skip;
129  Uint8 *dst = info->dst;
130  int dstskip = info->dst_skip;
131  Uint8 *palmap = info->table;
132  SDL_PixelFormat *srcfmt = info->src_fmt;
133  SDL_PixelFormat *dstfmt = info->dst_fmt;
134  int srcbpp = srcfmt->BytesPerPixel;
135  Uint32 ckey = info->colorkey;
136  Uint32 Pixel;
137  unsigned sR, sG, sB;
138  unsigned dR, dG, dB;
139  const unsigned A = info->a;
140 
141  while (height--) {
142  /* *INDENT-OFF* */
143  DUFFS_LOOP(
144  {
145  DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
146  if ( Pixel != ckey ) {
147  dR = dstfmt->palette->colors[*dst].r;
148  dG = dstfmt->palette->colors[*dst].g;
149  dB = dstfmt->palette->colors[*dst].b;
150  ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB);
151  dR &= 0xff;
152  dG &= 0xff;
153  dB &= 0xff;
154  /* Pack RGB into 8bit pixel */
155  if ( palmap == NULL ) {
156  *dst =((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0));
157  } else {
158  *dst = palmap[((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))];
159  }
160  }
161  dst++;
162  src += srcbpp;
163  },
164  width);
165  /* *INDENT-ON* */
166  src += srcskip;
167  dst += dstskip;
168  }
169 }
Uint8 * table
Definition: SDL_blit.h:67
int src_skip
Definition: SDL_blit.h:60
Uint8 g
Definition: SDL_pixels.h:298
GLenum GLenum dst
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
#define ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB)
Definition: SDL_blit.h:445
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
Uint8 b
Definition: SDL_pixels.h:299
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 r
Definition: SDL_pixels.h:297
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
#define NULL
Definition: begin_code.h:164
SDL_Color * colors
Definition: SDL_pixels.h:307
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
SDL_Palette * palette
Definition: SDL_pixels.h:318
Uint8 a
Definition: SDL_blit.h:70

◆ BlitNtoNPixelAlpha()

static void BlitNtoNPixelAlpha ( SDL_BlitInfo info)
static

Definition at line 1291 of file SDL_blit_A.c.

References ALPHA_BLEND_RGBA, 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, DUFFS_LOOP4, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitA().

1292 {
1293  int width = info->dst_w;
1294  int height = info->dst_h;
1295  Uint8 *src = info->src;
1296  int srcskip = info->src_skip;
1297  Uint8 *dst = info->dst;
1298  int dstskip = info->dst_skip;
1299  SDL_PixelFormat *srcfmt = info->src_fmt;
1300  SDL_PixelFormat *dstfmt = info->dst_fmt;
1301  int srcbpp;
1302  int dstbpp;
1303  Uint32 Pixel;
1304  unsigned sR, sG, sB, sA;
1305  unsigned dR, dG, dB, dA;
1306 
1307  /* Set up some basic variables */
1308  srcbpp = srcfmt->BytesPerPixel;
1309  dstbpp = dstfmt->BytesPerPixel;
1310 
1311  while (height--) {
1312  /* *INDENT-OFF* */
1313  DUFFS_LOOP4(
1314  {
1315  DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
1316  if(sA) {
1317  DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA);
1318  ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA);
1319  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
1320  }
1321  src += srcbpp;
1322  dst += dstbpp;
1323  },
1324  width);
1325  /* *INDENT-ON* */
1326  src += srcskip;
1327  dst += dstskip;
1328  }
1329 }
int src_skip
Definition: SDL_blit.h:60
GLenum GLenum dst
#define ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA)
Definition: SDL_blit.h:454
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
#define DUFFS_LOOP4(pixel_copy_increment, width)
Definition: SDL_blit.h:488
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

◆ BlitNtoNSurfaceAlpha()

static void BlitNtoNSurfaceAlpha ( SDL_BlitInfo info)
static

Definition at line 1211 of file SDL_blit_A.c.

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

Referenced by SDL_CalculateBlitA().

1212 {
1213  int width = info->dst_w;
1214  int height = info->dst_h;
1215  Uint8 *src = info->src;
1216  int srcskip = info->src_skip;
1217  Uint8 *dst = info->dst;
1218  int dstskip = info->dst_skip;
1219  SDL_PixelFormat *srcfmt = info->src_fmt;
1220  SDL_PixelFormat *dstfmt = info->dst_fmt;
1221  int srcbpp = srcfmt->BytesPerPixel;
1222  int dstbpp = dstfmt->BytesPerPixel;
1223  Uint32 Pixel;
1224  unsigned sR, sG, sB;
1225  unsigned dR, dG, dB, dA;
1226  const unsigned sA = info->a;
1227 
1228  if (sA) {
1229  while (height--) {
1230  /* *INDENT-OFF* */
1231  DUFFS_LOOP4(
1232  {
1233  DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
1234  DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA);
1235  ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA);
1236  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
1237  src += srcbpp;
1238  dst += dstbpp;
1239  },
1240  width);
1241  /* *INDENT-ON* */
1242  src += srcskip;
1243  dst += dstskip;
1244  }
1245  }
1246 }
int src_skip
Definition: SDL_blit.h:60
GLenum GLenum dst
#define ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA)
Definition: SDL_blit.h:454
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
#define DUFFS_LOOP4(pixel_copy_increment, width)
Definition: SDL_blit.h:488
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

◆ BlitNtoNSurfaceAlphaKey()

static void BlitNtoNSurfaceAlphaKey ( SDL_BlitInfo info)
static

Definition at line 1250 of file SDL_blit_A.c.

References SDL_BlitInfo::a, ALPHA_BLEND_RGBA, 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_LOOP4, RETRIEVE_RGB_PIXEL, RGB_FROM_PIXEL, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitA().

1251 {
1252  int width = info->dst_w;
1253  int height = info->dst_h;
1254  Uint8 *src = info->src;
1255  int srcskip = info->src_skip;
1256  Uint8 *dst = info->dst;
1257  int dstskip = info->dst_skip;
1258  SDL_PixelFormat *srcfmt = info->src_fmt;
1259  SDL_PixelFormat *dstfmt = info->dst_fmt;
1260  Uint32 ckey = info->colorkey;
1261  int srcbpp = srcfmt->BytesPerPixel;
1262  int dstbpp = dstfmt->BytesPerPixel;
1263  Uint32 Pixel;
1264  unsigned sR, sG, sB;
1265  unsigned dR, dG, dB, dA;
1266  const unsigned sA = info->a;
1267 
1268  while (height--) {
1269  /* *INDENT-OFF* */
1270  DUFFS_LOOP4(
1271  {
1272  RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
1273  if(sA && Pixel != ckey) {
1274  RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB);
1275  DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA);
1276  ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA);
1277  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
1278  }
1279  src += srcbpp;
1280  dst += dstbpp;
1281  },
1282  width);
1283  /* *INDENT-ON* */
1284  src += srcskip;
1285  dst += dstskip;
1286  }
1287 }
int src_skip
Definition: SDL_blit.h:60
#define RETRIEVE_RGB_PIXEL(buf, bpp, Pixel)
Definition: SDL_blit.h:146
GLenum GLenum dst
#define ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA)
Definition: SDL_blit.h:454
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 RGB_FROM_PIXEL(Pixel, fmt, r, g, b)
Definition: SDL_blit.h:122
#define DUFFS_LOOP4(pixel_copy_increment, width)
Definition: SDL_blit.h:488
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

◆ BlitRGBtoRGBPixelAlpha()

static void BlitRGBtoRGBPixelAlpha ( SDL_BlitInfo info)
static

Definition at line 525 of file SDL_blit_A.c.

References SDL_PixelFormat::Amask, SDL_PixelFormat::Ashift, d, SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP4, SDL_ALPHA_OPAQUE, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitA().

526 {
527  int width = info->dst_w;
528  int height = info->dst_h;
529  Uint32 *srcp = (Uint32 *) info->src;
530  int srcskip = info->src_skip >> 2;
531  Uint32 *dstp = (Uint32 *) info->dst;
532  int dstskip = info->dst_skip >> 2;
533 
534  while (height--) {
535  /* *INDENT-OFF* */
536  DUFFS_LOOP4({
537  Uint32 dalpha;
538  Uint32 d;
539  Uint32 s1;
540  Uint32 d1;
541  Uint32 s = *srcp;
542  Uint32 alpha = s >> 24;
543  /* FIXME: Here we special-case opaque alpha since the
544  compositioning used (>>8 instead of /255) doesn't handle
545  it correctly. Also special-case alpha=0 for speed?
546  Benchmark this! */
547  if (alpha) {
548  if (alpha == SDL_ALPHA_OPAQUE) {
549  *dstp = *srcp;
550  } else {
551  /*
552  * take out the middle component (green), and process
553  * the other two in parallel. One multiply less.
554  */
555  d = *dstp;
556  dalpha = d >> 24;
557  s1 = s & 0xff00ff;
558  d1 = d & 0xff00ff;
559  d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff;
560  s &= 0xff00;
561  d &= 0xff00;
562  d = (d + ((s - d) * alpha >> 8)) & 0xff00;
563  dalpha = alpha + (dalpha * (alpha ^ 0xFF) >> 8);
564  *dstp = d1 | d | (dalpha << 24);
565  }
566  }
567  ++srcp;
568  ++dstp;
569  }, width);
570  /* *INDENT-ON* */
571  srcp += srcskip;
572  dstp += dstskip;
573  }
574 }
GLdouble s
Definition: SDL_opengl.h:2063
int src_skip
Definition: SDL_blit.h:60
int dst_skip
Definition: SDL_blit.h:64
GLfloat GLfloat GLfloat alpha
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint8 * dst
Definition: SDL_blit.h:61
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
#define DUFFS_LOOP4(pixel_copy_increment, width)
Definition: SDL_blit.h:488
Uint8 * src
Definition: SDL_blit.h:57
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:203
#define SDL_ALPHA_OPAQUE
Definition: SDL_pixels.h:46

◆ BlitRGBtoRGBSurfaceAlpha()

static void BlitRGBtoRGBSurfaceAlpha ( SDL_BlitInfo info)
static

Definition at line 483 of file SDL_blit_A.c.

References SDL_BlitInfo::a, BlitRGBtoRGBSurfaceAlpha128(), d, SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP4, SDL_BlitInfo::src, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitA().

484 {
485  unsigned alpha = info->a;
486  if (alpha == 128) {
488  } else {
489  int width = info->dst_w;
490  int height = info->dst_h;
491  Uint32 *srcp = (Uint32 *) info->src;
492  int srcskip = info->src_skip >> 2;
493  Uint32 *dstp = (Uint32 *) info->dst;
494  int dstskip = info->dst_skip >> 2;
495  Uint32 s;
496  Uint32 d;
497  Uint32 s1;
498  Uint32 d1;
499 
500  while (height--) {
501  /* *INDENT-OFF* */
502  DUFFS_LOOP4({
503  s = *srcp;
504  d = *dstp;
505  s1 = s & 0xff00ff;
506  d1 = d & 0xff00ff;
507  d1 = (d1 + ((s1 - d1) * alpha >> 8))
508  & 0xff00ff;
509  s &= 0xff00;
510  d &= 0xff00;
511  d = (d + ((s - d) * alpha >> 8)) & 0xff00;
512  *dstp = d1 | d | 0xff000000;
513  ++srcp;
514  ++dstp;
515  }, width);
516  /* *INDENT-ON* */
517  srcp += srcskip;
518  dstp += dstskip;
519  }
520  }
521 }
GLdouble s
Definition: SDL_opengl.h:2063
int src_skip
Definition: SDL_blit.h:60
int dst_skip
Definition: SDL_blit.h:64
GLfloat GLfloat GLfloat alpha
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint8 * dst
Definition: SDL_blit.h:61
static void BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:458
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
#define DUFFS_LOOP4(pixel_copy_increment, width)
Definition: SDL_blit.h:488
Uint8 * src
Definition: SDL_blit.h:57
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
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

◆ BlitRGBtoRGBSurfaceAlpha128()

static void BlitRGBtoRGBSurfaceAlpha128 ( SDL_BlitInfo info)
static

Definition at line 458 of file SDL_blit_A.c.

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

Referenced by BlitRGBtoRGBSurfaceAlpha().

459 {
460  int width = info->dst_w;
461  int height = info->dst_h;
462  Uint32 *srcp = (Uint32 *) info->src;
463  int srcskip = info->src_skip >> 2;
464  Uint32 *dstp = (Uint32 *) info->dst;
465  int dstskip = info->dst_skip >> 2;
466 
467  while (height--) {
468  /* *INDENT-OFF* */
469  DUFFS_LOOP4({
470  Uint32 s = *srcp++;
471  Uint32 d = *dstp;
472  *dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1)
473  + (s & d & 0x00010101)) | 0xff000000;
474  }, width);
475  /* *INDENT-ON* */
476  srcp += srcskip;
477  dstp += dstskip;
478  }
479 }
GLdouble s
Definition: SDL_opengl.h:2063
int src_skip
Definition: SDL_blit.h:60
int dst_skip
Definition: SDL_blit.h:64
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
Uint8 * dst
Definition: SDL_blit.h:61
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
#define DUFFS_LOOP4(pixel_copy_increment, width)
Definition: SDL_blit.h:488
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

◆ SDL_CalculateBlitA()

SDL_BlitFunc SDL_CalculateBlitA ( SDL_Surface surface)

Definition at line 1333 of file SDL_blit_A.c.

References SDL_PixelFormat::Aloss, SDL_PixelFormat::Amask, SDL_PixelFormat::Ashift, Blit555to555SurfaceAlpha(), Blit565to565SurfaceAlpha(), BlitARGBto555PixelAlpha(), BlitARGBto565PixelAlpha(), BlitNto1PixelAlpha(), BlitNto1SurfaceAlpha(), BlitNto1SurfaceAlphaKey(), BlitNtoNPixelAlpha(), BlitNtoNSurfaceAlpha(), BlitNtoNSurfaceAlphaKey(), BlitRGBtoRGBPixelAlpha(), BlitRGBtoRGBSurfaceAlpha(), SDL_PixelFormat::Bmask, SDL_PixelFormat::Bshift, SDL_PixelFormat::BytesPerPixel, SDL_BlitMap::dst, SDL_BlitInfo::flags, SDL_Surface::format, SDL_PixelFormat::Gmask, SDL_PixelFormat::Gshift, SDL_BlitMap::identity, SDL_BlitMap::info, SDL_Surface::map, NULL, SDL_PixelFormat::Rmask, SDL_PixelFormat::Rshift, SDL_COPY_BLEND, SDL_COPY_COLORKEY, SDL_COPY_MODULATE_ALPHA, SDL_COPY_RLE_MASK, SDL_Has3DNow, SDL_HasARMSIMD(), SDL_HasMMX, and SDL_HasNEON.

Referenced by SDL_CalculateBlit().

1334 {
1335  SDL_PixelFormat *sf = surface->format;
1336  SDL_PixelFormat *df = surface->map->dst->format;
1337 
1338  switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
1339  case SDL_COPY_BLEND:
1340  /* Per-pixel alpha blits */
1341  switch (df->BytesPerPixel) {
1342  case 1:
1343  return BlitNto1PixelAlpha;
1344 
1345  case 2:
1346 #if SDL_ARM_NEON_BLITTERS || SDL_ARM_SIMD_BLITTERS
1347  if (sf->BytesPerPixel == 4 && sf->Amask == 0xff000000
1348  && sf->Gmask == 0xff00 && df->Gmask == 0x7e0
1349  && ((sf->Rmask == 0xff && df->Rmask == 0x1f)
1350  || (sf->Bmask == 0xff && df->Bmask == 0x1f)))
1351  {
1352 #if SDL_ARM_NEON_BLITTERS
1353  if (SDL_HasNEON())
1354  return BlitARGBto565PixelAlphaARMNEON;
1355 #endif
1356 #if SDL_ARM_SIMD_BLITTERS
1357  if (SDL_HasARMSIMD())
1358  return BlitARGBto565PixelAlphaARMSIMD;
1359 #endif
1360  }
1361 #endif
1362  if (sf->BytesPerPixel == 4 && sf->Amask == 0xff000000
1363  && sf->Gmask == 0xff00
1364  && ((sf->Rmask == 0xff && df->Rmask == 0x1f)
1365  || (sf->Bmask == 0xff && df->Bmask == 0x1f))) {
1366  if (df->Gmask == 0x7e0)
1367  return BlitARGBto565PixelAlpha;
1368  else if (df->Gmask == 0x3e0)
1369  return BlitARGBto555PixelAlpha;
1370  }
1371  return BlitNtoNPixelAlpha;
1372 
1373  case 4:
1374  if (sf->Rmask == df->Rmask
1375  && sf->Gmask == df->Gmask
1376  && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) {
1377 #if defined(__MMX__) || defined(__3dNOW__)
1378  if (sf->Rshift % 8 == 0
1379  && sf->Gshift % 8 == 0
1380  && sf->Bshift % 8 == 0
1381  && sf->Ashift % 8 == 0 && sf->Aloss == 0) {
1382 #ifdef __3dNOW__
1383  if (SDL_Has3DNow())
1384  return BlitRGBtoRGBPixelAlphaMMX3DNOW;
1385 #endif
1386 #ifdef __MMX__
1387  if (SDL_HasMMX())
1388  return BlitRGBtoRGBPixelAlphaMMX;
1389 #endif
1390  }
1391 #endif /* __MMX__ || __3dNOW__ */
1392  if (sf->Amask == 0xff000000) {
1393 #if SDL_ARM_NEON_BLITTERS
1394  if (SDL_HasNEON())
1395  return BlitRGBtoRGBPixelAlphaARMNEON;
1396 #endif
1397 #if SDL_ARM_SIMD_BLITTERS
1398  if (SDL_HasARMSIMD())
1399  return BlitRGBtoRGBPixelAlphaARMSIMD;
1400 #endif
1401  return BlitRGBtoRGBPixelAlpha;
1402  }
1403  }
1404  return BlitNtoNPixelAlpha;
1405 
1406  case 3:
1407  default:
1408  break;
1409  }
1410  return BlitNtoNPixelAlpha;
1411 
1413  if (sf->Amask == 0) {
1414  /* Per-surface alpha blits */
1415  switch (df->BytesPerPixel) {
1416  case 1:
1417  return BlitNto1SurfaceAlpha;
1418 
1419  case 2:
1420  if (surface->map->identity) {
1421  if (df->Gmask == 0x7e0) {
1422 #ifdef __MMX__
1423  if (SDL_HasMMX())
1424  return Blit565to565SurfaceAlphaMMX;
1425  else
1426 #endif
1427  return Blit565to565SurfaceAlpha;
1428  } else if (df->Gmask == 0x3e0) {
1429 #ifdef __MMX__
1430  if (SDL_HasMMX())
1431  return Blit555to555SurfaceAlphaMMX;
1432  else
1433 #endif
1434  return Blit555to555SurfaceAlpha;
1435  }
1436  }
1437  return BlitNtoNSurfaceAlpha;
1438 
1439  case 4:
1440  if (sf->Rmask == df->Rmask
1441  && sf->Gmask == df->Gmask
1442  && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) {
1443 #ifdef __MMX__
1444  if (sf->Rshift % 8 == 0
1445  && sf->Gshift % 8 == 0
1446  && sf->Bshift % 8 == 0 && SDL_HasMMX())
1447  return BlitRGBtoRGBSurfaceAlphaMMX;
1448 #endif
1449  if ((sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff) {
1450  return BlitRGBtoRGBSurfaceAlpha;
1451  }
1452  }
1453  return BlitNtoNSurfaceAlpha;
1454 
1455  case 3:
1456  default:
1457  return BlitNtoNSurfaceAlpha;
1458  }
1459  }
1460  break;
1461 
1463  if (sf->Amask == 0) {
1464  if (df->BytesPerPixel == 1) {
1465  return BlitNto1SurfaceAlphaKey;
1466  } else {
1467  return BlitNtoNSurfaceAlphaKey;
1468  }
1469  }
1470  break;
1471  }
1472 
1473  return NULL;
1474 }
static void BlitARGBto565PixelAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:1118
static void BlitNto1SurfaceAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:30
#define SDL_Has3DNow
static void BlitNtoNSurfaceAlphaKey(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:1250
#define SDL_COPY_COLORKEY
Definition: SDL_blit.h:39
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:123
#define SDL_COPY_RLE_MASK
Definition: SDL_blit.h:44
static void BlitARGBto555PixelAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:1164
static void BlitNtoNPixelAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:1291
struct SDL_BlitMap * map
Definition: SDL_surface.h:88
static void Blit555to555SurfaceAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:1079
static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:1040
#define SDL_HasNEON
static void BlitRGBtoRGBPixelAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:525
static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:483
#define SDL_HasMMX
SDL_Surface * dst
Definition: SDL_blit.h:88
#define NULL
Definition: begin_code.h:164
SDL_PixelFormat * format
Definition: SDL_surface.h:72
SDL_bool SDL_HasARMSIMD(void)
Definition: SDL_cpuinfo.c:777
#define SDL_COPY_MODULATE_ALPHA
Definition: SDL_blit.h:35
static void BlitNto1PixelAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:77
static void BlitNtoNSurfaceAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:1211
int identity
Definition: SDL_blit.h:89
#define SDL_COPY_BLEND
Definition: SDL_blit.h:36
SDL_BlitInfo info
Definition: SDL_blit.h:92