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

Functions

static void Blit_RGB888_index8 (SDL_BlitInfo *info)
 
static void Blit_RGB101010_index8 (SDL_BlitInfo *info)
 
static void Blit_RGB888_RGB555 (SDL_BlitInfo *info)
 
static void Blit_RGB888_RGB565 (SDL_BlitInfo *info)
 
static void Blit_RGB565_32 (SDL_BlitInfo *info, const Uint32 *map)
 
static void Blit_RGB565_ARGB8888 (SDL_BlitInfo *info)
 
static void Blit_RGB565_ABGR8888 (SDL_BlitInfo *info)
 
static void Blit_RGB565_RGBA8888 (SDL_BlitInfo *info)
 
static void Blit_RGB565_BGRA8888 (SDL_BlitInfo *info)
 
static void BlitNto1 (SDL_BlitInfo *info)
 
static void Blit4to4MaskAlpha (SDL_BlitInfo *info)
 
static void Blit4to4CopyAlpha (SDL_BlitInfo *info)
 
static void get_permutation (SDL_PixelFormat *srcfmt, SDL_PixelFormat *dstfmt, int *_p0, int *_p1, int *_p2, int *_p3, int *_alpha_channel)
 
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)
 
static void Blit_3or4_to_3or4__same_rgb (SDL_BlitInfo *info)
 
static void Blit_3or4_to_3or4__inversed_rgb (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 3142 of file SDL_blit_N.c.

◆ GetBlitFeatures

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

Definition at line 887 of file SDL_blit_N.c.

◆ HAVE_FAST_WRITE_INT8

#define HAVE_FAST_WRITE_INT8   1

Definition at line 31 of file SDL_blit_N.c.

◆ HI

#define HI   1

Definition at line 892 of file SDL_blit_N.c.

◆ LO

#define LO   0

Definition at line 893 of file SDL_blit_N.c.

◆ MASKOK

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

Definition at line 3263 of file SDL_blit_N.c.

◆ NO_ALPHA

#define NO_ALPHA   1

Definition at line 3140 of file SDL_blit_N.c.

◆ 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 1010 of file SDL_blit_N.c.

◆ RGB565_32

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

Definition at line 1373 of file SDL_blit_N.c.

◆ RGB888_RGB332

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

Definition at line 900 of file SDL_blit_N.c.

◆ 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

Definition at line 1120 of file SDL_blit_N.c.

◆ RGB888_RGB565

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

Definition at line 1246 of file SDL_blit_N.c.

◆ SET_ALPHA

#define SET_ALPHA   2

Definition at line 3141 of file SDL_blit_N.c.

Function Documentation

◆ Blit2101010toN()

static void Blit2101010toN ( SDL_BlitInfo info)
static

Definition at line 2897 of file SDL_blit_N.c.

2898{
2899 int width = info->dst_w;
2900 int height = info->dst_h;
2901 Uint8 *src = info->src;
2902 int srcskip = info->src_skip;
2903 Uint8 *dst = info->dst;
2904 int dstskip = info->dst_skip;
2905 SDL_PixelFormat *dstfmt = info->dst_fmt;
2906 int dstbpp = dstfmt->BytesPerPixel;
2907 Uint32 Pixel;
2908 unsigned sR, sG, sB, sA;
2909
2910 while (height--) {
2911 /* *INDENT-OFF* */
2912 DUFFS_LOOP(
2913 {
2914 Pixel = *(Uint32 *)src;
2915 RGBA_FROM_ARGB2101010(Pixel, sR, sG, sB, sA);
2916 ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, sA);
2917 dst += dstbpp;
2918 src += 4;
2919 },
2920 width);
2921 /* *INDENT-ON* */
2922 src += srcskip;
2923 dst += dstskip;
2924 }
2925}
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a)
Definition: SDL_blit.h:402
#define DUFFS_LOOP(pixel_copy_increment, width)
Definition: SDL_blit.h:500
#define RGBA_FROM_ARGB2101010(Pixel, r, g, b, a)
Definition: SDL_blit.h:346
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:203
int dst_skip
Definition: SDL_blit.h:64
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
int src_skip
Definition: SDL_blit.h:60
Uint8 * src
Definition: SDL_blit.h:57
Uint8 * dst
Definition: SDL_blit.h:61
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320

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

◆ Blit2to2Key()

static void Blit2to2Key ( SDL_BlitInfo info)
static

Definition at line 2487 of file SDL_blit_N.c.

2488{
2489 int width = info->dst_w;
2490 int height = info->dst_h;
2491 Uint16 *srcp = (Uint16 *) info->src;
2492 int srcskip = info->src_skip;
2493 Uint16 *dstp = (Uint16 *) info->dst;
2494 int dstskip = info->dst_skip;
2495 Uint32 ckey = info->colorkey;
2496 Uint32 rgbmask = ~info->src_fmt->Amask;
2497
2498 /* Set up some basic variables */
2499 srcskip /= 2;
2500 dstskip /= 2;
2501 ckey &= rgbmask;
2502
2503 while (height--) {
2504 /* *INDENT-OFF* */
2505 DUFFS_LOOP(
2506 {
2507 if ( (*srcp & rgbmask) != ckey ) {
2508 *dstp = *srcp;
2509 }
2510 dstp++;
2511 srcp++;
2512 },
2513 width);
2514 /* *INDENT-ON* */
2515 srcp += srcskip;
2516 dstp += dstskip;
2517 }
2518}
Uint32 colorkey
Definition: SDL_blit.h:69

References SDL_BlitInfo::colorkey, 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().

◆ Blit4to4CopyAlpha()

static void Blit4to4CopyAlpha ( SDL_BlitInfo info)
static

Definition at line 2136 of file SDL_blit_N.c.

2137{
2138 int width = info->dst_w;
2139 int height = info->dst_h;
2140 Uint32 *src = (Uint32 *) info->src;
2141 int srcskip = info->src_skip;
2142 Uint32 *dst = (Uint32 *) info->dst;
2143 int dstskip = info->dst_skip;
2144
2145 /* RGBA->RGBA, COPY_ALPHA */
2146 while (height--) {
2147 /* *INDENT-OFF* */
2148 DUFFS_LOOP(
2149 {
2150 *dst = *src;
2151 ++dst;
2152 ++src;
2153 },
2154 width);
2155 /* *INDENT-ON* */
2156 src = (Uint32 *) ((Uint8 *) src + srcskip);
2157 dst = (Uint32 *) ((Uint8 *) dst + dstskip);
2158 }
2159}

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

◆ Blit4to4MaskAlpha()

static void Blit4to4MaskAlpha ( SDL_BlitInfo info)
static

Definition at line 2086 of file SDL_blit_N.c.

2087{
2088 int width = info->dst_w;
2089 int height = info->dst_h;
2090 Uint32 *src = (Uint32 *) info->src;
2091 int srcskip = info->src_skip;
2092 Uint32 *dst = (Uint32 *) info->dst;
2093 int dstskip = info->dst_skip;
2094 SDL_PixelFormat *srcfmt = info->src_fmt;
2095 SDL_PixelFormat *dstfmt = info->dst_fmt;
2096
2097 if (dstfmt->Amask) {
2098 /* RGB->RGBA, SET_ALPHA */
2099 Uint32 mask = (info->a >> dstfmt->Aloss) << dstfmt->Ashift;
2100
2101 while (height--) {
2102 /* *INDENT-OFF* */
2103 DUFFS_LOOP(
2104 {
2105 *dst = *src | mask;
2106 ++dst;
2107 ++src;
2108 },
2109 width);
2110 /* *INDENT-ON* */
2111 src = (Uint32 *) ((Uint8 *) src + srcskip);
2112 dst = (Uint32 *) ((Uint8 *) dst + dstskip);
2113 }
2114 } else {
2115 /* RGBA->RGB, NO_ALPHA */
2116 Uint32 mask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
2117
2118 while (height--) {
2119 /* *INDENT-OFF* */
2120 DUFFS_LOOP(
2121 {
2122 *dst = *src & mask;
2123 ++dst;
2124 ++src;
2125 },
2126 width);
2127 /* *INDENT-ON* */
2128 src = (Uint32 *) ((Uint8 *) src + srcskip);
2129 dst = (Uint32 *) ((Uint8 *) dst + dstskip);
2130 }
2131 }
2132}
GLenum GLint GLuint mask
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
Uint8 a
Definition: SDL_blit.h:70

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

◆ Blit_3or4_to_3or4__inversed_rgb()

static void Blit_3or4_to_3or4__inversed_rgb ( SDL_BlitInfo info)
static

Definition at line 3036 of file SDL_blit_N.c.

