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 588 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 592 of file SDL_blit_A.c.

Referenced by Blit16to16SurfaceAlpha128().

Function Documentation

◆ Blit16to16SurfaceAlpha128()

static void Blit16to16SurfaceAlpha128 ( SDL_BlitInfo info,
Uint16  mask 
)
static

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

598 {
599  int width = info->dst_w;
600  int height = info->dst_h;
601  Uint16 *srcp = (Uint16 *) info->src;
602  int srcskip = info->src_skip >> 1;
603  Uint16 *dstp = (Uint16 *) info->dst;
604  int dstskip = info->dst_skip >> 1;
605 
606  while (height--) {
607  if (((uintptr_t) srcp ^ (uintptr_t) dstp) & 2) {
608  /*
609  * Source and destination not aligned, pipeline it.
610  * This is mostly a win for big blits but no loss for
611  * small ones
612  */
613  Uint32 prev_sw;
614  int w = width;
615 
616  /* handle odd destination */
617  if ((uintptr_t) dstp & 2) {
618  Uint16 d = *dstp, s = *srcp;
619  *dstp = BLEND16_50(d, s, mask);
620  dstp++;
621  srcp++;
622  w--;
623  }
624  srcp++; /* srcp is now 32-bit aligned */
625 
626  /* bootstrap pipeline with first halfword */
627  prev_sw = ((Uint32 *) srcp)[-1];
628 
629  while (w > 1) {
630  Uint32 sw, dw, s;
631  sw = *(Uint32 *) srcp;
632  dw = *(Uint32 *) dstp;
633 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
634  s = (prev_sw << 16) + (sw >> 16);
635 #else
636  s = (prev_sw >> 16) + (sw << 16);
637 #endif
638  prev_sw = sw;
639  *(Uint32 *) dstp = BLEND2x16_50(dw, s, mask);
640  dstp += 2;
641  srcp += 2;
642  w -= 2;
643  }
644 
645  /* final pixel if any */
646  if (w) {
647  Uint16 d = *dstp, s;
648 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
649  s = (Uint16) prev_sw;
650 #else
651  s = (Uint16) (prev_sw >> 16);
652 #endif
653  *dstp = BLEND16_50(d, s, mask);
654  srcp++;
655  dstp++;
656  }
657  srcp += srcskip - 1;
658  dstp += dstskip;
659  } else {
660  /* source and destination are aligned */
661  int w = width;
662 
663  /* first odd pixel? */
664  if ((uintptr_t) srcp & 2) {
665  Uint16 d = *dstp, s = *srcp;
666  *dstp = BLEND16_50(d, s, mask);
667  srcp++;
668  dstp++;
669  w--;
670  }
671  /* srcp and dstp are now 32-bit aligned */
672 
673  while (w > 1) {
674  Uint32 sw = *(Uint32 *) srcp;
675  Uint32 dw = *(Uint32 *) dstp;
676  *(Uint32 *) dstp = BLEND2x16_50(dw, sw, mask);
677  srcp += 2;
678  dstp += 2;
679  w -= 2;
680  }
681 
682  /* last odd pixel? */
683  if (w) {
684  Uint16 d = *dstp, s = *srcp;
685  *dstp = BLEND16_50(d, s, mask);
686  srcp++;
687  dstp++;
688  }
689  srcp += srcskip;
690  dstp += dstskip;
691  }
692  }
693 }
#define BLEND16_50(d, s, mask)
Definition: SDL_blit_A.c:588
GLdouble s
Definition: SDL_opengl.h:2063
int src_skip
Definition: SDL_blit.h:60
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
Definition: SDL_stdinc.h:181
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
uint16_t Uint16
Definition: SDL_stdinc.h:169
#define BLEND2x16_50(d, s, mask)
Definition: SDL_blit_A.c:592

◆ Blit555to555SurfaceAlpha()

static void Blit555to555SurfaceAlpha ( SDL_BlitInfo info)
static

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

1016 {
1017  unsigned alpha = info->a; /* downscale alpha to 5 bits */
1018  if (alpha == 128) {
1019  Blit16to16SurfaceAlpha128(info, 0xfbde);
1020  } else {
1021  int width = info->dst_w;
1022  int height = info->dst_h;
1023  Uint16 *srcp = (Uint16 *) info->src;
1024  int srcskip = info->src_skip >> 1;
1025  Uint16 *dstp = (Uint16 *) info->dst;
1026  int dstskip = info->dst_skip >> 1;
1027  alpha >>= 3; /* downscale alpha to 5 bits */
1028 
1029  while (height--) {
1030  /* *INDENT-OFF* */
1031  DUFFS_LOOP4({
1032  Uint32 s = *srcp++;
1033  Uint32 d = *dstp;
1034  /*
1035  * shift out the middle component (green) to
1036  * the high 16 bits, and process all three RGB
1037  * components at the same time.
1038  */
1039  s = (s | s << 16) & 0x03e07c1f;
1040  d = (d | d << 16) & 0x03e07c1f;
1041  d += (s - d) * alpha >> 5;
1042  d &= 0x03e07c1f;
1043  *dstp++ = (Uint16)(d | d >> 16);
1044  }, width);
1045  /* *INDENT-ON* */
1046  srcp += srcskip;
1047  dstp += dstskip;
1048  }
1049  }
1050 }
GLdouble s
Definition: SDL_opengl.h:2063
int src_skip
Definition: SDL_blit.h:60
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
Definition: SDL_stdinc.h:181
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:597
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint16_t Uint16
Definition: SDL_stdinc.h:169
Uint8 a
Definition: SDL_blit.h:70

◆ Blit565to565SurfaceAlpha()

static void Blit565to565SurfaceAlpha ( SDL_BlitInfo info)
static

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

977 {
978  unsigned alpha = info->a;
979  if (alpha == 128) {
980  Blit16to16SurfaceAlpha128(info, 0xf7de);
981  } else {
982  int width = info->dst_w;
983  int height = info->dst_h;
984  Uint16 *srcp = (Uint16 *) info->src;
985  int srcskip = info->src_skip >> 1;
986  Uint16 *dstp = (Uint16 *) info->dst;
987  int dstskip = info->dst_skip >> 1;
988  alpha >>= 3; /* downscale alpha to 5 bits */
989 
990  while (height--) {
991  /* *INDENT-OFF* */
992  DUFFS_LOOP4({
993  Uint32 s = *srcp++;
994  Uint32 d = *dstp;
995  /*
996  * shift out the middle component (green) to
997  * the high 16 bits, and process all three RGB
998  * components at the same time.
999  */
1000  s = (s | s << 16) & 0x07e0f81f;
1001  d = (d | d << 16) & 0x07e0f81f;
1002  d += (s - d) * alpha >> 5;
1003  d &= 0x07e0f81f;
1004  *dstp++ = (Uint16)(d | d >> 16);
1005  }, width);
1006  /* *INDENT-ON* */
1007  srcp += srcskip;
1008  dstp += dstskip;
1009  }
1010  }
1011 }
GLdouble s
Definition: SDL_opengl.h:2063
int src_skip
Definition: SDL_blit.h:60
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
Definition: SDL_stdinc.h:181
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:597
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint16_t Uint16
Definition: SDL_stdinc.h:169
Uint8 a
Definition: SDL_blit.h:70

◆ BlitARGBto555PixelAlpha()

static void BlitARGBto555PixelAlpha ( SDL_BlitInfo info)
static

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

1101 {
1102  int width = info->dst_w;
1103  int height = info->dst_h;
1104  Uint32 *srcp = (Uint32 *) info->src;
1105  int srcskip = info->src_skip >> 2;
1106  Uint16 *dstp = (Uint16 *) info->dst;
1107  int dstskip = info->dst_skip >> 1;
1108 
1109  while (height--) {
1110  /* *INDENT-OFF* */
1111  DUFFS_LOOP4({
1112  unsigned alpha;
1113  Uint32 s = *srcp;
1114  alpha = s >> 27; /* downscale alpha to 5 bits */
1115  /* FIXME: Here we special-case opaque alpha since the
1116  compositioning used (>>8 instead of /255) doesn't handle
1117  it correctly. Also special-case alpha=0 for speed?
1118  Benchmark this! */
1119  if(alpha) {
1120  if(alpha == (SDL_ALPHA_OPAQUE >> 3)) {
1121  *dstp = (Uint16)((s >> 9 & 0x7c00) + (s >> 6 & 0x3e0) + (s >> 3 & 0x1f));
1122  } else {
1123  Uint32 d = *dstp;
1124  /*
1125  * convert source and destination to G0RAB65565
1126  * and blend all components at the same time
1127  */
1128  s = ((s & 0xf800) << 10) + (s >> 9 & 0x7c00)
1129  + (s >> 3 & 0x1f);
1130  d = (d | d << 16) & 0x03e07c1f;
1131  d += (s - d) * alpha >> 5;
1132  d &= 0x03e07c1f;
1133  *dstp = (Uint16)(d | d >> 16);
1134  }
1135  }
1136  srcp++;
1137  dstp++;
1138  }, width);
1139  /* *INDENT-ON* */
1140  srcp += srcskip;
1141  dstp += dstskip;
1142  }
1143 }
GLdouble s
Definition: SDL_opengl.h:2063
int src_skip
Definition: SDL_blit.h:60
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
Definition: SDL_stdinc.h:181
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
uint16_t Uint16
Definition: SDL_stdinc.h:169
#define SDL_ALPHA_OPAQUE
Definition: SDL_pixels.h:46

