mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 11:28:15 +00:00
Extend blitting support for all <8bpp formats
This commit is contained in:

committed by
Sam Lantinga

parent
753bbd199e
commit
773ec1cfcb
@@ -26,8 +26,11 @@
|
|||||||
|
|
||||||
/* Functions to blit from bitmaps to other surfaces */
|
/* Functions to blit from bitmaps to other surfaces */
|
||||||
|
|
||||||
static void BlitBto1(SDL_BlitInfo *info)
|
SDL_FORCE_INLINE void BlitBto1(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||||
{
|
{
|
||||||
|
const Uint32 mask = (1 << srcbpp) - 1;
|
||||||
|
const Uint32 align = (8 / srcbpp) - 1;
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
int width, height;
|
int width, height;
|
||||||
Uint8 *src, *map, *dst;
|
Uint8 *src, *map, *dst;
|
||||||
@@ -41,22 +44,28 @@ static void BlitBto1(SDL_BlitInfo *info)
|
|||||||
dst = info->dst;
|
dst = info->dst;
|
||||||
dstskip = info->dst_skip;
|
dstskip = info->dst_skip;
|
||||||
map = info->table;
|
map = info->table;
|
||||||
|
|
||||||
|
if (srcbpp == 4)
|
||||||
|
srcskip += width - (width + 1) / 2;
|
||||||
|
else if (srcbpp == 2)
|
||||||
|
srcskip += width - (width + 3) / 4;
|
||||||
|
else if (srcbpp == 1)
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
if (map) {
|
if (map) {
|
||||||
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x01);
|
bit = (byte & mask);
|
||||||
if (1) {
|
if (1) {
|
||||||
*dst = map[bit];
|
*dst = map[bit];
|
||||||
}
|
}
|
||||||
dst++;
|
dst++;
|
||||||
byte >>= 1;
|
byte >>= srcbpp;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
@@ -65,34 +74,34 @@ static void BlitBto1(SDL_BlitInfo *info)
|
|||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x80) >> 7;
|
bit = (byte >> (8 - srcbpp)) & mask;
|
||||||
if (1) {
|
if (1) {
|
||||||
*dst = map[bit];
|
*dst = map[bit];
|
||||||
}
|
}
|
||||||
dst++;
|
dst++;
|
||||||
byte <<= 1;
|
byte <<= srcbpp;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x01);
|
bit = (byte & mask);
|
||||||
if (1) {
|
if (1) {
|
||||||
*dst = bit;
|
*dst = bit;
|
||||||
}
|
}
|
||||||
dst++;
|
dst++;
|
||||||
byte >>= 1;
|
byte >>= srcbpp;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
@@ -101,15 +110,15 @@ static void BlitBto1(SDL_BlitInfo *info)
|
|||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x80) >> 7;
|
bit = (byte >> (8 - srcbpp)) & mask;
|
||||||
if (1) {
|
if (1) {
|
||||||
*dst = bit;
|
*dst = bit;
|
||||||
}
|
}
|
||||||
dst++;
|
dst++;
|
||||||
byte <<= 1;
|
byte <<= srcbpp;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
@@ -118,8 +127,11 @@ static void BlitBto1(SDL_BlitInfo *info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBto2(SDL_BlitInfo *info)
|
SDL_FORCE_INLINE void BlitBto2(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||||
{
|
{
|
||||||
|
const Uint32 mask = (1 << srcbpp) - 1;
|
||||||
|
const Uint32 align = (8 / srcbpp) - 1;
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
int width, height;
|
int width, height;
|
||||||
Uint8 *src;
|
Uint8 *src;
|
||||||
@@ -134,20 +146,26 @@ static void BlitBto2(SDL_BlitInfo *info)
|
|||||||
dst = (Uint16 *)info->dst;
|
dst = (Uint16 *)info->dst;
|
||||||
dstskip = info->dst_skip / 2;
|
dstskip = info->dst_skip / 2;
|
||||||
map = (Uint16 *)info->table;
|
map = (Uint16 *)info->table;
|
||||||
|
|
||||||
|
if (srcbpp == 4)
|
||||||
|
srcskip += width - (width + 1) / 2;
|
||||||
|
else if (srcbpp == 2)
|
||||||
|
srcskip += width - (width + 3) / 4;
|
||||||
|
else if (srcbpp == 1)
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x01);
|
bit = (byte & mask);
|
||||||
if (1) {
|
if (1) {
|
||||||
*dst = map[bit];
|
*dst = map[bit];
|
||||||
}
|
}
|
||||||
byte >>= 1;
|
byte >>= srcbpp;
|
||||||
dst++;
|
dst++;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
@@ -157,14 +175,14 @@ static void BlitBto2(SDL_BlitInfo *info)
|
|||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x80) >> 7;
|
bit = (byte >> (8 - srcbpp)) & mask;
|
||||||
if (1) {
|
if (1) {
|
||||||
*dst = map[bit];
|
*dst = map[bit];
|
||||||
}
|
}
|
||||||
byte <<= 1;
|
byte <<= srcbpp;
|
||||||
dst++;
|
dst++;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
@@ -173,8 +191,11 @@ static void BlitBto2(SDL_BlitInfo *info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBto3(SDL_BlitInfo *info)
|
SDL_FORCE_INLINE void BlitBto3(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||||
{
|
{
|
||||||
|
const Uint32 mask = (1 << srcbpp) - 1;
|
||||||
|
const Uint32 align = (8 / srcbpp) - 1;
|
||||||
|
|
||||||
int c, o;
|
int c, o;
|
||||||
int width, height;
|
int width, height;
|
||||||
Uint8 *src, *map, *dst;
|
Uint8 *src, *map, *dst;
|
||||||
@@ -188,23 +209,29 @@ static void BlitBto3(SDL_BlitInfo *info)
|
|||||||
dst = info->dst;
|
dst = info->dst;
|
||||||
dstskip = info->dst_skip;
|
dstskip = info->dst_skip;
|
||||||
map = info->table;
|
map = info->table;
|
||||||
|
|
||||||
|
if (srcbpp == 4)
|
||||||
|
srcskip += width - (width + 1) / 2;
|
||||||
|
else if (srcbpp == 2)
|
||||||
|
srcskip += width - (width + 3) / 4;
|
||||||
|
else if (srcbpp == 1)
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x01);
|
bit = (byte & mask);
|
||||||
if (1) {
|
if (1) {
|
||||||
o = bit * 4;
|
o = bit * 4;
|
||||||
dst[0] = map[o++];
|
dst[0] = map[o++];
|
||||||
dst[1] = map[o++];
|
dst[1] = map[o++];
|
||||||
dst[2] = map[o++];
|
dst[2] = map[o++];
|
||||||
}
|
}
|
||||||
byte >>= 1;
|
byte >>= srcbpp;
|
||||||
dst += 3;
|
dst += 3;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
@@ -214,17 +241,17 @@ static void BlitBto3(SDL_BlitInfo *info)
|
|||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x80) >> 7;
|
bit = (byte >> (8 - srcbpp)) & mask;
|
||||||
if (1) {
|
if (1) {
|
||||||
o = bit * 4;
|
o = bit * 4;
|
||||||
dst[0] = map[o++];
|
dst[0] = map[o++];
|
||||||
dst[1] = map[o++];
|
dst[1] = map[o++];
|
||||||
dst[2] = map[o++];
|
dst[2] = map[o++];
|
||||||
}
|
}
|
||||||
byte <<= 1;
|
byte <<= srcbpp;
|
||||||
dst += 3;
|
dst += 3;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
@@ -233,8 +260,11 @@ static void BlitBto3(SDL_BlitInfo *info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBto4(SDL_BlitInfo *info)
|
SDL_FORCE_INLINE void BlitBto4(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||||
{
|
{
|
||||||
|
const Uint32 mask = (1 << srcbpp) - 1;
|
||||||
|
const Uint32 align = (8 / srcbpp) - 1;
|
||||||
|
|
||||||
int width, height;
|
int width, height;
|
||||||
Uint8 *src;
|
Uint8 *src;
|
||||||
Uint32 *map, *dst;
|
Uint32 *map, *dst;
|
||||||
@@ -249,20 +279,26 @@ static void BlitBto4(SDL_BlitInfo *info)
|
|||||||
dst = (Uint32 *)info->dst;
|
dst = (Uint32 *)info->dst;
|
||||||
dstskip = info->dst_skip / 4;
|
dstskip = info->dst_skip / 4;
|
||||||
map = (Uint32 *)info->table;
|
map = (Uint32 *)info->table;
|
||||||
|
|
||||||
|
if (srcbpp == 4)
|
||||||
|
srcskip += width - (width + 1) / 2;
|
||||||
|
else if (srcbpp == 2)
|
||||||
|
srcskip += width - (width + 3) / 4;
|
||||||
|
else if (srcbpp == 1)
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x01);
|
bit = (byte & mask);
|
||||||
if (1) {
|
if (1) {
|
||||||
*dst = map[bit];
|
*dst = map[bit];
|
||||||
}
|
}
|
||||||
byte >>= 1;
|
byte >>= srcbpp;
|
||||||
dst++;
|
dst++;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
@@ -272,14 +308,14 @@ static void BlitBto4(SDL_BlitInfo *info)
|
|||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x80) >> 7;
|
bit = (byte >> (8 - srcbpp)) & mask;
|
||||||
if (1) {
|
if (1) {
|
||||||
*dst = map[bit];
|
*dst = map[bit];
|
||||||
}
|
}
|
||||||
byte <<= 1;
|
byte <<= srcbpp;
|
||||||
dst++;
|
dst++;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
@@ -288,8 +324,11 @@ static void BlitBto4(SDL_BlitInfo *info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBto1Key(SDL_BlitInfo *info)
|
SDL_FORCE_INLINE void BlitBto1Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||||
{
|
{
|
||||||
|
const Uint32 mask = (1 << srcbpp) - 1;
|
||||||
|
const Uint32 align = (8 / srcbpp) - 1;
|
||||||
|
|
||||||
int width = info->dst_w;
|
int width = info->dst_w;
|
||||||
int height = info->dst_h;
|
int height = info->dst_h;
|
||||||
Uint8 *src = info->src;
|
Uint8 *src = info->src;
|
||||||
@@ -301,22 +340,27 @@ static void BlitBto1Key(SDL_BlitInfo *info)
|
|||||||
int c;
|
int c;
|
||||||
|
|
||||||
/* Set up some basic variables */
|
/* Set up some basic variables */
|
||||||
|
if (srcbpp == 4)
|
||||||
|
srcskip += width - (width + 1) / 2;
|
||||||
|
else if (srcbpp == 2)
|
||||||
|
srcskip += width - (width + 3) / 4;
|
||||||
|
else if (srcbpp == 1)
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
if (palmap) {
|
if (palmap) {
|
||||||
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x01);
|
bit = (byte & mask);
|
||||||
if (bit != ckey) {
|
if (bit != ckey) {
|
||||||
*dst = palmap[bit];
|
*dst = palmap[bit];
|
||||||
}
|
}
|
||||||
dst++;
|
dst++;
|
||||||
byte >>= 1;
|
byte >>= srcbpp;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
@@ -325,34 +369,34 @@ static void BlitBto1Key(SDL_BlitInfo *info)
|
|||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x80) >> 7;
|
bit = (byte >> (8 - srcbpp)) & mask;
|
||||||
if (bit != ckey) {
|
if (bit != ckey) {
|
||||||
*dst = palmap[bit];
|
*dst = palmap[bit];
|
||||||
}
|
}
|
||||||
dst++;
|
dst++;
|
||||||
byte <<= 1;
|
byte <<= srcbpp;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x01);
|
bit = (byte & mask);
|
||||||
if (bit != ckey) {
|
if (bit != ckey) {
|
||||||
*dst = bit;
|
*dst = bit;
|
||||||
}
|
}
|
||||||
dst++;
|
dst++;
|
||||||
byte >>= 1;
|
byte >>= srcbpp;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
@@ -361,15 +405,15 @@ static void BlitBto1Key(SDL_BlitInfo *info)
|
|||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x80) >> 7;
|
bit = (byte >> (8 - srcbpp)) & mask;
|
||||||
if (bit != ckey) {
|
if (bit != ckey) {
|
||||||
*dst = bit;
|
*dst = bit;
|
||||||
}
|
}
|
||||||
dst++;
|
dst++;
|
||||||
byte <<= 1;
|
byte <<= srcbpp;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
@@ -378,8 +422,11 @@ static void BlitBto1Key(SDL_BlitInfo *info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBto2Key(SDL_BlitInfo *info)
|
SDL_FORCE_INLINE void BlitBto2Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||||
{
|
{
|
||||||
|
const Uint32 mask = (1 << srcbpp) - 1;
|
||||||
|
const Uint32 align = (8 / srcbpp) - 1;
|
||||||
|
|
||||||
int width = info->dst_w;
|
int width = info->dst_w;
|
||||||
int height = info->dst_h;
|
int height = info->dst_h;
|
||||||
Uint8 *src = info->src;
|
Uint8 *src = info->src;
|
||||||
@@ -391,21 +438,26 @@ static void BlitBto2Key(SDL_BlitInfo *info)
|
|||||||
int c;
|
int c;
|
||||||
|
|
||||||
/* Set up some basic variables */
|
/* Set up some basic variables */
|
||||||
|
if (srcbpp == 4)
|
||||||
|
srcskip += width - (width + 1) / 2;
|
||||||
|
else if (srcbpp == 2)
|
||||||
|
srcskip += width - (width + 3) / 4;
|
||||||
|
else if (srcbpp == 1)
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
dstskip /= 2;
|
dstskip /= 2;
|
||||||
|
|
||||||
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x01);
|
bit = (byte & mask);
|
||||||
if (bit != ckey) {
|
if (bit != ckey) {
|
||||||
*dstp = ((Uint16 *)palmap)[bit];
|
*dstp = ((Uint16 *)palmap)[bit];
|
||||||
}
|
}
|
||||||
byte >>= 1;
|
byte >>= srcbpp;
|
||||||
dstp++;
|
dstp++;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
@@ -415,14 +467,14 @@ static void BlitBto2Key(SDL_BlitInfo *info)
|
|||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x80) >> 7;
|
bit = (byte >> (8 - srcbpp)) & mask;
|
||||||
if (bit != ckey) {
|
if (bit != ckey) {
|
||||||
*dstp = ((Uint16 *)palmap)[bit];
|
*dstp = ((Uint16 *)palmap)[bit];
|
||||||
}
|
}
|
||||||
byte <<= 1;
|
byte <<= srcbpp;
|
||||||
dstp++;
|
dstp++;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
@@ -431,8 +483,11 @@ static void BlitBto2Key(SDL_BlitInfo *info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBto3Key(SDL_BlitInfo *info)
|
SDL_FORCE_INLINE void BlitBto3Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||||
{
|
{
|
||||||
|
const Uint32 mask = (1 << srcbpp) - 1;
|
||||||
|
const Uint32 align = (8 / srcbpp) - 1;
|
||||||
|
|
||||||
int width = info->dst_w;
|
int width = info->dst_w;
|
||||||
int height = info->dst_h;
|
int height = info->dst_h;
|
||||||
Uint8 *src = info->src;
|
Uint8 *src = info->src;
|
||||||
@@ -444,20 +499,25 @@ static void BlitBto3Key(SDL_BlitInfo *info)
|
|||||||
int c;
|
int c;
|
||||||
|
|
||||||
/* Set up some basic variables */
|
/* Set up some basic variables */
|
||||||
|
if (srcbpp == 4)
|
||||||
|
srcskip += width - (width + 1) / 2;
|
||||||
|
else if (srcbpp == 2)
|
||||||
|
srcskip += width - (width + 3) / 4;
|
||||||
|
else if (srcbpp == 1)
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x01);
|
bit = (byte & mask);
|
||||||
if (bit != ckey) {
|
if (bit != ckey) {
|
||||||
SDL_memcpy(dst, &palmap[bit * 4], 3);
|
SDL_memcpy(dst, &palmap[bit * 4], 3);
|
||||||
}
|
}
|
||||||
byte >>= 1;
|
byte >>= srcbpp;
|
||||||
dst += 3;
|
dst += 3;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
@@ -467,14 +527,14 @@ static void BlitBto3Key(SDL_BlitInfo *info)
|
|||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x80) >> 7;
|
bit = (byte >> (8 - srcbpp)) & mask;
|
||||||
if (bit != ckey) {
|
if (bit != ckey) {
|
||||||
SDL_memcpy(dst, &palmap[bit * 4], 3);
|
SDL_memcpy(dst, &palmap[bit * 4], 3);
|
||||||
}
|
}
|
||||||
byte <<= 1;
|
byte <<= srcbpp;
|
||||||
dst += 3;
|
dst += 3;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
@@ -483,8 +543,11 @@ static void BlitBto3Key(SDL_BlitInfo *info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBto4Key(SDL_BlitInfo *info)
|
SDL_FORCE_INLINE void BlitBto4Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||||
{
|
{
|
||||||
|
const Uint32 mask = (1 << srcbpp) - 1;
|
||||||
|
const Uint32 align = (8 / srcbpp) - 1;
|
||||||
|
|
||||||
int width = info->dst_w;
|
int width = info->dst_w;
|
||||||
int height = info->dst_h;
|
int height = info->dst_h;
|
||||||
Uint8 *src = info->src;
|
Uint8 *src = info->src;
|
||||||
@@ -496,21 +559,26 @@ static void BlitBto4Key(SDL_BlitInfo *info)
|
|||||||
int c;
|
int c;
|
||||||
|
|
||||||
/* Set up some basic variables */
|
/* Set up some basic variables */
|
||||||
|
if (srcbpp == 4)
|
||||||
|
srcskip += width - (width + 1) / 2;
|
||||||
|
else if (srcbpp == 2)
|
||||||
|
srcskip += width - (width + 3) / 4;
|
||||||
|
else if (srcbpp == 1)
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
dstskip /= 4;
|
dstskip /= 4;
|
||||||
|
|
||||||
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x01);
|
bit = (byte & mask);
|
||||||
if (bit != ckey) {
|
if (bit != ckey) {
|
||||||
*dstp = ((Uint32 *)palmap)[bit];
|
*dstp = ((Uint32 *)palmap)[bit];
|
||||||
}
|
}
|
||||||
byte >>= 1;
|
byte >>= srcbpp;
|
||||||
dstp++;
|
dstp++;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
@@ -520,14 +588,14 @@ static void BlitBto4Key(SDL_BlitInfo *info)
|
|||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x80) >> 7;
|
bit = (byte >> (8 - srcbpp)) & mask;
|
||||||
if (bit != ckey) {
|
if (bit != ckey) {
|
||||||
*dstp = ((Uint32 *)palmap)[bit];
|
*dstp = ((Uint32 *)palmap)[bit];
|
||||||
}
|
}
|
||||||
byte <<= 1;
|
byte <<= srcbpp;
|
||||||
dstp++;
|
dstp++;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
@@ -536,8 +604,11 @@ static void BlitBto4Key(SDL_BlitInfo *info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBtoNAlpha(SDL_BlitInfo *info)
|
SDL_FORCE_INLINE void BlitBtoNAlpha(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||||
{
|
{
|
||||||
|
const Uint32 mask = (1 << srcbpp) - 1;
|
||||||
|
const Uint32 align = (8 / srcbpp) - 1;
|
||||||
|
|
||||||
int width = info->dst_w;
|
int width = info->dst_w;
|
||||||
int height = info->dst_h;
|
int height = info->dst_h;
|
||||||
Uint8 *src = info->src;
|
Uint8 *src = info->src;
|
||||||
@@ -555,16 +626,21 @@ static void BlitBtoNAlpha(SDL_BlitInfo *info)
|
|||||||
|
|
||||||
/* Set up some basic variables */
|
/* Set up some basic variables */
|
||||||
dstbpp = dstfmt->BytesPerPixel;
|
dstbpp = dstfmt->BytesPerPixel;
|
||||||
|
if (srcbpp == 4)
|
||||||
|
srcskip += width - (width + 1) / 2;
|
||||||
|
else if (srcbpp == 2)
|
||||||
|
srcskip += width - (width + 3) / 4;
|
||||||
|
else if (srcbpp == 1)
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x01);
|
bit = (byte & mask);
|
||||||
if (1) {
|
if (1) {
|
||||||
sR = srcpal[bit].r;
|
sR = srcpal[bit].r;
|
||||||
sG = srcpal[bit].g;
|
sG = srcpal[bit].g;
|
||||||
@@ -573,7 +649,7 @@ static void BlitBtoNAlpha(SDL_BlitInfo *info)
|
|||||||
ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
|
ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
|
||||||
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
|
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
|
||||||
}
|
}
|
||||||
byte >>= 1;
|
byte >>= srcbpp;
|
||||||
dst += dstbpp;
|
dst += dstbpp;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
@@ -583,10 +659,10 @@ static void BlitBtoNAlpha(SDL_BlitInfo *info)
|
|||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x80) >> 7;
|
bit = (byte >> (8 - srcbpp)) & mask;
|
||||||
if (1) {
|
if (1) {
|
||||||
sR = srcpal[bit].r;
|
sR = srcpal[bit].r;
|
||||||
sG = srcpal[bit].g;
|
sG = srcpal[bit].g;
|
||||||
@@ -595,7 +671,7 @@ static void BlitBtoNAlpha(SDL_BlitInfo *info)
|
|||||||
ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
|
ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
|
||||||
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
|
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
|
||||||
}
|
}
|
||||||
byte <<= 1;
|
byte <<= srcbpp;
|
||||||
dst += dstbpp;
|
dst += dstbpp;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
@@ -604,8 +680,11 @@ static void BlitBtoNAlpha(SDL_BlitInfo *info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
|
SDL_FORCE_INLINE void BlitBtoNAlphaKey(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||||
{
|
{
|
||||||
|
const Uint32 mask = (1 << srcbpp) - 1;
|
||||||
|
const Uint32 align = (8 / srcbpp) - 1;
|
||||||
|
|
||||||
int width = info->dst_w;
|
int width = info->dst_w;
|
||||||
int height = info->dst_h;
|
int height = info->dst_h;
|
||||||
Uint8 *src = info->src;
|
Uint8 *src = info->src;
|
||||||
@@ -625,16 +704,21 @@ static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
|
|||||||
|
|
||||||
/* Set up some basic variables */
|
/* Set up some basic variables */
|
||||||
dstbpp = dstfmt->BytesPerPixel;
|
dstbpp = dstfmt->BytesPerPixel;
|
||||||
|
if (srcbpp == 4)
|
||||||
|
srcskip += width - (width + 1) / 2;
|
||||||
|
else if (srcbpp == 2)
|
||||||
|
srcskip += width - (width + 3) / 4;
|
||||||
|
else if (srcbpp == 1)
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x01);
|
bit = (byte & mask);
|
||||||
if (bit != ckey) {
|
if (bit != ckey) {
|
||||||
sR = srcpal[bit].r;
|
sR = srcpal[bit].r;
|
||||||
sG = srcpal[bit].g;
|
sG = srcpal[bit].g;
|
||||||
@@ -643,7 +727,7 @@ static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
|
|||||||
ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
|
ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
|
||||||
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
|
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
|
||||||
}
|
}
|
||||||
byte >>= 1;
|
byte >>= srcbpp;
|
||||||
dst += dstbpp;
|
dst += dstbpp;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
@@ -653,10 +737,10 @@ static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
|
|||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
if (!(c & 7)) {
|
if (!(c & align)) {
|
||||||
byte = *src++;
|
byte = *src++;
|
||||||
}
|
}
|
||||||
bit = (byte & 0x80) >> 7;
|
bit = (byte >> (8 - srcbpp)) & mask;
|
||||||
if (bit != ckey) {
|
if (bit != ckey) {
|
||||||
sR = srcpal[bit].r;
|
sR = srcpal[bit].r;
|
||||||
sG = srcpal[bit].g;
|
sG = srcpal[bit].g;
|
||||||
@@ -665,7 +749,7 @@ static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
|
|||||||
ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
|
ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
|
||||||
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
|
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
|
||||||
}
|
}
|
||||||
byte <<= 1;
|
byte <<= srcbpp;
|
||||||
dst += dstbpp;
|
dst += dstbpp;
|
||||||
}
|
}
|
||||||
src += srcskip;
|
src += srcskip;
|
||||||
@@ -674,115 +758,221 @@ static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const SDL_BlitFunc bitmap_blit[] = {
|
|
||||||
(SDL_BlitFunc)NULL, BlitBto1, BlitBto2, BlitBto3, BlitBto4
|
|
||||||
};
|
|
||||||
|
|
||||||
static const SDL_BlitFunc colorkey_blit[] = {
|
|
||||||
(SDL_BlitFunc)NULL, BlitBto1Key, BlitBto2Key, BlitBto3Key, BlitBto4Key
|
|
||||||
};
|
|
||||||
|
|
||||||
static void Blit4bto4(SDL_BlitInfo *info)
|
static void Blit1bto1(SDL_BlitInfo *info) {
|
||||||
{
|
BlitBto1(info, 1);
|
||||||
int width = info->dst_w;
|
|
||||||
int height = info->dst_h;
|
|
||||||
Uint8 *src = info->src;
|
|
||||||
Uint32 *dst = (Uint32 *)info->dst;
|
|
||||||
int srcskip = info->src_skip;
|
|
||||||
int dstskip = info->dst_skip;
|
|
||||||
Uint32 *map = (Uint32 *)info->table;
|
|
||||||
int c;
|
|
||||||
|
|
||||||
/* Set up some basic variables */
|
|
||||||
srcskip += width - (width + 1) / 2;
|
|
||||||
|
|
||||||
while (height--) {
|
|
||||||
Uint8 byte = 0, bit;
|
|
||||||
for (c = 0; c < width; ++c) {
|
|
||||||
if (!(c & 0x1)) {
|
|
||||||
byte = *src++;
|
|
||||||
}
|
|
||||||
bit = (byte & 0xF0) >> 4;
|
|
||||||
if (1) {
|
|
||||||
*dst = map[bit];
|
|
||||||
}
|
|
||||||
byte <<= 4;
|
|
||||||
dst++;
|
|
||||||
}
|
|
||||||
src += srcskip;
|
|
||||||
dst = (Uint32 *)((Uint8 *)dst + dstskip);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Blit4bto4Key(SDL_BlitInfo *info)
|
static void Blit1bto2(SDL_BlitInfo *info) {
|
||||||
{
|
BlitBto2(info, 1);
|
||||||
int width = info->dst_w;
|
|
||||||
int height = info->dst_h;
|
|
||||||
Uint8 *src = info->src;
|
|
||||||
Uint32 *dst = (Uint32 *)info->dst;
|
|
||||||
int srcskip = info->src_skip;
|
|
||||||
int dstskip = info->dst_skip;
|
|
||||||
Uint32 ckey = info->colorkey;
|
|
||||||
Uint32 *map = (Uint32 *)info->table;
|
|
||||||
int c;
|
|
||||||
|
|
||||||
/* Set up some basic variables */
|
|
||||||
srcskip += width - (width + 1) / 2;
|
|
||||||
|
|
||||||
while (height--) {
|
|
||||||
Uint8 byte = 0, bit;
|
|
||||||
for (c = 0; c < width; ++c) {
|
|
||||||
if (!(c & 0x1)) {
|
|
||||||
byte = *src++;
|
|
||||||
}
|
|
||||||
bit = (byte & 0xF0) >> 4;
|
|
||||||
if (bit != ckey) {
|
|
||||||
*dst = map[bit];
|
|
||||||
}
|
|
||||||
byte <<= 4;
|
|
||||||
dst++;
|
|
||||||
}
|
|
||||||
src += srcskip;
|
|
||||||
dst = (Uint32 *)((Uint8 *)dst + dstskip);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Blit1bto3(SDL_BlitInfo *info) {
|
||||||
|
BlitBto3(info, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit1bto4(SDL_BlitInfo *info) {
|
||||||
|
BlitBto4(info, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const SDL_BlitFunc bitmap_blit_1b[] = {
|
||||||
|
(SDL_BlitFunc)NULL, Blit1bto1, Blit1bto2, Blit1bto3, Blit1bto4
|
||||||
|
};
|
||||||
|
|
||||||
|
static void Blit1bto1Key(SDL_BlitInfo *info) {
|
||||||
|
BlitBto1Key(info, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit1bto2Key(SDL_BlitInfo *info) {
|
||||||
|
BlitBto2Key(info, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit1bto3Key(SDL_BlitInfo *info) {
|
||||||
|
BlitBto3Key(info, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit1bto4Key(SDL_BlitInfo *info) {
|
||||||
|
BlitBto4Key(info, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const SDL_BlitFunc colorkey_blit_1b[] = {
|
||||||
|
(SDL_BlitFunc)NULL, Blit1bto1Key, Blit1bto2Key, Blit1bto3Key, Blit1bto4Key
|
||||||
|
};
|
||||||
|
|
||||||
|
static void Blit1btoNAlpha(SDL_BlitInfo *info)
|
||||||
|
{
|
||||||
|
BlitBtoNAlpha(info, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit1btoNAlphaKey(SDL_BlitInfo *info)
|
||||||
|
{
|
||||||
|
BlitBtoNAlphaKey(info, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void Blit2bto1(SDL_BlitInfo *info) {
|
||||||
|
BlitBto1(info, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit2bto2(SDL_BlitInfo *info) {
|
||||||
|
BlitBto2(info, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit2bto3(SDL_BlitInfo *info) {
|
||||||
|
BlitBto3(info, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit2bto4(SDL_BlitInfo *info) {
|
||||||
|
BlitBto4(info, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const SDL_BlitFunc bitmap_blit_2b[] = {
|
||||||
|
(SDL_BlitFunc)NULL, Blit2bto1, Blit2bto2, Blit2bto3, Blit2bto4
|
||||||
|
};
|
||||||
|
|
||||||
|
static void Blit2bto1Key(SDL_BlitInfo *info) {
|
||||||
|
BlitBto1Key(info, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit2bto2Key(SDL_BlitInfo *info) {
|
||||||
|
BlitBto2Key(info, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit2bto3Key(SDL_BlitInfo *info) {
|
||||||
|
BlitBto3Key(info, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit2bto4Key(SDL_BlitInfo *info) {
|
||||||
|
BlitBto4Key(info, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const SDL_BlitFunc colorkey_blit_2b[] = {
|
||||||
|
(SDL_BlitFunc)NULL, Blit2bto1Key, Blit2bto2Key, Blit2bto3Key, Blit2bto4Key
|
||||||
|
};
|
||||||
|
|
||||||
|
static void Blit2btoNAlpha(SDL_BlitInfo *info)
|
||||||
|
{
|
||||||
|
BlitBtoNAlpha(info, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit2btoNAlphaKey(SDL_BlitInfo *info)
|
||||||
|
{
|
||||||
|
BlitBtoNAlphaKey(info, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void Blit4bto1(SDL_BlitInfo *info) {
|
||||||
|
BlitBto1(info, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit4bto2(SDL_BlitInfo *info) {
|
||||||
|
BlitBto2(info, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit4bto3(SDL_BlitInfo *info) {
|
||||||
|
BlitBto3(info, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit4bto4(SDL_BlitInfo *info) {
|
||||||
|
BlitBto4(info, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const SDL_BlitFunc bitmap_blit_4b[] = {
|
||||||
|
(SDL_BlitFunc)NULL, Blit4bto1, Blit4bto2, Blit4bto3, Blit4bto4
|
||||||
|
};
|
||||||
|
|
||||||
|
static void Blit4bto1Key(SDL_BlitInfo *info) {
|
||||||
|
BlitBto1Key(info, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit4bto2Key(SDL_BlitInfo *info) {
|
||||||
|
BlitBto2Key(info, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit4bto3Key(SDL_BlitInfo *info) {
|
||||||
|
BlitBto3Key(info, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit4bto4Key(SDL_BlitInfo *info) {
|
||||||
|
BlitBto4Key(info, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const SDL_BlitFunc colorkey_blit_4b[] = {
|
||||||
|
(SDL_BlitFunc)NULL, Blit4bto1Key, Blit4bto2Key, Blit4bto3Key, Blit4bto4Key
|
||||||
|
};
|
||||||
|
|
||||||
|
static void Blit4btoNAlpha(SDL_BlitInfo *info)
|
||||||
|
{
|
||||||
|
BlitBtoNAlpha(info, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Blit4btoNAlphaKey(SDL_BlitInfo *info)
|
||||||
|
{
|
||||||
|
BlitBtoNAlphaKey(info, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface)
|
SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface)
|
||||||
{
|
{
|
||||||
int which;
|
int which;
|
||||||
|
|
||||||
/* 4bits to 32bits */
|
|
||||||
if (surface->format->format == SDL_PIXELFORMAT_INDEX4MSB) {
|
|
||||||
if (surface->map->dst->format->BytesPerPixel == 4) {
|
|
||||||
switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
|
|
||||||
case 0:
|
|
||||||
return Blit4bto4;
|
|
||||||
|
|
||||||
case SDL_COPY_COLORKEY:
|
|
||||||
return Blit4bto4Key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (surface->format->format == SDL_PIXELFORMAT_INDEX1MSB) {
|
|
||||||
if (surface->map->dst->format->BitsPerPixel < 8) {
|
if (surface->map->dst->format->BitsPerPixel < 8) {
|
||||||
which = 0;
|
which = 0;
|
||||||
} else {
|
} else {
|
||||||
which = surface->map->dst->format->BytesPerPixel;
|
which = surface->map->dst->format->BytesPerPixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SDL_PIXELTYPE(surface->format->format) == SDL_PIXELTYPE_INDEX1) {
|
||||||
switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
|
switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
|
||||||
case 0:
|
case 0:
|
||||||
return bitmap_blit[which];
|
return bitmap_blit_1b[which];
|
||||||
|
|
||||||
case SDL_COPY_COLORKEY:
|
case SDL_COPY_COLORKEY:
|
||||||
return colorkey_blit[which];
|
return colorkey_blit_1b[which];
|
||||||
|
|
||||||
case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
|
case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
|
||||||
return which >= 2 ? BlitBtoNAlpha : (SDL_BlitFunc)NULL;
|
return which >= 2 ? Blit1btoNAlpha : (SDL_BlitFunc)NULL;
|
||||||
|
|
||||||
case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
|
case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
|
||||||
return which >= 2 ? BlitBtoNAlphaKey : (SDL_BlitFunc)NULL;
|
return which >= 2 ? Blit1btoNAlphaKey : (SDL_BlitFunc)NULL;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SDL_PIXELTYPE(surface->format->format) == SDL_PIXELTYPE_INDEX2) {
|
||||||
|
switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
|
||||||
|
case 0:
|
||||||
|
return bitmap_blit_2b[which];
|
||||||
|
|
||||||
|
case SDL_COPY_COLORKEY:
|
||||||
|
return colorkey_blit_2b[which];
|
||||||
|
|
||||||
|
case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
|
||||||
|
return which >= 2 ? Blit2btoNAlpha : (SDL_BlitFunc)NULL;
|
||||||
|
|
||||||
|
case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
|
||||||
|
return which >= 2 ? Blit2btoNAlphaKey : (SDL_BlitFunc)NULL;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SDL_PIXELTYPE(surface->format->format) == SDL_PIXELTYPE_INDEX4) {
|
||||||
|
switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
|
||||||
|
case 0:
|
||||||
|
return bitmap_blit_4b[which];
|
||||||
|
|
||||||
|
case SDL_COPY_COLORKEY:
|
||||||
|
return colorkey_blit_4b[which];
|
||||||
|
|
||||||
|
case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
|
||||||
|
return which >= 2 ? Blit4btoNAlpha : (SDL_BlitFunc)NULL;
|
||||||
|
|
||||||
|
case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
|
||||||
|
return which >= 2 ? Blit4btoNAlphaKey : (SDL_BlitFunc)NULL;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user