3037{
3038 int width = info->dst_w;
3039 int height = info->dst_h;
3040 Uint8 *src = info->src;
3041 int srcskip = info->src_skip;
3042 Uint8 *dst = info->dst;
3043 int dstskip = info->dst_skip;
3044 SDL_PixelFormat *srcfmt = info->src_fmt;
3045 int srcbpp = srcfmt->BytesPerPixel;
3046 SDL_PixelFormat *dstfmt = info->dst_fmt;
3047 int dstbpp = dstfmt->BytesPerPixel;
3048
3049 if (dstfmt->Amask) {
3050 if (srcfmt->Amask) {
3051 /* COPY_ALPHA */
3052 /* Only to switch ABGR8888 <-> ARGB8888 */
3053 while (height--) {
3054#if SDL_BYTEORDER == SDL_LIL_ENDIAN
3055 int i0 = 0, i1 = 1, i2 = 2, i3 = 3;
3056#else
3057 int i0 = 3, i1 = 2, i2 = 1, i3 = 0;
3058#endif
3059 /* *INDENT-OFF* */
3060 DUFFS_LOOP(
3061 {
3062 Uint32 *dst32 = (Uint32*)dst;
3063 Uint8 s0 = src[i0];
3064 Uint8 s1 = src[i1];
3065 Uint8 s2 = src[i2];
3066 Uint32 alphashift = src[i3] << dstfmt->Ashift;
3067 /* inversed, compared to Blit_3or4_to_3or4__same_rgb */
3068 *dst32 = (s0 << 16) | (s1 << 8) | (s2) | alphashift;
3069 dst += 4;
3070 src += 4;
3071 }, width);
3072 /* *INDENT-ON* */
3073 src += srcskip;
3074 dst += dstskip;
3075 }
3076 } else {
3077 /* SET_ALPHA */
3078 Uint32 mask = info->a << dstfmt->Ashift;
3079#if SDL_BYTEORDER == SDL_LIL_ENDIAN
3080 int i0 = 0, i1 = 1, i2 = 2;
3081#else
3082 int i0 = srcbpp - 1 - 0;
3083 int i1 = srcbpp - 1 - 1;
3084 int i2 = srcbpp - 1 - 2;
3085#endif
3086 while (height--) {
3087 /* *INDENT-OFF* */
3088 DUFFS_LOOP(
3089 {
3090 Uint32 *dst32 = (Uint32*)dst;
3091 Uint8 s0 = src[i0];
3092 Uint8 s1 = src[i1];
3093 Uint8 s2 = src[i2];
3094 /* inversed, compared to Blit_3or4_to_3or4__same_rgb */
3095 *dst32 = (s0 << 16) | (s1 << 8) | (s2) | mask;
3096 dst += 4;
3097 src += srcbpp;
3098 }, width);
3099 /* *INDENT-ON* */
3100 src += srcskip;
3101 dst += dstskip;
3102 }
3103 }
3104 } else {
3105 /* NO_ALPHA */
3106#if SDL_BYTEORDER == SDL_LIL_ENDIAN
3107 int i0 = 0, i1 = 1, i2 = 2;
3108 int j0 = 2, j1 = 1, j2 = 0;
3109#else
3110 int i0 = srcbpp - 1 - 0;
3111 int i1 = srcbpp - 1 - 1;
3112 int i2 = srcbpp - 1 - 2;
3113 int j0 = dstbpp - 1 - 2;
3114 int j1 = dstbpp - 1 - 1;
3115 int j2 = dstbpp - 1 - 0;
3116#endif
3117 while (height--) {
3118 /* *INDENT-OFF* */
3119 DUFFS_LOOP(
3120 {
3121 Uint8 s0 = src[i0];
3122 Uint8 s1 = src[i1];
3123 Uint8 s2 = src[i2];
3124 /* inversed, compared to Blit_3or4_to_3or4__same_rgb */
3125 dst[j0] = s0;
3126 dst[j1] = s1;
3127 dst[j2] = s2;
3128 dst += dstbpp;
3129 src += srcbpp;
3130 }, width);
3131 /* *INDENT-ON* */
3132 src += srcskip;
3133 dst += dstskip;
3134 }
3135 }
3136 return;
3137}
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 i1
Definition: SDL_glfuncs.h:141
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 j1
Definition: SDL_glfuncs.h:141
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 i2
Definition: SDL_glfuncs.h:141
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s0

References SDL_BlitInfo::a, SDL_PixelFormat::Amask, SDL_PixelFormat::Ashift, SDL_PixelFormat::BytesPerPixel, SDL_BlitInfo::dst, SDL_BlitInfo::dst_fmt, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, i1, i2, j1, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, and SDL_BlitInfo::src_skip.

◆ Blit_3or4_to_3or4__same_rgb()

static void Blit_3or4_to_3or4__same_rgb ( SDL_BlitInfo info)
static

Definition at line 2961 of file SDL_blit_N.c.

2962{
2963 int width = info->dst_w;
2964 int height = info->dst_h;
2965 Uint8 *src = info->src;
2966 int srcskip = info->src_skip;
2967 Uint8 *dst = info->dst;
2968 int dstskip = info->dst_skip;
2969 SDL_PixelFormat *srcfmt = info->src_fmt;
2970 int srcbpp = srcfmt->BytesPerPixel;
2971 SDL_PixelFormat *dstfmt = info->dst_fmt;
2972 int dstbpp = dstfmt->BytesPerPixel;
2973
2974 if (dstfmt->Amask) {
2975 /* SET_ALPHA */
2976 Uint32 mask = info->a << dstfmt->Ashift;
2977#if SDL_BYTEORDER == SDL_LIL_ENDIAN
2978 int i0 = 0, i1 = 1, i2 = 2;
2979#else
2980 int i0 = srcbpp - 1 - 0;
2981 int i1 = srcbpp - 1 - 1;
2982 int i2 = srcbpp - 1 - 2;
2983#endif
2984 while (height--) {
2985 /* *INDENT-OFF* */
2986 DUFFS_LOOP(
2987 {
2988 Uint32 *dst32 = (Uint32*)dst;
2989 Uint8 s0 = src[i0];
2990 Uint8 s1 = src[i1];
2991 Uint8 s2 = src[i2];
2992 *dst32 = (s0) | (s1 << 8) | (s2 << 16) | mask;
2993 dst += 4;
2994 src += srcbpp;
2995 }, width);
2996 /* *INDENT-ON* */
2997 src += srcskip;
2998 dst += dstskip;
2999 }
3000 } else {
3001 /* NO_ALPHA */
3002#if SDL_BYTEORDER == SDL_LIL_ENDIAN
3003 int i0 = 0, i1 = 1, i2 = 2;
3004 int j0 = 0, j1 = 1, j2 = 2;
3005#else
3006 int i0 = srcbpp - 1 - 0;
3007 int i1 = srcbpp - 1 - 1;
3008 int i2 = srcbpp - 1 - 2;
3009 int j0 = dstbpp - 1 - 0;
3010 int j1 = dstbpp - 1 - 1;
3011 int j2 = dstbpp - 1 - 2;
3012#endif
3013 while (height--) {
3014 /* *INDENT-OFF* */
3015 DUFFS_LOOP(
3016 {
3017 Uint8 s0 = src[i0];
3018 Uint8 s1 = src[i1];
3019 Uint8 s2 = src[i2];
3020 dst[j0] = s0;
3021 dst[j1] = s1;
3022 dst[j2] = s2;
3023 dst += dstbpp;
3024 src += srcbpp;
3025 }, width);
3026 /* *INDENT-ON* */
3027 src += srcskip;
3028 dst += dstskip;
3029 }
3030 }
3031 return;
3032}

References SDL_BlitInfo::a, SDL_PixelFormat::Amask, SDL_PixelFormat::Ashift, SDL_PixelFormat::BytesPerPixel, SDL_BlitInfo::dst, SDL_BlitInfo::dst_fmt, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, i1, i2, j1, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, and SDL_BlitInfo::src_skip.

◆ Blit_RGB101010_index8()

static void Blit_RGB101010_index8 ( SDL_BlitInfo info)
static

Definition at line 1016 of file SDL_blit_N.c.

1017{
1018#ifndef USE_DUFFS_LOOP
1019 int c;
1020#endif
1021 int width, height;
1022 Uint32 *src;
1023 const Uint8 *map;
1024 Uint8 *dst;
1025 int srcskip, dstskip;
1026
1027 /* Set up some basic variables */
1028 width = info->dst_w;
1029 height = info->dst_h;
1030 src = (Uint32 *) info->src;
1031 srcskip = info->src_skip / 4;
1032 dst = info->dst;
1033 dstskip = info->dst_skip;
1034 map = info->table;
1035
1036 if (map == NULL) {
1037 while (height--) {
1038#ifdef USE_DUFFS_LOOP
1039 /* *INDENT-OFF* */
1040 DUFFS_LOOP(
1041 RGB101010_RGB332(*dst++, *src);
1042 , width);
1043 /* *INDENT-ON* */
1044#else
1045 for (c = width / 4; c; --c) {
1046 /* Pack RGB into 8bit pixel */
1047 ++src;
1048 RGB101010_RGB332(*dst++, *src);
1049 ++src;
1050 RGB101010_RGB332(*dst++, *src);
1051 ++src;
1052 RGB101010_RGB332(*dst++, *src);
1053 ++src;
1054 }
1055 switch (width & 3) {
1056 case 3:
1057 RGB101010_RGB332(*dst++, *src);
1058 ++src;
1059 case 2:
1060 RGB101010_RGB332(*dst++, *src);
1061 ++src;
1062 case 1:
1063 RGB101010_RGB332(*dst++, *src);
1064 ++src;
1065 }
1066#endif /* USE_DUFFS_LOOP */
1067 src += srcskip;
1068 dst += dstskip;
1069 }
1070 } else {
1071 int Pixel;
1072
1073 while (height--) {
1074#ifdef USE_DUFFS_LOOP
1075 /* *INDENT-OFF* */
1076 DUFFS_LOOP(
1077 RGB101010_RGB332(Pixel, *src);
1078 *dst++ = map[Pixel];
1079 ++src;
1080 , width);
1081 /* *INDENT-ON* */
1082#else
1083 for (c = width / 4; c; --c) {
1084 /* Pack RGB into 8bit pixel */
1085 RGB101010_RGB332(Pixel, *src);
1086 *dst++ = map[Pixel];
1087 ++src;
1088 RGB101010_RGB332(Pixel, *src);
1089 *dst++ = map[Pixel];
1090 ++src;
1091 RGB101010_RGB332(Pixel, *src);
1092 *dst++ = map[Pixel];
1093 ++src;
1094 RGB101010_RGB332(Pixel, *src);
1095 *dst++ = map[Pixel];
1096 ++src;
1097 }
1098 switch (width & 3) {
1099 case 3:
1100 RGB101010_RGB332(Pixel, *src);
1101 *dst++ = map[Pixel];
1102 ++src;
1103 case 2:
1104 RGB101010_RGB332(Pixel, *src);
1105 *dst++ = map[Pixel];
1106 ++src;
1107 case 1:
1108 RGB101010_RGB332(Pixel, *src);
1109 *dst++ = map[Pixel];
1110 ++src;
1111 }
1112#endif /* USE_DUFFS_LOOP */
1113 src += srcskip;
1114 dst += dstskip;
1115 }
1116 }
1117}
#define RGB101010_RGB332(dst, src)
Definition: SDL_blit_N.c:1010
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:291
const GLubyte * c
#define NULL
Definition: begin_code.h:167
Uint8 * table
Definition: SDL_blit.h:67

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

Referenced by SDL_CalculateBlitN().

◆ Blit_RGB565_32()

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

Definition at line 1375 of file SDL_blit_N.c.

1376{
1377#ifndef USE_DUFFS_LOOP
1378 int c;
1379#endif
1380 int width, height;
1381 Uint8 *src;
1382 Uint32 *dst;
1383 int srcskip, dstskip;
1384
1385 /* Set up some basic variables */
1386 width = info->dst_w;
1387 height = info->dst_h;
1388 src = (Uint8 *) info->src;
1389 srcskip = info->src_skip;
1390 dst = (Uint32 *) info->dst;
1391 dstskip = info->dst_skip / 4;
1392
1393#ifdef USE_DUFFS_LOOP
1394 while (height--) {
1395 /* *INDENT-OFF* */
1396 DUFFS_LOOP(
1397 {
1398 *dst++ = RGB565_32(dst, src, map);
1399 src += 2;
1400 },
1401 width);
1402 /* *INDENT-ON* */
1403 src += srcskip;
1404 dst += dstskip;
1405 }
1406#else
1407 while (height--) {
1408 /* Copy in 4 pixel chunks */
1409 for (c = width / 4; c; --c) {
1410 *dst++ = RGB565_32(dst, src, map);
1411 src += 2;
1412 *dst++ = RGB565_32(dst, src, map);
1413 src += 2;
1414 *dst++ = RGB565_32(dst, src, map);
1415 src += 2;
1416 *dst++ = RGB565_32(dst, src, map);
1417 src += 2;
1418 }
1419 /* Get any leftovers */
1420 switch (width & 3) {
1421 case 3:
1422 *dst++ = RGB565_32(dst, src, map);
1423 src += 2;
1424 case 2:
1425 *dst++ = RGB565_32(dst, src, map);
1426 src += 2;
1427 case 1:
1428 *dst++ = RGB565_32(dst, src, map);
1429 src += 2;
1430 break;
1431 }
1432 src += srcskip;
1433 dst += dstskip;
1434 }
1435#endif /* USE_DUFFS_LOOP */
1436}
#define RGB565_32(dst, src, map)
Definition: SDL_blit_N.c:1373

References SDL_BlitInfo::dst, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_skip, SDL_BlitInfo::dst_w, DUFFS_LOOP, map, 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().

◆ Blit_RGB565_ABGR8888()

static void Blit_RGB565_ABGR8888 ( SDL_BlitInfo info)
static

Definition at line 1709 of file SDL_blit_N.c.

1710{
1712}
static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map)
Definition: SDL_blit_N.c:1375
static const Uint32 RGB565_ABGR8888_LUT[512]
Definition: SDL_blit_N.c:1577

References Blit_RGB565_32(), and RGB565_ABGR8888_LUT.

◆ Blit_RGB565_ARGB8888()

static void Blit_RGB565_ARGB8888 ( SDL_BlitInfo info)
static

Definition at line 1571 of file SDL_blit_N.c.

1572{
1574}
static const Uint32 RGB565_ARGB8888_LUT[512]
Definition: SDL_blit_N.c:1439

References Blit_RGB565_32(), and RGB565_ARGB8888_LUT.

◆ Blit_RGB565_BGRA8888()

static void Blit_RGB565_BGRA8888 ( SDL_BlitInfo info)
static

Definition at line 1985 of file SDL_blit_N.c.

1986{
1988}
static const Uint32 RGB565_BGRA8888_LUT[512]
Definition: SDL_blit_N.c:1853

References Blit_RGB565_32(), and RGB565_BGRA8888_LUT.

◆ Blit_RGB565_RGBA8888()

static void Blit_RGB565_RGBA8888 ( SDL_BlitInfo info)
static

Definition at line 1847 of file SDL_blit_N.c.

1848{
1850}
static const Uint32 RGB565_RGBA8888_LUT[512]
Definition: SDL_blit_N.c:1715

References Blit_RGB565_32(), and RGB565_RGBA8888_LUT.

◆ Blit_RGB888_index8()

static void Blit_RGB888_index8 ( SDL_BlitInfo info)
static

Definition at line 906 of file SDL_blit_N.c.

907{
908#ifndef USE_DUFFS_LOOP
909 int c;
910#endif
911 int width, height;
912 Uint32 *src;
913 const Uint8 *map;
914 Uint8 *dst;
915 int srcskip, dstskip;
916
917 /* Set up some basic variables */
918 width = info->dst_w;
919 height = info->dst_h;
920 src = (Uint32 *) info->src;
921 srcskip = info->src_skip / 4;
922 dst = info->dst;
923 dstskip = info->dst_skip;
924 map = info->table;
925
926 if (map == NULL) {
927 while (height--) {
928#ifdef USE_DUFFS_LOOP
929 /* *INDENT-OFF* */
931 RGB888_RGB332(*dst++, *src);
932 , width);
933 /* *INDENT-ON* */
934#else
935 for (c = width / 4; c; --c) {
936 /* Pack RGB into 8bit pixel */
937 ++src;
938 RGB888_RGB332(*dst++, *src);
939 ++src;
940 RGB888_RGB332(*dst++, *src);
941 ++src;
942 RGB888_RGB332(*dst++, *src);
943 ++src;
944 }
945 switch (width & 3) {
946 case 3:
947 RGB888_RGB332(*dst++, *src);
948 ++src;
949 case 2:
950 RGB888_RGB332(*dst++, *src);
951 ++src;
952 case 1:
953 RGB888_RGB332(*dst++, *src);
954 ++src;
955 }
956#endif /* USE_DUFFS_LOOP */
957 src += srcskip;
958 dst += dstskip;
959 }
960 } else {
961 int Pixel;
962
963 while (height--) {
964#ifdef USE_DUFFS_LOOP
965 /* *INDENT-OFF* */
967 RGB888_RGB332(Pixel, *src);
968 *dst++ = map[Pixel];
969 ++src;
970 , width);
971 /* *INDENT-ON* */
972#else
973 for (c = width / 4; c; --c) {
974 /* Pack RGB into 8bit pixel */
975 RGB888_RGB332(Pixel, *src);
976 *dst++ = map[Pixel];
977 ++src;
978 RGB888_RGB332(Pixel, *src);
979 *dst++ = map[Pixel];
980 ++src;
981 RGB888_RGB332(Pixel, *src);
982 *dst++ = map[Pixel];
983 ++src;
984 RGB888_RGB332(Pixel, *src);
985 *dst++ = map[Pixel];
986 ++src;
987 }
988 switch (width & 3) {
989 case 3:
990 RGB888_RGB332(Pixel, *src);
991 *dst++ = map[Pixel];
992 ++src;
993 case 2:
994 RGB888_RGB332(Pixel, *src);
995 *dst++ = map[Pixel];
996 ++src;
997 case 1:
998 RGB888_RGB332(Pixel, *src);
999 *dst++ = map[Pixel];
1000 ++src;
1001 }
1002#endif /* USE_DUFFS_LOOP */
1003 src += srcskip;
1004 dst += dstskip;
1005 }
1006 }
1007}
#define RGB888_RGB332(dst, src)
Definition: SDL_blit_N.c:900

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

Referenced by SDL_CalculateBlitN().

◆ Blit_RGB888_RGB555()

static void Blit_RGB888_RGB555 ( SDL_BlitInfo info)
static

Definition at line 1136 of file SDL_blit_N.c.

1137{
1138#ifndef USE_DUFFS_LOOP
1139 int c;
1140#endif
1141 int width, height;
1142 Uint32 *src;
1143 Uint16 *dst;
1144 int srcskip, dstskip;
1145
1146 /* Set up some basic variables */
1147 width = info->dst_w;
1148 height = info->dst_h;
1149 src = (Uint32 *) info->src;
1150 srcskip = info->src_skip / 4;
1151 dst = (Uint16 *) info->dst;
1152 dstskip = info->dst_skip / 2;
1153
1154#ifdef USE_DUFFS_LOOP
1155 while (height--) {
1156 /* *INDENT-OFF* */
1157 DUFFS_LOOP(
1159 ++src;
1160 ++dst;
1161 , width);
1162 /* *INDENT-ON* */
1163 src += srcskip;
1164 dst += dstskip;
1165 }
1166#else
1167 /* Memory align at 4-byte boundary, if necessary */
1168 if ((long) dst & 0x03) {
1169 /* Don't do anything if width is 0 */
1170 if (width == 0) {
1171 return;
1172 }
1173 --width;
1174
1175 while (height--) {
1176 /* Perform copy alignment */
1178 ++src;
1179 ++dst;
1180
1181 /* Copy in 4 pixel chunks */
1182 for (c = width / 4; c; --c) {
1183 RGB888_RGB555_TWO(dst, src);
1184 src += 2;
1185 dst += 2;
1186 RGB888_RGB555_TWO(dst, src);
1187 src += 2;
1188 dst += 2;
1189 }
1190 /* Get any leftovers */
1191 switch (width & 3) {
1192 case 3:
1194 ++src;
1195 ++dst;
1196 case 2:
1197 RGB888_RGB555_TWO(dst, src);
1198 src += 2;
1199 dst += 2;
1200 break;
1201 case 1:
1203 ++src;
1204 ++dst;
1205 break;
1206 }
1207 src += srcskip;
1208 dst += dstskip;
1209 }
1210 } else {
1211 while (height--) {
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:
1225 ++src;
1226 ++dst;
1227 case 2:
1228 RGB888_RGB555_TWO(dst, src);
1229 src += 2;
1230 dst += 2;
1231 break;
1232 case 1:
1234 ++src;
1235 ++dst;
1236 break;
1237 }
1238 src += srcskip;
1239 dst += dstskip;
1240 }
1241 }
1242#endif /* USE_DUFFS_LOOP */
1243}
#define RGB888_RGB555(dst, src)
Definition: SDL_blit_N.c:1120

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.

◆ Blit_RGB888_RGB565()

static void Blit_RGB888_RGB565 ( SDL_BlitInfo info)
static

Definition at line 1262 of file SDL_blit_N.c.

1263{
1264#ifndef USE_DUFFS_LOOP
1265 int c;
1266#endif
1267 int width, height;
1268 Uint32 *src;
1269 Uint16 *dst;
1270 int srcskip, dstskip;
1271
1272 /* Set up some basic variables */
1273 width = info->dst_w;
1274 height = info->dst_h;
1275 src = (Uint32 *) info->src;
1276 srcskip = info->src_skip / 4;
1277 dst = (Uint16 *) info->dst;
1278 dstskip = info->dst_skip / 2;
1279
1280#ifdef USE_DUFFS_LOOP
1281 while (height--) {
1282 /* *INDENT-OFF* */
1283 DUFFS_LOOP(
1285 ++src;
1286 ++dst;
1287 , width);
1288 /* *INDENT-ON* */
1289 src += srcskip;
1290 dst += dstskip;
1291 }
1292#else
1293 /* Memory align at 4-byte boundary, if necessary */
1294 if ((long) dst & 0x03) {
1295 /* Don't do anything if width is 0 */
1296 if (width == 0) {
1297 return;
1298 }
1299 --width;
1300
1301 while (height--) {
1302 /* Perform copy alignment */
1304 ++src;
1305 ++dst;
1306
1307 /* Copy in 4 pixel chunks */
1308 for (c = width / 4; c; --c) {
1309 RGB888_RGB565_TWO(dst, src);
1310 src += 2;
1311 dst += 2;
1312 RGB888_RGB565_TWO(dst, src);
1313 src += 2;
1314 dst += 2;
1315 }
1316 /* Get any leftovers */
1317 switch (width & 3) {
1318 case 3:
1320 ++src;
1321 ++dst;
1322 case 2:
1323 RGB888_RGB565_TWO(dst, src);
1324 src += 2;
1325 dst += 2;
1326 break;
1327 case 1:
1329 ++src;
1330 ++dst;
1331 break;
1332 }
1333 src += srcskip;
1334 dst += dstskip;
1335 }
1336 } else {
1337 while (height--) {
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:
1351 ++src;
1352 ++dst;
1353 case 2:
1354 RGB888_RGB565_TWO(dst, src);
1355 src += 2;
1356 dst += 2;
1357 break;
1358 case 1:
1360 ++src;
1361 ++dst;
1362 break;
1363 }
1364 src += srcskip;
1365 dst += dstskip;
1366 }
1367 }
1368#endif /* USE_DUFFS_LOOP */
1369}
#define RGB888_RGB565(dst, src)
Definition: SDL_blit_N.c:1246

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.

◆ BlitNto1()

static void BlitNto1 ( SDL_BlitInfo info)
static

Definition at line 1991 of file SDL_blit_N.c.

1992{
1993#ifndef USE_DUFFS_LOOP
1994 int c;
1995#endif
1996 int width, height;
1997 Uint8 *src;
1998 const Uint8 *map;
1999 Uint8 *dst;
2000 int srcskip, dstskip;
2001 int srcbpp;
2002 Uint32 Pixel;
2003 int sR, sG, sB;
2004 SDL_PixelFormat *srcfmt;
2005
2006 /* Set up some basic variables */
2007 width = info->dst_w;
2008 height = info->dst_h;
2009 src = info->src;
2010 srcskip = info->src_skip;
2011 dst = info->dst;
2012 dstskip = info->dst_skip;
2013 map = info->table;
2014 srcfmt = info->src_fmt;
2015 srcbpp = srcfmt->BytesPerPixel;
2016
2017 if (map == NULL) {
2018 while (height--) {
2019#ifdef USE_DUFFS_LOOP
2020 /* *INDENT-OFF* */
2021 DUFFS_LOOP(
2022 DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
2023 sR, sG, sB);
2024 if ( 1 ) {
2025 /* Pack RGB into 8bit pixel */
2026 *dst = ((sR>>5)<<(3+2))|
2027 ((sG>>5)<<(2)) |
2028 ((sB>>6)<<(0)) ;
2029 }
2030 dst++;
2031 src += srcbpp;
2032 , width);
2033 /* *INDENT-ON* */
2034#else
2035 for (c = width; c; --c) {
2036 DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
2037 if (1) {
2038 /* Pack RGB into 8bit pixel */
2039 *dst = ((sR >> 5) << (3 + 2)) |
2040 ((sG >> 5) << (2)) | ((sB >> 6) << (0));
2041 }
2042 dst++;
2043 src += srcbpp;
2044 }
2045#endif
2046 src += srcskip;
2047 dst += dstskip;
2048 }
2049 } else {
2050 while (height--) {
2051#ifdef USE_DUFFS_LOOP
2052 /* *INDENT-OFF* */
2053 DUFFS_LOOP(
2054 DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
2055 sR, sG, sB);
2056 if ( 1 ) {
2057 /* Pack RGB into 8bit pixel */
2058 *dst = map[((sR>>5)<<(3+2))|
2059 ((sG>>5)<<(2)) |
2060 ((sB>>6)<<(0)) ];
2061 }
2062 dst++;
2063 src += srcbpp;
2064 , width);
2065 /* *INDENT-ON* */
2066#else
2067 for (c = width; c; --c) {
2068 DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
2069 if (1) {
2070 /* Pack RGB into 8bit pixel */
2071 *dst = map[((sR >> 5) << (3 + 2)) |
2072 ((sG >> 5) << (2)) | ((sB >> 6) << (0))];
2073 }
2074 dst++;
2075 src += srcbpp;
2076 }
2077#endif /* USE_DUFFS_LOOP */
2078 src += srcskip;
2079 dst += dstskip;
2080 }
2081 }
2082}
#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b)
Definition: SDL_blit.h:177

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

◆ BlitNto1Key()

static void BlitNto1Key ( SDL_BlitInfo info)
static

Definition at line 2421 of file SDL_blit_N.c.