◆ BlitARGBto565PixelAlpha()

static void BlitARGBto565PixelAlpha ( SDL_BlitInfo info)
static

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

1055 {
1056  int width = info->dst_w;
1057  int height = info->dst_h;
1058  Uint32 *srcp = (Uint32 *) info->src;
1059  int srcskip = info->src_skip >> 2;
1060  Uint16 *dstp = (Uint16 *) info->dst;
1061  int dstskip = info->dst_skip >> 1;
1062 
1063  while (height--) {
1064  /* *INDENT-OFF* */
1065  DUFFS_LOOP4({
1066  Uint32 s = *srcp;
1067  unsigned alpha = s >> 27; /* downscale alpha to 5 bits */
1068  /* FIXME: Here we special-case opaque alpha since the
1069  compositioning used (>>8 instead of /255) doesn't handle
1070  it correctly. Also special-case alpha=0 for speed?
1071  Benchmark this! */
1072  if(alpha) {
1073  if(alpha == (SDL_ALPHA_OPAQUE >> 3)) {
1074  *dstp = (Uint16)((s >> 8 & 0xf800) + (s >> 5 & 0x7e0) + (s >> 3 & 0x1f));
1075  } else {
1076  Uint32 d = *dstp;
1077  /*
1078  * convert source and destination to G0RAB65565
1079  * and blend all components at the same time
1080  */
1081  s = ((s & 0xfc00) << 11) + (s >> 8 & 0xf800)
1082  + (s >> 3 & 0x1f);
1083  d = (d | d << 16) & 0x07e0f81f;
1084  d += (s - d) * alpha >> 5;
1085  d &= 0x07e0f81f;
1086  *dstp = (Uint16)(d | d >> 16);
1087  }
1088  }
1089  srcp++;
1090  dstp++;
1091  }, width);
1092  /* *INDENT-ON* */
1093  srcp += srcskip;
1094  dstp += dstskip;
1095  }
1096 }
GLdouble s
Definition: SDL_opengl.h:2063
int src_skip
Definition: SDL_blit.h:60
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
Definition: SDL_stdinc.h:181
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
uint16_t Uint16
Definition: SDL_stdinc.h:169
#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
uint32_t Uint32
Definition: SDL_stdinc.h:181
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:157
#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
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
uint32_t Uint32
Definition: SDL_stdinc.h:181
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:157
#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
#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
uint32_t Uint32
Definition: SDL_stdinc.h:181
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:157
#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
#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 1227 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().

1228 {
1229  int width = info->dst_w;
1230  int height = info->dst_h;
1231  Uint8 *src = info->src;
1232  int srcskip = info->src_skip;
1233  Uint8 *dst = info->dst;
1234  int dstskip = info->dst_skip;
1235  SDL_PixelFormat *srcfmt = info->src_fmt;
1236  SDL_PixelFormat *dstfmt = info->dst_fmt;
1237  int srcbpp;
1238  int dstbpp;
1239  Uint32 Pixel;
1240  unsigned sR, sG, sB, sA;
1241  unsigned dR, dG, dB, dA;
1242 
1243  /* Set up some basic variables */
1244  srcbpp = srcfmt->BytesPerPixel;
1245  dstbpp = dstfmt->BytesPerPixel;
1246 
1247  while (height--) {
1248  /* *INDENT-OFF* */
1249  DUFFS_LOOP4(
1250  {
1251  DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
1252  if(sA) {
1253  DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA);
1254  ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA);
1255  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
1256  }
1257  src += srcbpp;
1258  dst += dstbpp;
1259  },
1260  width);
1261  /* *INDENT-ON* */
1262  src += srcskip;
1263  dst += dstskip;
1264  }
1265 }
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
uint32_t Uint32
Definition: SDL_stdinc.h:181
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:157
#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

◆ BlitNtoNSurfaceAlpha()

static void BlitNtoNSurfaceAlpha ( SDL_BlitInfo info)
static

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

1148 {
1149  int width = info->dst_w;
1150  int height = info->dst_h;
1151  Uint8 *src = info->src;
1152  int srcskip = info->src_skip;
1153  Uint8 *dst = info->dst;
1154  int dstskip = info->dst_skip;
1155  SDL_PixelFormat *srcfmt = info->src_fmt;
1156  SDL_PixelFormat *dstfmt = info->dst_fmt;
1157  int srcbpp = srcfmt->BytesPerPixel;
1158  int dstbpp = dstfmt->BytesPerPixel;
1159  Uint32 Pixel;
1160  unsigned sR, sG, sB;
1161  unsigned dR, dG, dB, dA;
1162  const unsigned sA = info->a;
1163 
1164  if (sA) {
1165  while (height--) {
1166  /* *INDENT-OFF* */
1167  DUFFS_LOOP4(
1168  {
1169  DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
1170  DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA);
1171  ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA);
1172  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
1173  src += srcbpp;
1174  dst += dstbpp;
1175  },
1176  width);
1177  /* *INDENT-ON* */
1178  src += srcskip;
1179  dst += dstskip;
1180  }
1181  }
1182 }
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
uint32_t Uint32
Definition: SDL_stdinc.h:181
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:157
#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
#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 1186 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().

1187 {
1188  int width = info->dst_w;
1189  int height = info->dst_h;
1190  Uint8 *src = info->src;
1191  int srcskip = info->src_skip;
1192  Uint8 *dst = info->dst;
1193  int dstskip = info->dst_skip;
1194  SDL_PixelFormat *srcfmt = info->src_fmt;
1195  SDL_PixelFormat *dstfmt = info->dst_fmt;
1196  Uint32 ckey = info->colorkey;
1197  int srcbpp = srcfmt->BytesPerPixel;
1198  int dstbpp = dstfmt->BytesPerPixel;
1199  Uint32 Pixel;
1200  unsigned sR, sG, sB;
1201  unsigned dR, dG, dB, dA;
1202  const unsigned sA = info->a;
1203 
1204  while (height--) {
1205  /* *INDENT-OFF* */
1206  DUFFS_LOOP4(
1207  {
1208  RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
1209  if(sA && Pixel != ckey) {
1210  RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB);
1211  DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA);
1212  ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA);
1213  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
1214  }
1215  src += srcbpp;
1216  dst += dstbpp;
1217  },
1218  width);
1219  /* *INDENT-ON* */
1220  src += srcskip;
1221  dst += dstskip;
1222  }
1223 }
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
uint32_t Uint32
Definition: SDL_stdinc.h:181
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:157
#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
Uint8 a
Definition: SDL_blit.h:70

◆ BlitRGBtoRGBPixelAlpha()

static void BlitRGBtoRGBPixelAlpha ( SDL_BlitInfo info)
static

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

462 {
463  int width = info->dst_w;
464  int height = info->dst_h;
465  Uint32 *srcp = (Uint32 *) info->src;
466  int srcskip = info->src_skip >> 2;
467  Uint32 *dstp = (Uint32 *) info->dst;
468  int dstskip = info->dst_skip >> 2;
469 
470  while (height--) {
471  /* *INDENT-OFF* */
472  DUFFS_LOOP4({
473  Uint32 dalpha;
474  Uint32 d;
475  Uint32 s1;
476  Uint32 d1;
477  Uint32 s = *srcp;
478  Uint32 alpha = s >> 24;
479  /* FIXME: Here we special-case opaque alpha since the
480  compositioning used (>>8 instead of /255) doesn't handle
481  it correctly. Also special-case alpha=0 for speed?
482  Benchmark this! */
483  if (alpha) {
484  if (alpha == SDL_ALPHA_OPAQUE) {
485  *dstp = *srcp;
486  } else {
487  /*
488  * take out the middle component (green), and process
489  * the other two in parallel. One multiply less.
490  */
491  d = *dstp;
492  dalpha = d >> 24;
493  s1 = s & 0xff00ff;
494  d1 = d & 0xff00ff;
495  d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff;
496  s &= 0xff00;
497  d &= 0xff00;
498  d = (d + ((s - d) * alpha >> 8)) & 0xff00;
499  dalpha = alpha + (dalpha * (alpha ^ 0xFF) >> 8);
500  *dstp = d1 | d | (dalpha << 24);
501  }
502  }
503  ++srcp;
504  ++dstp;
505  }, width);
506  /* *INDENT-ON* */
507  srcp += srcskip;
508  dstp += dstskip;
509  }
510 }
GLdouble s
Definition: SDL_opengl.h:2063
int src_skip
Definition: SDL_blit.h:60
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
Definition: SDL_stdinc.h:181
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
#define SDL_ALPHA_OPAQUE
Definition: SDL_pixels.h:46

