Fixed bug #2199: make SDL_blit_slow handles SDL_PIXELFORMAT_ARGB2101010, storing as RGBA

This commit is contained in:
Sylvain 2022-03-15 17:46:12 +01:00
parent 3bebdaccb7
commit f3e86b9fd3
No known key found for this signature in database
GPG Key ID: 5F87E02E5BC0939E
2 changed files with 33 additions and 18 deletions

View File

@ -231,9 +231,7 @@ SDL_CalculateBlit(SDL_Surface * surface)
if (map->identity && !(map->info.flags & ~SDL_COPY_RLE_DESIRED)) { if (map->identity && !(map->info.flags & ~SDL_COPY_RLE_DESIRED)) {
blit = SDL_BlitCopy; blit = SDL_BlitCopy;
} else if (surface->format->Rloss > 8 || dst->format->Rloss > 8) { } else if (surface->format->Rloss > 8 || dst->format->Rloss > 8) {
/* Greater than 8 bits per channel not supported yet */ blit = SDL_Blit_Slow;
SDL_InvalidateMap(map);
return SDL_SetError("Blit combination not supported");
} }
#if SDL_HAVE_BLIT_0 #if SDL_HAVE_BLIT_0
else if (surface->format->BitsPerPixel < 8 && else if (surface->format->BitsPerPixel < 8 &&

View File

@ -46,6 +46,8 @@ SDL_Blit_Slow(SDL_BlitInfo * info)
SDL_PixelFormat *dst_fmt = info->dst_fmt; SDL_PixelFormat *dst_fmt = info->dst_fmt;
int srcbpp = src_fmt->BytesPerPixel; int srcbpp = src_fmt->BytesPerPixel;
int dstbpp = dst_fmt->BytesPerPixel; int dstbpp = dst_fmt->BytesPerPixel;
int srcfmt_isnot_2101010 = (src_fmt->format != SDL_PIXELFORMAT_ARGB2101010);
int dstfmt_isnot_2101010 = (dst_fmt->format != SDL_PIXELFORMAT_ARGB2101010);
Uint32 rgbmask = ~src_fmt->Amask; Uint32 rgbmask = ~src_fmt->Amask;
Uint32 ckey = info->colorkey & rgbmask; Uint32 ckey = info->colorkey & rgbmask;
@ -62,14 +64,19 @@ SDL_Blit_Slow(SDL_BlitInfo * info)
while (n--) { while (n--) {
srcx = posx >> 16; srcx = posx >> 16;
src = (info->src + (srcy * info->src_pitch) + (srcx * srcbpp)); src = (info->src + (srcy * info->src_pitch) + (srcx * srcbpp));
if (srcfmt_isnot_2101010) {
if (src_fmt->Amask) { if (src_fmt->Amask) {
DISEMBLE_RGBA(src, srcbpp, src_fmt, srcpixel, srcR, srcG, DISEMBLE_RGBA(src, srcbpp, src_fmt, srcpixel, srcR, srcG, srcB, srcA);
srcB, srcA);
} else { } else {
DISEMBLE_RGB(src, srcbpp, src_fmt, srcpixel, srcR, srcG, DISEMBLE_RGB(src, srcbpp, src_fmt, srcpixel, srcR, srcG, srcB);
srcB);
srcA = 0xFF; srcA = 0xFF;
} }
} else {
/* SDL_PIXELFORMAT_ARGB2101010 */
srcpixel = *((Uint32 *)(src));
RGBA_FROM_ARGB2101010(srcpixel, srcR, srcG, srcB, srcA);
}
if (flags & SDL_COPY_COLORKEY) { if (flags & SDL_COPY_COLORKEY) {
/* srcpixel isn't set for 24 bpp */ /* srcpixel isn't set for 24 bpp */
if (srcbpp == 3) { if (srcbpp == 3) {
@ -82,14 +89,18 @@ SDL_Blit_Slow(SDL_BlitInfo * info)
continue; continue;
} }
} }
if (dstfmt_isnot_2101010) {
if (dst_fmt->Amask) { if (dst_fmt->Amask) {
DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA);
dstB, dstA);
} else { } else {
DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB);
dstB);
dstA = 0xFF; dstA = 0xFF;
} }
} else {
/* SDL_PIXELFORMAT_ARGB2101010 */
dstpixel = *((Uint32 *)(dst));
RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA);
}
if (flags & SDL_COPY_MODULATE_COLOR) { if (flags & SDL_COPY_MODULATE_COLOR) {
srcR = (srcR * modulateR) / 255; srcR = (srcR * modulateR) / 255;
@ -151,11 +162,17 @@ SDL_Blit_Slow(SDL_BlitInfo * info)
dstA = 255; dstA = 255;
break; break;
} }
if (dstfmt_isnot_2101010) {
if (dst_fmt->Amask) { if (dst_fmt->Amask) {
ASSEMBLE_RGBA(dst, dstbpp, dst_fmt, dstR, dstG, dstB, dstA); ASSEMBLE_RGBA(dst, dstbpp, dst_fmt, dstR, dstG, dstB, dstA);
} else { } else {
ASSEMBLE_RGB(dst, dstbpp, dst_fmt, dstR, dstG, dstB); ASSEMBLE_RGB(dst, dstbpp, dst_fmt, dstR, dstG, dstB);
} }
} else {
Uint32 Pixel;
ARGB2101010_FROM_RGBA(Pixel, dstR, dstG, dstB, dstA);
*(Uint32 *)dst = Pixel;
}
posx += incx; posx += incx;
dst += dstbpp; dst += dstbpp;
} }