2422{
2423 int width = info->dst_w;
2424 int height = info->dst_h;
2425 Uint8 *src = info->src;
2426 int srcskip = info->src_skip;
2427 Uint8 *dst = info->dst;
2428 int dstskip = info->dst_skip;
2429 SDL_PixelFormat *srcfmt = info->src_fmt;
2430 const Uint8 *palmap = info->table;
2431 Uint32 ckey = info->colorkey;
2432 Uint32 rgbmask = ~srcfmt->Amask;
2433 int srcbpp;
2434 Uint32 Pixel;
2435 unsigned sR, sG, sB;
2436
2437 /* Set up some basic variables */
2438 srcbpp = srcfmt->BytesPerPixel;
2439 ckey &= rgbmask;
2440
2441 if (palmap == NULL) {
2442 while (height--) {
2443 /* *INDENT-OFF* */
2444 DUFFS_LOOP(
2445 {
2446 DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
2447 sR, sG, sB);
2448 if ( (Pixel & rgbmask) != ckey ) {
2449 /* Pack RGB into 8bit pixel */
2450 *dst = (Uint8)(((sR>>5)<<(3+2))|
2451 ((sG>>5)<<(2)) |
2452 ((sB>>6)<<(0)));
2453 }
2454 dst++;
2455 src += srcbpp;
2456 },
2457 width);
2458 /* *INDENT-ON* */
2459 src += srcskip;
2460 dst += dstskip;
2461 }
2462 } else {
2463 while (height--) {
2464 /* *INDENT-OFF* */
2465 DUFFS_LOOP(
2466 {
2467 DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
2468 sR, sG, sB);
2469 if ( (Pixel & rgbmask) != ckey ) {
2470 /* Pack RGB into 8bit pixel */
2471 *dst = (Uint8)palmap[((sR>>5)<<(3+2))|
2472 ((sG>>5)<<(2)) |
2473 ((sB>>6)<<(0)) ];
2474 }
2475 dst++;
2476 src += srcbpp;
2477 },
2478 width);
2479 /* *INDENT-ON* */
2480 src += srcskip;
2481 dst += dstskip;
2482 }
2483 }
2484}

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

◆ BlitNto2101010()

static void BlitNto2101010 ( SDL_BlitInfo info)
static

Definition at line 2929 of file SDL_blit_N.c.

2930{
2931 int width = info->dst_w;
2932 int height = info->dst_h;
2933 Uint8 *src = info->src;
2934 int srcskip = info->src_skip;
2935 Uint8 *dst = info->dst;
2936 int dstskip = info->dst_skip;
2937 SDL_PixelFormat *srcfmt = info->src_fmt;
2938 int srcbpp = srcfmt->BytesPerPixel;
2939 Uint32 Pixel;
2940 unsigned sR, sG, sB, sA;
2941
2942 while (height--) {
2943 /* *INDENT-OFF* */
2944 DUFFS_LOOP(
2945 {
2946 DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
2947 ARGB2101010_FROM_RGBA(Pixel, sR, sG, sB, sA);
2948 *(Uint32 *)dst = Pixel;
2949 dst += 4;
2950 src += srcbpp;
2951 },
2952 width);
2953 /* *INDENT-ON* */
2954 src += srcskip;
2955 dst += dstskip;
2956 }
2957}
#define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a)
Definition: SDL_blit.h:353
#define ARGB2101010_FROM_RGBA(Pixel, r, g, b, a)
Definition: SDL_blit.h:253

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

◆ BlitNtoN()

static void BlitNtoN ( SDL_BlitInfo info)
static

Definition at line 2244 of file SDL_blit_N.c.

2245{
2246 int width = info->dst_w;
2247 int height = info->dst_h;
2248 Uint8 *src = info->src;
2249 int srcskip = info->src_skip;
2250 Uint8 *dst = info->dst;
2251 int dstskip = info->dst_skip;
2252 SDL_PixelFormat *srcfmt = info->src_fmt;
2253 int srcbpp = srcfmt->BytesPerPixel;
2254 SDL_PixelFormat *dstfmt = info->dst_fmt;
2255 int dstbpp = dstfmt->BytesPerPixel;
2256 unsigned alpha = dstfmt->Amask ? info->a : 0;
2257
2258#if HAVE_FAST_WRITE_INT8
2259 /* Blit with permutation: 4->4 */
2260 if (srcbpp == 4 && dstbpp == 4 &&
2263
2264 /* Find the appropriate permutation */
2265 int alpha_channel, p0, p1, p2, p3;
2266 get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel);
2267
2268 while (height--) {
2269 /* *INDENT-OFF* */
2270 DUFFS_LOOP(
2271 {
2272 dst[0] = src[p0];
2273 dst[1] = src[p1];
2274 dst[2] = src[p2];
2275 dst[3] = src[p3];
2276 dst[alpha_channel] = alpha;
2277 src += 4;
2278 dst += 4;
2279 }, width);
2280 /* *INDENT-ON* */
2281 src += srcskip;
2282 dst += dstskip;
2283 }
2284 return;
2285 }
2286#endif
2287
2288 /* Blit with permutation: 4->3 */
2289 if (srcbpp == 4 && dstbpp == 3 &&
2291
2292 /* Find the appropriate permutation */
2293 int p0, p1, p2, p3;
2294 get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL);
2295
2296 while (height--) {
2297 /* *INDENT-OFF* */
2298 DUFFS_LOOP(
2299 {
2300 dst[0] = src[p0];
2301 dst[1] = src[p1];
2302 dst[2] = src[p2];
2303 src += 4;
2304 dst += 3;
2305 }, width);
2306 /* *INDENT-ON* */
2307 src += srcskip;
2308 dst += dstskip;
2309 }
2310 return;
2311 }
2312
2313#if HAVE_FAST_WRITE_INT8
2314 /* Blit with permutation: 3->4 */
2315 if (srcbpp == 3 && dstbpp == 4 &&
2317
2318 /* Find the appropriate permutation */
2319 int alpha_channel, p0, p1, p2, p3;
2320 get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel);
2321
2322 while (height--) {
2323 /* *INDENT-OFF* */
2324 DUFFS_LOOP(
2325 {
2326 dst[0] = src[p0];
2327 dst[1] = src[p1];
2328 dst[2] = src[p2];
2329 dst[3] = src[p3];
2330 dst[alpha_channel] = alpha;
2331 src += 3;
2332 dst += 4;
2333 }, width);
2334 /* *INDENT-ON* */
2335 src += srcskip;
2336 dst += dstskip;
2337 }
2338 return;
2339 }
2340#endif
2341
2342 while (height--) {
2343 /* *INDENT-OFF* */
2344 DUFFS_LOOP(
2345 {
2346 Uint32 Pixel;
2347 unsigned sR;
2348 unsigned sG;
2349 unsigned sB;
2350 DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
2351 ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha);
2352 dst += dstbpp;
2353 src += srcbpp;
2354 },
2355 width);
2356 /* *INDENT-ON* */
2357 src += srcskip;
2358 dst += dstskip;
2359 }
2360}
static void get_permutation(SDL_PixelFormat *srcfmt, SDL_PixelFormat *dstfmt, int *_p0, int *_p1, int *_p2, int *_p3, int *_alpha_channel)
Definition: SDL_blit_N.c:2163
GLfloat GLfloat GLfloat alpha
@ SDL_PIXELFORMAT_ARGB2101010
Definition: SDL_pixels.h:260

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_PixelFormat::format, get_permutation(), NULL, SDL_PIXELFORMAT_ARGB2101010, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitN().

◆ BlitNtoNCopyAlpha()

static void BlitNtoNCopyAlpha ( SDL_BlitInfo info)
static

Definition at line 2363 of file SDL_blit_N.c.

2364{
2365 int width = info->dst_w;
2366 int height = info->dst_h;
2367 Uint8 *src = info->src;
2368 int srcskip = info->src_skip;
2369 Uint8 *dst = info->dst;
2370 int dstskip = info->dst_skip;
2371 SDL_PixelFormat *srcfmt = info->src_fmt;
2372 int srcbpp = srcfmt->BytesPerPixel;
2373 SDL_PixelFormat *dstfmt = info->dst_fmt;
2374 int dstbpp = dstfmt->BytesPerPixel;
2375 int c;
2376
2377#if HAVE_FAST_WRITE_INT8
2378 /* Blit with permutation: 4->4 */
2379 if (srcbpp == 4 && dstbpp == 4 &&
2382
2383 /* Find the appropriate permutation */
2384 int p0, p1, p2, p3;
2385 get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL);
2386
2387 while (height--) {
2388 /* *INDENT-OFF* */
2389 DUFFS_LOOP(
2390 {
2391 dst[0] = src[p0];
2392 dst[1] = src[p1];
2393 dst[2] = src[p2];
2394 dst[3] = src[p3];
2395 src += 4;
2396 dst += 4;
2397 }, width);
2398 /* *INDENT-ON* */
2399 src += srcskip;
2400 dst += dstskip;
2401 }
2402 return;
2403 }
2404#endif
2405
2406 while (height--) {
2407 for (c = width; c; --c) {
2408 Uint32 Pixel;
2409 unsigned sR, sG, sB, sA;
2410 DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
2411 ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, sA);
2412 dst += dstbpp;
2413 src += srcbpp;
2414 }
2415 src += srcskip;
2416 dst += dstskip;
2417 }
2418}

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, DUFFS_LOOP, SDL_PixelFormat::format, get_permutation(), NULL, SDL_PIXELFORMAT_ARGB2101010, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitN().

◆ BlitNtoNKey()

static void BlitNtoNKey ( SDL_BlitInfo info)
static

Definition at line 2521 of file SDL_blit_N.c.

