Faster blit colorkey or not, applied to bpp: 3->4 and 4->3 ===== BlitNtoNKey ======== ABGR8888 -> BGR24 : faster x3 (2168709 -> 562738) ABGR8888 -> RGB24 : faster x3 (2165055 -> 567458) ARGB8888 -> BGR24 : faster x3 (2169109 -> 564338) ARGB8888 -> RGB24 : faster x3 (2165266 -> 567081) BGR24 -> ABGR8888 : faster x3 (2997675 -> 891636) BGR24 -> ARGB8888 : faster x3 (2985449 -> 892028) BGR24 -> BGR888 : faster x3 (2961611 -> 891913) BGR24 -> BGRA8888 : faster x3 (3116305 -> 891534) BGR24 -> BGRX8888 : faster x3 (3179654 -> 896978) BGR24 -> RGB888 : faster x3 (2968191 -> 895112) BGR24 -> RGBA8888 : faster x3 (2998428 -> 893147) BGR24 -> RGBX8888 : faster x3 (2976529 -> 914853) BGR888 -> BGR24 : faster x3 (2161906 -> 563921) BGR888 -> RGB24 : faster x3 (2168228 -> 566634) BGRA8888 -> BGR24 : faster x4 (2270501 -> 561873) BGRA8888 -> RGB24 : faster x3 (2163179 -> 567330) BGRX8888 -> BGR24 : faster x3 (2162911 -> 562322) BGRX8888 -> RGB24 : faster x3 (2169617 -> 570927) RGB24 -> ABGR8888 : faster x3 (2977061 -> 925975) RGB24 -> ARGB8888 : faster x3 (2978148 -> 923680) RGB24 -> BGR888 : faster x3 (3001413 -> 935074) RGB24 -> BGRA8888 : faster x3 (2959003 -> 924096) RGB24 -> BGRX8888 : faster x3 (2965240 -> 927100) RGB24 -> RGB888 : faster x3 (2983921 -> 926063) RGB24 -> RGBA8888 : faster x3 (2963908 -> 925457) RGB24 -> RGBX8888 : faster x3 (2967957 -> 931700) RGB888 -> BGR24 : faster x3 (2173299 -> 563226) RGB888 -> RGB24 : faster x3 (2218374 -> 566164) RGBA8888 -> BGR24 : faster x3 (2166355 -> 561381) RGBA8888 -> RGB24 : faster x3 (2170322 -> 566729) RGBX8888 -> BGR24 : faster x3 (2168524 -> 564072) RGBX8888 -> RGB24 : faster x3 (2163680 -> 566956) ===== BlitNtoN ======== BGR24 -> BGRA8888 : faster x3 (2458958 -> 797557) BGR24 -> BGRX8888 : faster x3 (2486085 -> 797745) BGR24 -> RGBA8888 : faster x3 (2422116 -> 797637) BGR24 -> RGBX8888 : faster x3 (2454426 -> 799085) BGRA8888 -> BGR24 : faster x4 (2468206 -> 524486) BGRA8888 -> RGB24 : faster x4 (2463581 -> 525561) BGRX8888 -> BGR24 : faster x4 (2583355 -> 524468) BGRX8888 -> RGB24 : faster x4 (2477242 -> 524284) RGB24 -> BGRA8888 : faster x2 (2453414 -> 818415) RGB24 -> BGRX8888 : faster x3 (2414915 -> 800863) RGB24 -> RGBA8888 : faster x3 (2461114 -> 798148) RGB24 -> RGBX8888 : faster x3 (2400922 -> 799203) RGBA8888 -> BGR24 : faster x4 (2494472 -> 526428) RGBA8888 -> RGB24 : faster x4 (2462260 -> 526791) RGBX8888 -> BGR24 : faster x4 (2541115 -> 524390) RGBX8888 -> RGB24 : faster x4 (2469059 -> 525416)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
diff --git a/src/video/SDL_blit_N.c b/src/video/SDL_blit_N.c
index b566f7e..5908285 100644
--- a/src/video/SDL_blit_N.c
+++ b/src/video/SDL_blit_N.c
@@ -2219,7 +2219,7 @@ BlitNtoN(SDL_BlitInfo * info)
int dstbpp = dstfmt->BytesPerPixel;
unsigned alpha = dstfmt->Amask ? info->a : 0;
- /* Any src/dst 8888, not CopyAlpha, no ARGB2101010 */
+ /* Blit with permutation: 4->4 */
if (srcbpp == 4 && dstbpp == 4 &&
srcfmt->format != SDL_PIXELFORMAT_ARGB2101010 &&
dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
@@ -2252,6 +2252,64 @@ BlitNtoN(SDL_BlitInfo * info)
return;
}
+ /* Blit with permutation: 4->3 */
+ if (srcbpp == 4 && dstbpp == 3 &&
+ srcfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
+
+ Uint32 *src32 = (Uint32*)src;
+
+ /* Find the appropriate permutation */
+ int r, g, b, a;
+ get_permutation(srcfmt, dstfmt, &r, &g, &b, &a, NULL);
+
+ while (height--) {
+ /* *INDENT-OFF* */
+ DUFFS_LOOP(
+ {
+ Uint8 *s8 = (Uint8 *)src32;
+ dst[0] = s8[r];
+ dst[1] = s8[g];
+ dst[2] = s8[b];
+ ++src32;
+ dst += 3;
+ }, width);
+ /* *INDENT-ON* */
+ src32 = (Uint32 *)((Uint8 *)src32 + srcskip);
+ dst += dstskip;
+ }
+ return;
+ }
+
+ /* Blit with permutation: 3->4 */
+ if (srcbpp == 3 && dstbpp == 4 &&
+ dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
+
+ Uint32 *dst32 = (Uint32*)dst;
+
+ /* Find the appropriate permutation */
+ int missing = 0, r, g, b, a;
+ get_permutation(srcfmt, dstfmt, &r, &g, &b, &a, &missing);
+
+ while (height--) {
+ /* *INDENT-OFF* */
+ DUFFS_LOOP(
+ {
+ Uint8 *d8 = (Uint8 *)dst32;
+ d8[0] = src[r];
+ d8[1] = src[g];
+ d8[2] = src[b];
+ d8[3] = src[a];
+ d8[missing] = alpha;
+ src += 3;
+ ++dst32;
+ }, width);
+ /* *INDENT-ON* */
+ src += srcskip;
+ dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip);
+ }
+ return;
+ }
+
while (height--) {
/* *INDENT-OFF* */
DUFFS_LOOP(
@@ -2287,7 +2345,7 @@ BlitNtoNCopyAlpha(SDL_BlitInfo * info)
int dstbpp = dstfmt->BytesPerPixel;
int c;
- /* Any src/dst 8888 for CopyAlpha, no ARGB2101010 */
+ /* Blit with permutation: 4->4 */
if (srcbpp == 4 && dstbpp == 4 &&
srcfmt->format != SDL_PIXELFORMAT_ARGB2101010 &&
dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
@@ -2499,7 +2557,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
}
}
- /* Any src/dst 8888, not CopyAlpha, no ARGB2101010 */
+ /* Blit with permutation: 4->4 */
if (srcbpp == 4 && dstbpp == 4 &&
srcfmt->format != SDL_PIXELFORMAT_ARGB2101010 &&
dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
@@ -2598,6 +2656,77 @@ BlitNtoNKey(SDL_BlitInfo * info)
return;
}
+ /* Blit with permutation: 4->3 */
+ if (srcbpp == 4 && dstbpp == 3 &&
+ srcfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
+
+ Uint32 *src32 = (Uint32*)src;
+
+ /* Find the appropriate permutation */
+ int r, g, b, a;
+ get_permutation(srcfmt, dstfmt, &r, &g, &b, &a, NULL);
+
+ while (height--) {
+ /* *INDENT-OFF* */
+ DUFFS_LOOP(
+ {
+ if ((*src32 & rgbmask) != ckey) {
+ Uint8 *s8 = (Uint8 *)src32;
+ dst[0] = s8[r];
+ dst[1] = s8[g];
+ dst[2] = s8[b];
+ }
+ ++src32;
+ dst += 3;
+ }, width);
+ /* *INDENT-ON* */
+ src32 = (Uint32 *)((Uint8 *)src32 + srcskip);
+ dst += dstskip;
+ }
+ return;
+ }
+
+ /* Blit with permutation: 3->4 */
+ if (srcbpp == 3 && dstbpp == 4 &&
+ dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
+
+ Uint32 *dst32 = (Uint32*)dst;
+
+ Uint8 k0 = ckey & 0xFF;
+ Uint8 k1 = (ckey >> 8) & 0xFF;
+ Uint8 k2 = (ckey >> 16) & 0xFF;
+
+ /* Find the appropriate permutation */
+ int missing = 0, r, g, b, a;
+ get_permutation(srcfmt, dstfmt, &r, &g, &b, &a, &missing);
+
+ while (height--) {
+ /* *INDENT-OFF* */
+ DUFFS_LOOP(
+ {
+ Uint8 s0 = src[0];
+ Uint8 s1 = src[1];
+ Uint8 s2 = src[2];
+
+ if (k0 != s0 || k1 != s1 || k2 != s2) {
+ Uint8 *d8 = (Uint8 *)dst32;
+ d8[0] = src[r];
+ d8[1] = src[g];
+ d8[2] = src[b];
+ d8[3] = src[a];
+ d8[missing] = alpha;
+ }
+ src += 3;
+ ++dst32;
+ }, width);
+ /* *INDENT-ON* */
+ src += srcskip;
+ dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip);
+
+ }
+ return;
+ }
+
while (height--) {
/* *INDENT-OFF* */
DUFFS_LOOP(
@@ -2674,7 +2803,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
return;
}
- /* Any src/dst 8888 for CopyAlpha, no ARGB2101010 */
+ /* Blit with permutation: 4->4 */
if (srcbpp == 4 && dstbpp == 4 &&
srcfmt->format != SDL_PIXELFORMAT_ARGB2101010 &&
dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {