mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-06-02 02:30:27 +00:00
Added support for blitting SDL_PIXELFORMAT_INDEX1LSB
Fixes https://github.com/libsdl-org/SDL/issues/7844
This commit is contained in:
parent
d97423ebab
commit
a3d4fd71c3
|
@ -45,6 +45,24 @@ static void BlitBto1(SDL_BlitInfo *info)
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
if (map) {
|
if (map) {
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (1) {
|
||||||
|
*dst = map[bit];
|
||||||
|
}
|
||||||
|
dst++;
|
||||||
|
byte >>= 1;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
|
@ -61,6 +79,25 @@ static void BlitBto1(SDL_BlitInfo *info)
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (1) {
|
||||||
|
*dst = bit;
|
||||||
|
}
|
||||||
|
dst++;
|
||||||
|
byte >>= 1;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
|
@ -80,6 +117,7 @@ static void BlitBto1(SDL_BlitInfo *info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void BlitBto2(SDL_BlitInfo *info)
|
static void BlitBto2(SDL_BlitInfo *info)
|
||||||
{
|
{
|
||||||
|
@ -99,6 +137,24 @@ static void BlitBto2(SDL_BlitInfo *info)
|
||||||
map = (Uint16 *)info->table;
|
map = (Uint16 *)info->table;
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (1) {
|
||||||
|
*dst = map[bit];
|
||||||
|
}
|
||||||
|
byte >>= 1;
|
||||||
|
dst++;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
|
@ -116,6 +172,7 @@ static void BlitBto2(SDL_BlitInfo *info)
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void BlitBto3(SDL_BlitInfo *info)
|
static void BlitBto3(SDL_BlitInfo *info)
|
||||||
{
|
{
|
||||||
|
@ -134,6 +191,27 @@ static void BlitBto3(SDL_BlitInfo *info)
|
||||||
map = info->table;
|
map = info->table;
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (1) {
|
||||||
|
o = bit * 4;
|
||||||
|
dst[0] = map[o++];
|
||||||
|
dst[1] = map[o++];
|
||||||
|
dst[2] = map[o++];
|
||||||
|
}
|
||||||
|
byte >>= 1;
|
||||||
|
dst += 3;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
|
@ -154,6 +232,7 @@ static void BlitBto3(SDL_BlitInfo *info)
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void BlitBto4(SDL_BlitInfo *info)
|
static void BlitBto4(SDL_BlitInfo *info)
|
||||||
{
|
{
|
||||||
|
@ -173,6 +252,24 @@ static void BlitBto4(SDL_BlitInfo *info)
|
||||||
map = (Uint32 *)info->table;
|
map = (Uint32 *)info->table;
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (1) {
|
||||||
|
*dst = map[bit];
|
||||||
|
}
|
||||||
|
byte >>= 1;
|
||||||
|
dst++;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
|
@ -190,6 +287,7 @@ static void BlitBto4(SDL_BlitInfo *info)
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void BlitBto1Key(SDL_BlitInfo *info)
|
static void BlitBto1Key(SDL_BlitInfo *info)
|
||||||
{
|
{
|
||||||
|
@ -207,6 +305,24 @@ static void BlitBto1Key(SDL_BlitInfo *info)
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
if (palmap) {
|
if (palmap) {
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (bit != ckey) {
|
||||||
|
*dst = palmap[bit];
|
||||||
|
}
|
||||||
|
dst++;
|
||||||
|
byte >>= 1;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
|
@ -223,6 +339,25 @@ static void BlitBto1Key(SDL_BlitInfo *info)
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (bit != ckey) {
|
||||||
|
*dst = bit;
|
||||||
|
}
|
||||||
|
dst++;
|
||||||
|
byte >>= 1;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
|
@ -242,6 +377,7 @@ static void BlitBto1Key(SDL_BlitInfo *info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void BlitBto2Key(SDL_BlitInfo *info)
|
static void BlitBto2Key(SDL_BlitInfo *info)
|
||||||
{
|
{
|
||||||
|
@ -259,6 +395,24 @@ static void BlitBto2Key(SDL_BlitInfo *info)
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
dstskip /= 2;
|
dstskip /= 2;
|
||||||
|
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (bit != ckey) {
|
||||||
|
*dstp = ((Uint16 *)palmap)[bit];
|
||||||
|
}
|
||||||
|
byte >>= 1;
|
||||||
|
dstp++;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dstp += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
|
@ -276,6 +430,7 @@ static void BlitBto2Key(SDL_BlitInfo *info)
|
||||||
dstp += dstskip;
|
dstp += dstskip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void BlitBto3Key(SDL_BlitInfo *info)
|
static void BlitBto3Key(SDL_BlitInfo *info)
|
||||||
{
|
{
|
||||||
|
@ -292,6 +447,24 @@ static void BlitBto3Key(SDL_BlitInfo *info)
|
||||||
/* Set up some basic variables */
|
/* Set up some basic variables */
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (bit != ckey) {
|
||||||
|
SDL_memcpy(dst, &palmap[bit * 4], 3);
|
||||||
|
}
|
||||||
|
byte >>= 1;
|
||||||
|
dst += 3;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
|
@ -309,6 +482,7 @@ static void BlitBto3Key(SDL_BlitInfo *info)
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void BlitBto4Key(SDL_BlitInfo *info)
|
static void BlitBto4Key(SDL_BlitInfo *info)
|
||||||
{
|
{
|
||||||
|
@ -326,6 +500,24 @@ static void BlitBto4Key(SDL_BlitInfo *info)
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
dstskip /= 4;
|
dstskip /= 4;
|
||||||
|
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (bit != ckey) {
|
||||||
|
*dstp = ((Uint32 *)palmap)[bit];
|
||||||
|
}
|
||||||
|
byte >>= 1;
|
||||||
|
dstp++;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dstp += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
|
@ -343,6 +535,7 @@ static void BlitBto4Key(SDL_BlitInfo *info)
|
||||||
dstp += dstskip;
|
dstp += dstskip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void BlitBtoNAlpha(SDL_BlitInfo *info)
|
static void BlitBtoNAlpha(SDL_BlitInfo *info)
|
||||||
{
|
{
|
||||||
|
@ -365,6 +558,29 @@ static void BlitBtoNAlpha(SDL_BlitInfo *info)
|
||||||
dstbpp = dstfmt->BytesPerPixel;
|
dstbpp = dstfmt->BytesPerPixel;
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (1) {
|
||||||
|
sR = srcpal[bit].r;
|
||||||
|
sG = srcpal[bit].g;
|
||||||
|
sB = srcpal[bit].b;
|
||||||
|
DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA);
|
||||||
|
ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
|
||||||
|
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
|
||||||
|
}
|
||||||
|
byte >>= 1;
|
||||||
|
dst += dstbpp;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
|
@ -387,6 +603,7 @@ static void BlitBtoNAlpha(SDL_BlitInfo *info)
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
|
static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
|
||||||
{
|
{
|
||||||
|
@ -411,6 +628,29 @@ static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
|
||||||
dstbpp = dstfmt->BytesPerPixel;
|
dstbpp = dstfmt->BytesPerPixel;
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (bit != ckey) {
|
||||||
|
sR = srcpal[bit].r;
|
||||||
|
sG = srcpal[bit].g;
|
||||||
|
sB = srcpal[bit].b;
|
||||||
|
DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA);
|
||||||
|
ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
|
||||||
|
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
|
||||||
|
}
|
||||||
|
byte >>= 1;
|
||||||
|
dst += dstbpp;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
|
@ -433,6 +673,7 @@ static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const SDL_BlitFunc bitmap_blit[] = {
|
static const SDL_BlitFunc bitmap_blit[] = {
|
||||||
(SDL_BlitFunc)NULL, BlitBto1, BlitBto2, BlitBto3, BlitBto4
|
(SDL_BlitFunc)NULL, BlitBto1, BlitBto2, BlitBto3, BlitBto4
|
||||||
|
|
Loading…
Reference in a new issue