2522{
2523 int width = info->dst_w;
2524 int height = info->dst_h;
2525 Uint8 *src = info->src;
2526 int srcskip = info->src_skip;
2527 Uint8 *dst = info->dst;
2528 int dstskip = info->dst_skip;
2529 Uint32 ckey = info->colorkey;
2530 SDL_PixelFormat *srcfmt = info->src_fmt;
2531 SDL_PixelFormat *dstfmt = info->dst_fmt;
2532 int srcbpp = srcfmt->BytesPerPixel;
2533 int dstbpp = dstfmt->BytesPerPixel;
2534 unsigned alpha = dstfmt->Amask ? info->a : 0;
2535 Uint32 rgbmask = ~srcfmt->Amask;
2536 int sfmt = srcfmt->format;
2537 int dfmt = dstfmt->format;
2538
2539 /* Set up some basic variables */
2540 ckey &= rgbmask;
2541
2542 /* BPP 4, same rgb */
2543 if (srcbpp == 4 && dstbpp == 4 && srcfmt->Rmask == dstfmt->Rmask && srcfmt->Gmask == dstfmt->Gmask && srcfmt->Bmask == dstfmt->Bmask) {
2544 Uint32 *src32 = (Uint32*)src;
2545 Uint32 *dst32 = (Uint32*)dst;
2546
2547 if (dstfmt->Amask) {
2548 /* RGB->RGBA, SET_ALPHA */
2549 Uint32 mask = info->a << dstfmt->Ashift;
2550 while (height--) {
2551 /* *INDENT-OFF* */
2552 DUFFS_LOOP(
2553 {
2554 if ((*src32 & rgbmask) != ckey) {
2555 *dst32 = *src32 | mask;
2556 }
2557 ++dst32;
2558 ++src32;
2559 }, width);
2560 /* *INDENT-ON* */
2561 src32 = (Uint32 *) ((Uint8 *) src32 + srcskip);
2562 dst32 = (Uint32 *) ((Uint8 *) dst32 + dstskip);
2563 }
2564 return;
2565 } else {
2566 /* RGBA->RGB, NO_ALPHA */
2567 Uint32 mask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
2568 while (height--) {
2569 /* *INDENT-OFF* */
2570 DUFFS_LOOP(
2571 {
2572 if ((*src32 & rgbmask) != ckey) {
2573 *dst32 = *src32 & mask;
2574 }
2575 ++dst32;
2576 ++src32;
2577 }, width);
2578 /* *INDENT-ON* */
2579 src32 = (Uint32 *) ((Uint8 *) src32 + srcskip);
2580 dst32 = (Uint32 *) ((Uint8 *) dst32 + dstskip);
2581 }
2582 return;
2583 }
2584 }
2585
2586#if HAVE_FAST_WRITE_INT8
2587 /* Blit with permutation: 4->4 */
2588 if (srcbpp == 4 && dstbpp == 4 &&
2591
2592 /* Find the appropriate permutation */
2593 int alpha_channel, p0, p1, p2, p3;
2594 get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel);
2595
2596 while (height--) {
2597 /* *INDENT-OFF* */
2598 DUFFS_LOOP(
2599 {
2600 Uint32 *src32 = (Uint32*)src;
2601
2602 if ((*src32 & rgbmask) != ckey) {
2603 dst[0] = src[p0];
2604 dst[1] = src[p1];
2605 dst[2] = src[p2];
2606 dst[3] = src[p3];
2607 dst[alpha_channel] = alpha;
2608 }
2609 src += 4;
2610 dst += 4;
2611 }, width);
2612 /* *INDENT-ON* */
2613 src += srcskip;
2614 dst += dstskip;
2615 }
2616 return;
2617 }
2618#endif
2619
2620 /* BPP 3, same rgb triplet */
2621 if ((sfmt == SDL_PIXELFORMAT_RGB24 && dfmt == SDL_PIXELFORMAT_RGB24) ||
2622 (sfmt == SDL_PIXELFORMAT_BGR24 && dfmt == SDL_PIXELFORMAT_BGR24)) {
2623
2624#if SDL_BYTEORDER == SDL_LIL_ENDIAN
2625 Uint8 k0 = ckey & 0xFF;
2626 Uint8 k1 = (ckey >> 8) & 0xFF;
2627 Uint8 k2 = (ckey >> 16) & 0xFF;
2628#else
2629 Uint8 k0 = (ckey >> 16) & 0xFF;
2630 Uint8 k1 = (ckey >> 8) & 0xFF;
2631 Uint8 k2 = ckey & 0xFF;
2632#endif
2633
2634 while (height--) {
2635 /* *INDENT-OFF* */
2636 DUFFS_LOOP(
2637 {
2638 Uint8 s0 = src[0];
2639 Uint8 s1 = src[1];
2640 Uint8 s2 = src[2];
2641
2642 if (k0 != s0 || k1 != s1 || k2 != s2) {
2643 dst[0] = s0;
2644 dst[1] = s1;
2645 dst[2] = s2;
2646 }
2647 src += 3;
2648 dst += 3;
2649 },
2650 width);
2651 /* *INDENT-ON* */
2652 src += srcskip;
2653 dst += dstskip;
2654 }
2655 return;
2656 }
2657
2658 /* BPP 3, inversed rgb triplet */
2659 if ((sfmt == SDL_PIXELFORMAT_RGB24 && dfmt == SDL_PIXELFORMAT_BGR24) ||
2660 (sfmt == SDL_PIXELFORMAT_BGR24 && dfmt == SDL_PIXELFORMAT_RGB24)) {
2661
2662#if SDL_BYTEORDER == SDL_LIL_ENDIAN
2663 Uint8 k0 = ckey & 0xFF;
2664 Uint8 k1 = (ckey >> 8) & 0xFF;
2665 Uint8 k2 = (ckey >> 16) & 0xFF;
2666#else
2667 Uint8 k0 = (ckey >> 16) & 0xFF;
2668 Uint8 k1 = (ckey >> 8) & 0xFF;
2669 Uint8 k2 = ckey & 0xFF;
2670#endif
2671
2672 while (height--) {
2673 /* *INDENT-OFF* */
2674 DUFFS_LOOP(
2675 {
2676 Uint8 s0 = src[0];
2677 Uint8 s1 = src[1];
2678 Uint8 s2 = src[2];
2679 if (k0 != s0 || k1 != s1 || k2 != s2) {
2680 /* Inversed RGB */
2681 dst[0] = s2;
2682 dst[1] = s1;
2683 dst[2] = s0;
2684 }
2685 src += 3;
2686 dst += 3;
2687 },
2688 width);
2689 /* *INDENT-ON* */
2690 src += srcskip;
2691 dst += dstskip;
2692 }
2693 return;
2694 }
2695
2696 /* Blit with permutation: 4->3 */
2697 if (srcbpp == 4 && dstbpp == 3 &&
2699
2700 /* Find the appropriate permutation */
2701 int p0, p1, p2, p3;
2702 get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL);
2703
2704 while (height--) {
2705 /* *INDENT-OFF* */
2706 DUFFS_LOOP(
2707 {
2708 Uint32 *src32 = (Uint32*)src;
2709 if ((*src32 & rgbmask) != ckey) {
2710 dst[0] = src[p0];
2711 dst[1] = src[p1];
2712 dst[2] = src[p2];
2713 }
2714 src += 4;
2715 dst += 3;
2716 }, width);
2717 /* *INDENT-ON* */
2718 src += srcskip;
2719 dst += dstskip;
2720 }
2721 return;
2722 }
2723
2724#if HAVE_FAST_WRITE_INT8
2725 /* Blit with permutation: 3->4 */
2726 if (srcbpp == 3 && dstbpp == 4 &&
2728
2729#if SDL_BYTEORDER == SDL_LIL_ENDIAN
2730 Uint8 k0 = ckey & 0xFF;
2731 Uint8 k1 = (ckey >> 8) & 0xFF;
2732 Uint8 k2 = (ckey >> 16) & 0xFF;
2733#else
2734 Uint8 k0 = (ckey >> 16) & 0xFF;
2735 Uint8 k1 = (ckey >> 8) & 0xFF;
2736 Uint8 k2 = ckey & 0xFF;
2737#endif
2738
2739 /* Find the appropriate permutation */
2740 int alpha_channel, p0, p1, p2, p3;
2741 get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel);
2742
2743 while (height--) {
2744 /* *INDENT-OFF* */
2745 DUFFS_LOOP(
2746 {
2747 Uint8 s0 = src[0];
2748 Uint8 s1 = src[1];
2749 Uint8 s2 = src[2];
2750
2751 if (k0 != s0 || k1 != s1 || k2 != s2) {
2752 dst[0] = src[p0];
2753 dst[1] = src[p1];
2754 dst[2] = src[p2];
2755 dst[3] = src[p3];
2756 dst[alpha_channel] = alpha;
2757 }
2758 src += 3;
2759 dst += 4;
2760 }, width);
2761 /* *INDENT-ON* */
2762 src += srcskip;
2763 dst += dstskip;
2764 }
2765 return;
2766 }
2767#endif
2768
2769 while (height--) {
2770 /* *INDENT-OFF* */
2771 DUFFS_LOOP(
2772 {
2773 Uint32 Pixel;
2774 unsigned sR;
2775 unsigned sG;
2776 unsigned sB;
2777 RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
2778 if ( (Pixel & rgbmask) != ckey ) {
2779 RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB);
2780 ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha);
2781 }
2782 dst += dstbpp;
2783 src += srcbpp;
2784 },
2785 width);
2786 /* *INDENT-ON* */
2787 src += srcskip;
2788 dst += dstskip;
2789 }
2790}
#define RETRIEVE_RGB_PIXEL(buf, bpp, Pixel)
Definition: SDL_blit.h:146
#define RGB_FROM_PIXEL(Pixel, fmt, r, g, b)
Definition: SDL_blit.h:122
@ SDL_PIXELFORMAT_BGR24
Definition: SDL_pixels.h:233
@ SDL_PIXELFORMAT_RGB24
Definition: SDL_pixels.h:230