◆ BlitRGBtoRGBSurfaceAlpha()

static void BlitRGBtoRGBSurfaceAlpha ( SDL_BlitInfo info)
static

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

420 {
421  unsigned alpha = info->a;
422  if (alpha == 128) {
424  } else {
425  int width = info->dst_w;
426  int height = info->dst_h;
427  Uint32 *srcp = (Uint32 *) info->src;
428  int srcskip = info->src_skip >> 2;
429  Uint32 *dstp = (Uint32 *) info->dst;
430  int dstskip = info->dst_skip >> 2;
431  Uint32 s;
432  Uint32 d;
433  Uint32 s1;
434  Uint32 d1;
435 
436  while (height--) {
437  /* *INDENT-OFF* */
438  DUFFS_LOOP4({
439  s = *srcp;
440  d = *dstp;
441  s1 = s & 0xff00ff;
442  d1 = d & 0xff00ff;
443  d1 = (d1 + ((s1 - d1) * alpha >> 8))
444  & 0xff00ff;
445  s &= 0xff00;
446  d &= 0xff00;
447  d = (d + ((s - d) * alpha >> 8)) & 0xff00;
448  *dstp = d1 | d | 0xff000000;
449  ++srcp;
450  ++dstp;
451  }, width);
452  /* *INDENT-ON* */
453  srcp += srcskip;
454  dstp += dstskip;
455  }
456  }
457 }
GLdouble s
Definition: SDL_opengl.h:2063
int src_skip
Definition: SDL_blit.h:60
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
Definition: SDL_stdinc.h:181
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:394
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
Uint8 a
Definition: SDL_blit.h:70

◆ BlitRGBtoRGBSurfaceAlpha128()

static void BlitRGBtoRGBSurfaceAlpha128 ( SDL_BlitInfo info)
static

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

395 {
396  int width = info->dst_w;
397  int height = info->dst_h;
398  Uint32 *srcp = (Uint32 *) info->src;
399  int srcskip = info->src_skip >> 2;
400  Uint32 *dstp = (Uint32 *) info->dst;
401  int dstskip = info->dst_skip >> 2;
402 
403  while (height--) {
404  /* *INDENT-OFF* */
405  DUFFS_LOOP4({
406  Uint32 s = *srcp++;
407  Uint32 d = *dstp;
408  *dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1)
409  + (s & d & 0x00010101)) | 0xff000000;
410  }, width);
411  /* *INDENT-ON* */
412  srcp += srcskip;
413  dstp += dstskip;
414  }
415 }
GLdouble s
Definition: SDL_opengl.h:2063
int src_skip
Definition: SDL_blit.h:60
int dst_skip
Definition: SDL_blit.h:64
uint32_t Uint32
Definition: SDL_stdinc.h:181
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

◆ SDL_CalculateBlitA()

SDL_BlitFunc SDL_CalculateBlitA ( SDL_Surface surface)

Definition at line 1269 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, and SDL_HasMMX.

Referenced by SDL_CalculateBlit().