References SDL_BlitInfo::a, SDL_PixelFormat::Amask, SDL_PixelFormat::Ashift, ASSEMBLE_RGBA, SDL_PixelFormat::Bmask, 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, get_permutation(), SDL_PixelFormat::Gmask, NULL, RETRIEVE_RGB_PIXEL, RGB_FROM_PIXEL, SDL_PixelFormat::Rmask, SDL_PIXELFORMAT_ARGB2101010, SDL_PIXELFORMAT_BGR24, SDL_PIXELFORMAT_RGB24, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, and SDL_BlitInfo::src_skip.

Referenced by SDL_CalculateBlitN().

◆ BlitNtoNKeyCopyAlpha()

static void BlitNtoNKeyCopyAlpha ( SDL_BlitInfo info)
static

Definition at line 2793 of file SDL_blit_N.c.

2794{
2795 int width = info->dst_w;
2796 int height = info->dst_h;
2797 Uint8 *src = info->src;
2798 int srcskip = info->src_skip;
2799 Uint8 *dst = info->dst;
2800 int dstskip = info->dst_skip;
2801 Uint32 ckey = info->colorkey;
2802 SDL_PixelFormat *srcfmt = info->src_fmt;
2803 SDL_PixelFormat *dstfmt = info->dst_fmt;
2804 Uint32 rgbmask = ~srcfmt->Amask;
2805
2806 Uint8 srcbpp;
2807 Uint8 dstbpp;
2808 Uint32 Pixel;
2809 unsigned sR, sG, sB, sA;
2810
2811 /* Set up some basic variables */
2812 srcbpp = srcfmt->BytesPerPixel;
2813 dstbpp = dstfmt->BytesPerPixel;
2814 ckey &= rgbmask;
2815
2816 /* Fastpath: same source/destination format, with Amask, bpp 32, loop is vectorized. ~10x faster */
2817 if (srcfmt->format == dstfmt->format) {
2818
2819 if (srcfmt->format == SDL_PIXELFORMAT_ARGB8888 ||
2820 srcfmt->format == SDL_PIXELFORMAT_ABGR8888 ||
2821 srcfmt->format == SDL_PIXELFORMAT_BGRA8888 ||
2822 srcfmt->format == SDL_PIXELFORMAT_RGBA8888) {
2823
2824 Uint32 *src32 = (Uint32*)src;
2825 Uint32 *dst32 = (Uint32*)dst;
2826 while (height--) {
2827 /* *INDENT-OFF* */
2828 DUFFS_LOOP(
2829 {
2830 if ((*src32 & rgbmask) != ckey) {
2831 *dst32 = *src32;
2832 }
2833 ++src32;
2834 ++dst32;
2835 },
2836 width);
2837 /* *INDENT-ON* */
2838 src32 = (Uint32 *)((Uint8 *)src32 + srcskip);
2839 dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip);
2840 }
2841 }
2842 return;
2843 }
2844
2845#if HAVE_FAST_WRITE_INT8
2846 /* Blit with permutation: 4->4 */
2847 if (srcbpp == 4 && dstbpp == 4 &&
2850
2851 /* Find the appropriate permutation */
2852 int p0, p1, p2, p3;
2853 get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL);
2854
2855 while (height--) {
2856 /* *INDENT-OFF* */
2857 DUFFS_LOOP(
2858 {
2859 Uint32 *src32 = (Uint32*)src;
2860 if ((*src32 & rgbmask) != ckey) {
2861 dst[0] = src[p0];
2862 dst[1] = src[p1];
2863 dst[2] = src[p2];
2864 dst[3] = src[p3];
2865 }
2866 src += 4;
2867 dst += 4;
2868 }, width);
2869 /* *INDENT-ON* */
2870 src += srcskip;
2871 dst += dstskip;
2872 }
2873 return;
2874 }
2875#endif
2876
2877 while (height--) {
2878 /* *INDENT-OFF* */
2879 DUFFS_LOOP(
2880 {
2881 DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
2882 if ( (Pixel & rgbmask) != ckey ) {
2883 ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, sA);
2884 }
2885 dst += dstbpp;
2886 src += srcbpp;
2887 },
2888 width);
2889 /* *INDENT-ON* */
2890 src += srcskip;
2891 dst += dstskip;
2892 }
2893}
@ SDL_PIXELFORMAT_RGBA8888
Definition: SDL_pixels.h:251
@ SDL_PIXELFORMAT_ABGR8888
Definition: SDL_pixels.h:254
@ SDL_PIXELFORMAT_BGRA8888
Definition: SDL_pixels.h:257
@ SDL_PIXELFORMAT_ARGB8888
Definition: SDL_pixels.h:248

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, get_permutation(), NULL, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB2101010, 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().

◆ get_permutation()

static void get_permutation ( SDL_PixelFormat srcfmt,
SDL_PixelFormat dstfmt,
int *  _p0,
int *  _p1,
int *  _p2,
int *  _p3,
int *  _alpha_channel 
)
static

Definition at line 2163 of file SDL_blit_N.c.

2165{
2166 int alpha_channel = 0, p0, p1, p2, p3;
2167#if SDL_BYTEORDER == SDL_LIL_ENDIAN
2168 int Pixel = 0x04030201; /* identity permutation */
2169#else
2170 int Pixel = 0x01020304; /* identity permutation */
2171 int srcbpp = srcfmt->BytesPerPixel;
2172 int dstbpp = dstfmt->BytesPerPixel;
2173#endif
2174
2175 if (srcfmt->Amask) {
2176 RGBA_FROM_PIXEL(Pixel, srcfmt, p0, p1, p2, p3);
2177 } else {
2178 RGB_FROM_PIXEL(Pixel, srcfmt, p0, p1, p2);
2179 p3 = 0;
2180 }
2181
2182 if (dstfmt->Amask) {
2183 if (srcfmt->Amask) {
2184 PIXEL_FROM_RGBA(Pixel, dstfmt, p0, p1, p2, p3);
2185 } else {
2186 PIXEL_FROM_RGBA(Pixel, dstfmt, p0, p1, p2, 0);
2187 }
2188 } else {
2189 PIXEL_FROM_RGB(Pixel, dstfmt, p0, p1, p2);
2190 }
2191
2192#if SDL_BYTEORDER == SDL_LIL_ENDIAN
2193 p0 = Pixel & 0xFF;
2194 p1 = (Pixel >> 8) & 0xFF;
2195 p2 = (Pixel >> 16) & 0xFF;
2196 p3 = (Pixel >> 24) & 0xFF;
2197#else
2198 p3 = Pixel & 0xFF;
2199 p2 = (Pixel >> 8) & 0xFF;
2200 p1 = (Pixel >> 16) & 0xFF;
2201 p0 = (Pixel >> 24) & 0xFF;
2202#endif
2203
2204 if (p0 == 0) {
2205 p0 = 1;
2206 alpha_channel = 0;
2207 } else if (p1 == 0) {
2208 p1 = 1;
2209 alpha_channel = 1;
2210 } else if (p2 == 0) {
2211 p2 = 1;
2212 alpha_channel = 2;
2213 } else if (p3 == 0) {
2214 p3 = 1;
2215 alpha_channel = 3;
2216 }
2217
2218#if SDL_BYTEORDER == SDL_LIL_ENDIAN
2219#else
2220 if (srcbpp == 3 && dstbpp == 4) {
2221 if (p0 != 1) p0--;
2222 if (p1 != 1) p1--;
2223 if (p2 != 1) p2--;
2224 if (p3 != 1) p3--;
2225 } else if (srcbpp == 4 && dstbpp == 3) {
2226 p0 = p1;
2227 p1 = p2;
2228 p2 = p3;
2229 }
2230#endif
2231 *_p0 = p0 - 1;
2232 *_p1 = p1 - 1;
2233 *_p2 = p2 - 1;
2234 *_p3 = p3 - 1;
2235
2236 if (_alpha_channel) {
2237 *_alpha_channel = alpha_channel;
2238 }
2239 return;
2240}
#define PIXEL_FROM_RGB(Pixel, fmt, r, g, b)
Definition: SDL_blit.h:218
#define RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a)
Definition: SDL_blit.h:304
#define PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a)
Definition: SDL_blit.h:395

References SDL_PixelFormat::Amask, SDL_PixelFormat::BytesPerPixel, PIXEL_FROM_RGB, PIXEL_FROM_RGBA, RGB_FROM_PIXEL, and RGBA_FROM_PIXEL.

Referenced by BlitNtoN(), BlitNtoNCopyAlpha(), BlitNtoNKey(), and BlitNtoNKeyCopyAlpha().

◆ SDL_CalculateBlitN()

SDL_BlitFunc SDL_CalculateBlitN ( SDL_Surface surface)

Definition at line 3266 of file SDL_blit_N.c.

3267{
3268 SDL_PixelFormat *srcfmt;
3269 SDL_PixelFormat *dstfmt;
3270 const struct blit_table *table;
3271 int which;
3272 SDL_BlitFunc blitfun;
3273
3274 /* Set up data for choosing the blit */
3275 srcfmt = surface->format;
3276 dstfmt = surface->map->dst->format;
3277
3278 /* We don't support destinations less than 8-bits */
3279 if (dstfmt->BitsPerPixel < 8) {
3280 return (NULL);
3281 }
3282
3283 switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
3284 case 0:
3285 blitfun = NULL;
3286 if (dstfmt->BitsPerPixel == 8) {
3287 if ((srcfmt->BytesPerPixel == 4) &&
3288 (srcfmt->Rmask == 0x00FF0000) &&
3289 (srcfmt->Gmask == 0x0000FF00) &&
3290 (srcfmt->Bmask == 0x000000FF)) {
3291 blitfun = Blit_RGB888_index8;
3292 } else if ((srcfmt->BytesPerPixel == 4) &&
3293 (srcfmt->Rmask == 0x3FF00000) &&
3294 (srcfmt->Gmask == 0x000FFC00) &&
3295 (srcfmt->Bmask == 0x000003FF)) {
3296 blitfun = Blit_RGB101010_index8;
3297 } else {
3298 blitfun = BlitNto1;
3299 }
3300 } else {
3301 /* Now the meat, choose the blitter we want */
3302 Uint32 a_need = NO_ALPHA;
3303 if (dstfmt->Amask)
3304 a_need = srcfmt->Amask ? COPY_ALPHA : SET_ALPHA;
3305 table = normal_blit[srcfmt->BytesPerPixel - 1];
3306 for (which = 0; table[which].dstbpp; ++which) {
3307 if (MASKOK(srcfmt->Rmask, table[which].srcR) &&
3308 MASKOK(srcfmt->Gmask, table[which].srcG) &&
3309 MASKOK(srcfmt->Bmask, table[which].srcB) &&
3310 MASKOK(dstfmt->Rmask, table[which].dstR) &&
3311 MASKOK(dstfmt->Gmask, table[which].dstG) &&
3312 MASKOK(dstfmt->Bmask, table[which].dstB) &&
3313 dstfmt->BytesPerPixel == table[which].dstbpp &&
3314 (a_need & table[which].alpha) == a_need &&
3315 ((table[which].blit_features & GetBlitFeatures()) ==
3316 table[which].blit_features))
3317 break;
3318 }
3319 blitfun = table[which].blitfunc;
3320
3321 if (blitfun == BlitNtoN) { /* default C fallback catch-all. Slow! */
3322 if (srcfmt->format == SDL_PIXELFORMAT_ARGB2101010) {
3323 blitfun = Blit2101010toN;
3324 } else if (dstfmt->format == SDL_PIXELFORMAT_ARGB2101010) {
3325 blitfun = BlitNto2101010;
3326 } else if (srcfmt->BytesPerPixel == 4 &&
3327 dstfmt->BytesPerPixel == 4 &&
3328 srcfmt->Rmask == dstfmt->Rmask &&
3329 srcfmt->Gmask == dstfmt->Gmask &&
3330 srcfmt->Bmask == dstfmt->Bmask) {
3331 if (a_need == COPY_ALPHA) {
3332 if (srcfmt->Amask == dstfmt->Amask) {
3333 /* Fastpath C fallback: 32bit RGBA<->RGBA blit with matching RGBA */
3334 blitfun = Blit4to4CopyAlpha;
3335 } else {
3336 blitfun = BlitNtoNCopyAlpha;
3337 }
3338 } else {
3339 /* Fastpath C fallback: 32bit RGB<->RGBA blit with matching RGB */
3340 blitfun = Blit4to4MaskAlpha;
3341 }
3342 } else if (a_need == COPY_ALPHA) {
3343 blitfun = BlitNtoNCopyAlpha;
3344 }
3345 }
3346 }
3347 return (blitfun);
3348
3349 case SDL_COPY_COLORKEY:
3350 /* colorkey blit: Here we don't have too many options, mostly
3351 because RLE is the preferred fast way to deal with this.
3352 If a particular case turns out to be useful we'll add it. */
3353
3354 if (srcfmt->BytesPerPixel == 2 && surface->map->identity)
3355 return Blit2to2Key;
3356 else if (dstfmt->BytesPerPixel == 1)
3357 return BlitNto1Key;
3358 else {
3359#if SDL_ALTIVEC_BLITTERS
3360 if ((srcfmt->BytesPerPixel == 4) && (dstfmt->BytesPerPixel == 4)
3361 && SDL_HasAltiVec()) {
3362 return Blit32to32KeyAltivec;
3363 } else
3364#endif
3365 if (srcfmt->Amask && dstfmt->Amask) {
3366 return BlitNtoNKeyCopyAlpha;
3367 } else {
3368 return BlitNtoNKey;
3369 }
3370 }
3371 }
3372
3373 return NULL;
3374}
#define SDL_COPY_RLE_MASK
Definition: SDL_blit.h:44
#define SDL_COPY_COLORKEY
Definition: SDL_blit.h:39
void(* SDL_BlitFunc)(SDL_BlitInfo *info)
Definition: SDL_blit.h:73
static void BlitNtoN(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2244
static void BlitNto1Key(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2421
static void Blit2to2Key(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2487
static void BlitNto1(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1991
static void Blit4to4CopyAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2136
#define MASKOK(x, y)
Definition: SDL_blit_N.c:3263
#define NO_ALPHA
Definition: SDL_blit_N.c:3140
#define GetBlitFeatures()
Definition: SDL_blit_N.c:887
static void Blit4to4MaskAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2086
static void Blit_RGB888_index8(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:906
static void Blit_RGB101010_index8(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1016
static const struct blit_table *const normal_blit[]
Definition: SDL_blit_N.c:3258
static void BlitNtoNKey(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2521
#define COPY_ALPHA
Definition: SDL_blit_N.c:3142
static void BlitNtoNCopyAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2363
#define SET_ALPHA
Definition: SDL_blit_N.c:3141
static void BlitNto2101010(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2929
static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2793
static void Blit2101010toN(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:2897
#define SDL_HasAltiVec
GLenum GLsizei GLenum GLenum const void * table
EGLSurface surface
Definition: eglext.h:248
Uint8 BitsPerPixel
Definition: SDL_pixels.h:319
Uint32 blit_features
Definition: SDL_blit_N.c:3148
SDL_BlitFunc blitfunc
Definition: SDL_blit_N.c:3149

References 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_PixelFormat::format, GetBlitFeatures, SDL_PixelFormat::Gmask, MASKOK, NO_ALPHA, normal_blit, NULL, SDL_PixelFormat::Rmask, SDL_COPY_COLORKEY, SDL_COPY_RLE_MASK, SDL_HasAltiVec, SDL_PIXELFORMAT_ARGB2101010, and SET_ALPHA.

Referenced by SDL_CalculateBlit().

Variable Documentation

◆ normal_blit

const struct blit_table* const normal_blit[]
static
Initial value:
= {
}
static const struct blit_table normal_blit_3[]
Definition: SDL_blit_N.c:3178
static const struct blit_table normal_blit_1[]
Definition: SDL_blit_N.c:3152
static const struct blit_table normal_blit_2[]
Definition: SDL_blit_N.c:3157
static const struct blit_table normal_blit_4[]
Definition: SDL_blit_N.c:3214

Definition at line 3258 of file SDL_blit_N.c.

Referenced by SDL_CalculateBlitN().

◆ normal_blit_1

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

Definition at line 3152 of file SDL_blit_N.c.

◆ normal_blit_2

const struct blit_table normal_blit_2[]
static
Initial value:
= {
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00FF0000, 0x0000FF00, 0x000000FF,
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0x000000FF, 0x0000FF00, 0x00FF0000,
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0xFF000000, 0x00FF0000, 0x0000FF00,
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0x0000FF00, 0x00FF0000, 0xFF000000,
{0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0}
}
static void Blit_RGB565_ABGR8888(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1709
static void Blit_RGB565_BGRA8888(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1985
static void Blit_RGB565_RGBA8888(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1847
static void Blit_RGB565_ARGB8888(SDL_BlitInfo *info)
Definition: SDL_blit_N.c:1571

Definition at line 3157 of file SDL_blit_N.c.

◆ normal_blit_3

const struct blit_table normal_blit_3[]
static

Definition at line 3178 of file SDL_blit_N.c.

◆ normal_blit_4

const struct blit_table normal_blit_4[]
static

Definition at line 3214 of file SDL_blit_N.c.

◆ RGB565_ABGR8888_LUT

const Uint32 RGB565_ABGR8888_LUT[512]
static

Definition at line 1577 of file SDL_blit_N.c.

Referenced by Blit_RGB565_ABGR8888().

◆ RGB565_ARGB8888_LUT

const Uint32 RGB565_ARGB8888_LUT[512]
static

Definition at line 1439 of file SDL_blit_N.c.

Referenced by Blit_RGB565_ARGB8888().

◆ RGB565_BGRA8888_LUT

const Uint32 RGB565_BGRA8888_LUT[512]
static

Definition at line 1853 of file SDL_blit_N.c.

Referenced by Blit_RGB565_BGRA8888().

◆ RGB565_RGBA8888_LUT

const Uint32 RGB565_RGBA8888_LUT[512]
static

Definition at line 1715 of file SDL_blit_N.c.

Referenced by Blit_RGB565_RGBA8888().