1270 {
1271  SDL_PixelFormat *sf = surface->format;
1272  SDL_PixelFormat *df = surface->map->dst->format;
1273 
1274  switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
1275  case SDL_COPY_BLEND:
1276  /* Per-pixel alpha blits */
1277  switch (df->BytesPerPixel) {
1278  case 1:
1279  return BlitNto1PixelAlpha;
1280 
1281  case 2:
1282  if (sf->BytesPerPixel == 4 && sf->Amask == 0xff000000
1283  && sf->Gmask == 0xff00
1284  && ((sf->Rmask == 0xff && df->Rmask == 0x1f)
1285  || (sf->Bmask == 0xff && df->Bmask == 0x1f))) {
1286  if (df->Gmask == 0x7e0)
1287  return BlitARGBto565PixelAlpha;
1288  else if (df->Gmask == 0x3e0)
1289  return BlitARGBto555PixelAlpha;
1290  }
1291  return BlitNtoNPixelAlpha;
1292 
1293  case 4:
1294  if (sf->Rmask == df->Rmask
1295  && sf->Gmask == df->Gmask
1296  && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) {
1297 #if defined(__MMX__) || defined(__3dNOW__)
1298  if (sf->Rshift % 8 == 0
1299  && sf->Gshift % 8 == 0
1300  && sf->Bshift % 8 == 0
1301  && sf->Ashift % 8 == 0 && sf->Aloss == 0) {
1302 #ifdef __3dNOW__
1303  if (SDL_Has3DNow())
1304  return BlitRGBtoRGBPixelAlphaMMX3DNOW;
1305 #endif
1306 #ifdef __MMX__
1307  if (SDL_HasMMX())
1308  return BlitRGBtoRGBPixelAlphaMMX;
1309 #endif
1310  }
1311 #endif /* __MMX__ || __3dNOW__ */
1312  if (sf->Amask == 0xff000000) {
1313  return BlitRGBtoRGBPixelAlpha;
1314  }
1315  }
1316  return BlitNtoNPixelAlpha;
1317 
1318  case 3:
1319  default:
1320  break;
1321  }
1322  return BlitNtoNPixelAlpha;
1323 
1325  if (sf->Amask == 0) {
1326  /* Per-surface alpha blits */
1327  switch (df->BytesPerPixel) {
1328  case 1:
1329  return BlitNto1SurfaceAlpha;
1330 
1331  case 2:
1332  if (surface->map->identity) {
1333  if (df->Gmask == 0x7e0) {
1334 #ifdef __MMX__
1335  if (SDL_HasMMX())
1336  return Blit565to565SurfaceAlphaMMX;
1337  else
1338 #endif
1339  return Blit565to565SurfaceAlpha;
1340  } else if (df->Gmask == 0x3e0) {
1341 #ifdef __MMX__
1342  if (SDL_HasMMX())
1343  return Blit555to555SurfaceAlphaMMX;
1344  else
1345 #endif
1346  return Blit555to555SurfaceAlpha;
1347  }
1348  }
1349  return BlitNtoNSurfaceAlpha;
1350 
1351  case 4:
1352  if (sf->Rmask == df->Rmask
1353  && sf->Gmask == df->Gmask
1354  && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) {
1355 #ifdef __MMX__
1356  if (sf->Rshift % 8 == 0
1357  && sf->Gshift % 8 == 0
1358  && sf->Bshift % 8 == 0 && SDL_HasMMX())
1359  return BlitRGBtoRGBSurfaceAlphaMMX;
1360 #endif
1361  if ((sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff) {
1362  return BlitRGBtoRGBSurfaceAlpha;
1363  }
1364  }
1365  return BlitNtoNSurfaceAlpha;
1366 
1367  case 3:
1368  default:
1369  return BlitNtoNSurfaceAlpha;
1370  }
1371  }
1372  break;
1373 
1375  if (sf->Amask == 0) {
1376  if (df->BytesPerPixel == 1) {
1377  return BlitNto1SurfaceAlphaKey;
1378  } else {
1379  return BlitNtoNSurfaceAlphaKey;
1380  }
1381  }
1382  break;
1383  }
1384 
1385  return NULL;
1386 }
static void BlitARGBto565PixelAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:1054
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:1186
#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:1100
static void BlitNtoNPixelAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:1227
struct SDL_BlitMap * map
Definition: SDL_surface.h:88
static void Blit555to555SurfaceAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:1015
static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:976
static void BlitRGBtoRGBPixelAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:461
static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_A.c:419
#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
#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:1147
int identity
Definition: SDL_blit.h:89
#define SDL_COPY_BLEND
Definition: SDL_blit.h:36
SDL_BlitInfo info
Definition: SDL_blit.h:92