rgba code for plain 16bpp using mmx... :) and blend rounding asm error fixed

thanks willem :)


SVN revision: 2502
This commit is contained in:
Carsten Haitzler 2000-04-19 16:53:34 +00:00
parent 0b5aae9a1a
commit aa89de24f8
5 changed files with 210 additions and 335 deletions

View File

@ -20,7 +20,7 @@ libImlib2_la_SOURCES = rend.c ximage.c scale.c rgba.c image.c color.c grab.c \
color.h draw.h rend.h ximage.h colormod.h file.h \
rgba.h common.h grab.h rgbadraw.h font.h format.h \
rotate.h grad.h filter.h \
asm_blend.S filter.c
asm_blend.S filter.c asm_rgba.S
libImlib2_la_LIBADD = @DLLDFLAGS@ $(top_builddir)/libltdl/libltdlc.la \
-lX11 -lXext -lttf $(LDFLAGS)
libImlib2_la_DEPENDENCIES = $(top_builddir)/config.h

View File

@ -72,6 +72,7 @@ m10001000: .byte 0, 0, 0, 1, 0, 0, 0, 1
m000V0V0V: .byte 127, 0, 127, 0, 127, 0, 0, 0
mI0000000: .byte 0, 0, 0, 0, 0, 0, 0, 64
m0VVV0VVV: .byte 127, 127, 127, 0, 127, 127, 127, 0
c1: .word 0x1, 0x1, 0x1, 0x1
/*\ MMX register use:
|*| %mm1 = Source value
@ -135,6 +136,7 @@ __imlib_mmx_blend_rgba_to_rgb:
ENTER
pxor %mm4, %mm4
movq c1, %mm5
LOOP_START
1:
@ -167,9 +169,10 @@ __imlib_mmx_blend_rgba_to_rgb:
punpcklbw %mm4, %mm1
punpcklbw %mm4, %mm2
/*\ d = d + (a * (s - d)) \*/
/*\ d = d + (a * ((s - d) + 0.5)) \*/
psubw %mm2, %mm1
psllw $1, %mm1
paddw %mm5, %mm1 /*\ Roundoff \*/
pmulhw %mm3, %mm1
paddw %mm1, %mm2
@ -229,6 +232,7 @@ __imlib_mmx_blend_rgba_to_rgba:
pxor %mm4, %mm4
movq m0X000000, %mm5
movq m00XXXXXX, %mm6
movq c1, %mm7
LOOP_START
1:
@ -254,9 +258,10 @@ __imlib_mmx_blend_rgba_to_rgba:
movq %mm1, %mm0
pand %mm5, %mm0
/*\ d = d + (a * (s - d)) \*/
/*\ d = d + (a * ((s - d) + 0.5)) \*/
psubw %mm2, %mm1
psllw $1, %mm1
paddw %mm7, %mm1 /*\ Roundoff \*/
pmulhw %mm3, %mm1
/*\ Replace alpha channel with separated out version in mm0 and add \*/

View File

@ -48,6 +48,7 @@ __imlib_RenderImage(Display *d, ImlibImage *im,
int actual_depth = 0;
char xup = 0, yup = 0;
char shm = 0, bgr = 0;
ImlibRGBAFunction rgbaer, masker;
/* dont do anything if we have a 0 widht or height image to render */
if ((dw <= 0) || (dh <= 0))
@ -201,6 +202,9 @@ __imlib_RenderImage(Display *d, ImlibImage *im,
if (dh > sh)
yup = 1;
/* scale in LINESIZE Y chunks and convert to depth*/
/*\ Get rgba and mask functions for XImage rendering \*/
rgbaer = __imlib_GetRGBAFunction(actual_depth, bgr, hiq, ct->palette_type);
if (m) masker = __imlib_GetMaskFunction(hiq);
for (y = 0; y < dh; y += LINESIZE)
{
hh = LINESIZE;
@ -264,200 +268,13 @@ __imlib_RenderImage(Display *d, ImlibImage *im,
jump = 0;
}
/* once scaled... convert chunk to bit depth into XImage bufer */
/* NB - the order here may be random - but I chose it to select most */
/* common depths first */
if (actual_depth == 16)
{
if (bgr)
{
if (hiq)
__imlib_RGBA_to_BGR565_dither(pointer, jump,
((DATA16 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA16))),
(xim->bytes_per_line / sizeof(DATA16)) - dw,
dw, hh, dx, dy + y);
else
__imlib_RGBA_to_BGR565_fast(pointer, jump,
((DATA16 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA16))),
(xim->bytes_per_line / sizeof(DATA16)) - dw,
dw, hh, dx, dy + y);
}
else
{
if (hiq)
__imlib_RGBA_to_RGB565_dither(pointer, jump,
((DATA16 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA16))),
(xim->bytes_per_line / sizeof(DATA16)) - dw,
dw, hh, dx, dy + y);
else
__imlib_RGBA_to_RGB565_fast(pointer, jump,
((DATA16 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA16))),
(xim->bytes_per_line / sizeof(DATA16)) - dw,
dw, hh, dx, dy + y);
}
}
/* FIXME: need to handle different RGB ordering */
else if (actual_depth == 24)
{
if (bgr)
__imlib_RGBA_to_BGR888_fast(pointer, jump,
((DATA8 *)xim->data) + (y * xim->bytes_per_line),
xim->bytes_per_line - (dw * 3),
dw, hh, dx, dy + y);
else
__imlib_RGBA_to_RGB888_fast(pointer, jump,
((DATA8 *)xim->data) + (y * xim->bytes_per_line),
xim->bytes_per_line - (dw * 3),
dw, hh, dx, dy + y);
}
else if (actual_depth == 32)
{
if (bgr)
__imlib_RGBA_to_BGR8888_fast(pointer, jump,
((DATA32 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA32))),
(xim->bytes_per_line / sizeof(DATA32)) - dw,
dw, hh, dx, dy + y);
else
__imlib_RGBA_to_RGB8888_fast(pointer, jump,
((DATA32 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA32))),
(xim->bytes_per_line / sizeof(DATA32)) - dw,
dw, hh, dx, dy + y);
}
else if (actual_depth == 8)
{
switch (ct->palette_type)
{
case 0:
if (hiq)
__imlib_RGBA_to_RGB332_dither(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
else
__imlib_RGBA_to_RGB332_fast(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
break;
case 1:
if (hiq)
__imlib_RGBA_to_RGB232_dither(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
else
__imlib_RGBA_to_RGB232_fast(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
break;
case 2:
if (hiq)
__imlib_RGBA_to_RGB222_dither(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
else
__imlib_RGBA_to_RGB222_fast(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
break;
case 3:
if (hiq)
__imlib_RGBA_to_RGB221_dither(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
else
__imlib_RGBA_to_RGB221_fast(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
break;
case 4:
if (hiq)
__imlib_RGBA_to_RGB121_dither(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
else
__imlib_RGBA_to_RGB121_fast(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
break;
case 5:
if (hiq)
__imlib_RGBA_to_RGB111_dither(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
else
__imlib_RGBA_to_RGB111_fast(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
break;
case 6:
if (hiq)
__imlib_RGBA_to_RGB1_dither(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
else
__imlib_RGBA_to_RGB1_fast(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
break;
default:
break;
}
}
else if (actual_depth == 15)
{
if (bgr)
{
if (hiq)
__imlib_RGBA_to_BGR555_dither(pointer, jump,
((DATA16 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA16))),
(xim->bytes_per_line / sizeof(DATA16)) - dw,
dw, hh, dx, dy + y);
else
__imlib_RGBA_to_BGR555_fast(pointer, jump,
((DATA16 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA16))),
(xim->bytes_per_line / sizeof(DATA16)) - dw,
dw, hh, dx, dy + y);
}
else
{
if (hiq)
__imlib_RGBA_to_RGB555_dither(pointer, jump,
((DATA16 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA16))),
(xim->bytes_per_line / sizeof(DATA16)) - dw,
dw, hh, dx, dy + y);
else
__imlib_RGBA_to_RGB555_fast(pointer, jump,
((DATA16 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA16))),
(xim->bytes_per_line / sizeof(DATA16)) - dw,
dw, hh, dx, dy + y);
}
}
rgbaer(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line)),
xim->bytes_per_line, dw, hh, dx, dy + y);
if (m)
{
memset(((DATA8 *)mxim->data) + (y * (mxim->bytes_per_line)),
0x0, mxim->bytes_per_line * hh);
if (dither_mask)
__imlib_RGBA_to_A1_dither(pointer, jump,
((DATA8 *)mxim->data) + (y * (mxim->bytes_per_line)),
(mxim->bytes_per_line) - (dw >> 3),
dw, hh, dx, dy + y);
else
__imlib_RGBA_to_A1_fast(pointer, jump,
((DATA8 *)mxim->data) + (y * (mxim->bytes_per_line)),
(mxim->bytes_per_line) - (dw >> 3),
dw, hh, dx, dy + y);
}
masker(pointer, jump,
((DATA8 *)mxim->data) + (y * (mxim->bytes_per_line)),
mxim->bytes_per_line, dw, hh, dx, dy + y);
h -= LINESIZE;
}
/* free up our buffers and poit tables */

View File

@ -1600,12 +1600,14 @@ __imlib_RGBA_init(void *rd, void *gd, void *bd, int depth, DATA8 palette_type)
}
}
void
static void
__imlib_RGBA_to_RGB565_fast(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
DATA8 *dst, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
DATA16 *dest = (DATA16 *)dst;
int dest_jump = (dow / sizeof(DATA16)) - width;
w = width;
h = height;
@ -1668,12 +1670,14 @@ __imlib_RGBA_to_RGB565_fast(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB565_dither(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
DATA8 *dst, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
DATA16 *dest = (DATA16 *)dst;
int dest_jump = (dow / sizeof(DATA16)) - width;
w = width + dx;
h = height + dy;
@ -1740,10 +1744,12 @@ __imlib_RGBA_to_RGB565_dither(DATA32 *src , int src_jump,
void
__imlib_RGBA_to_BGR565_fast(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
DATA8 *dst, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
DATA16 *dest = (DATA16 *)dst;
int dest_jump = (dow / sizeof(DATA16)) - width;
w = width;
h = height;
@ -1806,12 +1812,14 @@ __imlib_RGBA_to_BGR565_fast(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_BGR565_dither(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
DATA8 *dst, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
DATA16 *dest = (DATA16 *)dst;
int dest_jump = (dow / sizeof(DATA16)) - width;
w = width + dx;
h = height + dy;
@ -1876,12 +1884,14 @@ __imlib_RGBA_to_BGR565_dither(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB555_fast(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
DATA8 *dst, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
DATA16 *dest = (DATA16 *)dst;
int dest_jump = (dow / sizeof(DATA16)) - width;
w = width;
h = height;
@ -1944,12 +1954,14 @@ __imlib_RGBA_to_RGB555_fast(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB555_dither(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
DATA8 *dst, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
DATA16 *dest = (DATA16 *)dst;
int dest_jump = (dow / sizeof(DATA16)) - width;
w = width + dx;
h = height + dy;
@ -2014,12 +2026,14 @@ __imlib_RGBA_to_RGB555_dither(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_BGR555_fast(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
DATA8 *dst, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
DATA16 *dest = (DATA16 *)dst;
int dest_jump = (dow / sizeof(DATA16)) - width;
w = width;
h = height;
@ -2082,12 +2096,14 @@ __imlib_RGBA_to_BGR555_fast(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_BGR555_dither(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
DATA8 *dst, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
DATA16 *dest = (DATA16 *)dst;
int dest_jump = (dow / sizeof(DATA16)) - width;
w = width + dx;
h = height + dy;
@ -2152,12 +2168,13 @@ __imlib_RGBA_to_BGR555_dither(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB332_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - width;
w = width;
h = height;
@ -2248,12 +2265,13 @@ __imlib_RGBA_to_RGB332_fast(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB332_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - width;
w = width + dx;
h = height + dy;
@ -2326,12 +2344,13 @@ __imlib_RGBA_to_RGB332_dither(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB232_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - width;
w = width;
h = height;
@ -2422,12 +2441,13 @@ __imlib_RGBA_to_RGB232_fast(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB232_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - width;
w = width + dx;
h = height + dy;
@ -2500,12 +2520,13 @@ __imlib_RGBA_to_RGB232_dither(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB222_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - width;
w = width;
h = height;
@ -2596,12 +2617,13 @@ __imlib_RGBA_to_RGB222_fast(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB222_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - width;
w = width + dx;
h = height + dy;
@ -2674,12 +2696,13 @@ __imlib_RGBA_to_RGB222_dither(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB221_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - width;
w = width;
h = height;
@ -2770,12 +2793,13 @@ __imlib_RGBA_to_RGB221_fast(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB221_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - width;
w = width + dx;
h = height + dy;
@ -2848,12 +2872,13 @@ __imlib_RGBA_to_RGB221_dither(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB121_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - width;
w = width;
h = height;
@ -2944,12 +2969,13 @@ __imlib_RGBA_to_RGB121_fast(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB121_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - width;
w = width + dx;
h = height + dy;
@ -3022,12 +3048,13 @@ __imlib_RGBA_to_RGB121_dither(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB111_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - width;
w = width;
h = height;
@ -3118,12 +3145,13 @@ __imlib_RGBA_to_RGB111_fast(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB111_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - width;
w = width + dx;
h = height + dy;
@ -3196,12 +3224,13 @@ __imlib_RGBA_to_RGB111_dither(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB1_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - width;
w = width;
h = height;
@ -3220,12 +3249,13 @@ __imlib_RGBA_to_RGB1_fast(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB1_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - width;
w = width + dx;
h = height + dy;
@ -3244,12 +3274,13 @@ __imlib_RGBA_to_RGB1_dither(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_A1_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - (width >> 3);
w = width;
h = height;
@ -3268,12 +3299,13 @@ __imlib_RGBA_to_A1_fast(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_A1_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - (width >> 3);
w = width + dx;
h = height + dy;
@ -3292,12 +3324,14 @@ __imlib_RGBA_to_A1_dither(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB8888_fast(DATA32 *src , int src_jump,
DATA32 *dest, int dest_jump,
DATA8 *dst, int dow,
int width, int height, int dx, int dy)
{
int y, w, h;
DATA32 *dest = (DATA32 *)dst;
int dest_jump = (dow / sizeof(DATA32)) - width;
w = width;
h = height;
@ -3318,12 +3352,14 @@ __imlib_RGBA_to_RGB8888_fast(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_BGR8888_fast(DATA32 *src , int src_jump,
DATA32 *dest, int dest_jump,
DATA8 *dst, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
DATA32 *dest = (DATA32 *)dst;
int dest_jump = (dow / sizeof(DATA32)) - width;
w = width;
h = height;
@ -3342,12 +3378,13 @@ __imlib_RGBA_to_BGR8888_fast(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_RGB888_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - (width * 3);
w = width;
h = height;
@ -3366,12 +3403,13 @@ __imlib_RGBA_to_RGB888_fast(DATA32 *src , int src_jump,
dy = 0;
}
void
static void
__imlib_RGBA_to_BGR888_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
int x, y, w, h;
int dest_jump = dow - (width * 3);
w = width;
h = height;
@ -3390,3 +3428,88 @@ __imlib_RGBA_to_BGR888_fast(DATA32 *src , int src_jump,
dy = 0;
}
static void
__imlib_RGBA_to_Nothing(DATA32 *src , int src_jump,
DATA8 *dest, int dow,
int width, int height, int dx, int dy)
{
/*\ Nothing: Dummy function \*/
}
ImlibRGBAFunction
__imlib_GetRGBAFunction(int depth, char bgr, char hiq, DATA8 palette_type)
{
unsigned int did;
static ImlibRGBAFunction functions[11][2][2] = {
{ { &__imlib_RGBA_to_RGB555_fast, &__imlib_RGBA_to_RGB555_dither },
{ &__imlib_RGBA_to_BGR555_fast, &__imlib_RGBA_to_BGR555_dither } },
{ { &__imlib_RGBA_to_RGB565_fast, &__imlib_RGBA_to_RGB565_dither },
{ &__imlib_RGBA_to_BGR565_fast, &__imlib_RGBA_to_BGR565_dither } },
{ { &__imlib_RGBA_to_RGB888_fast, &__imlib_RGBA_to_RGB888_fast },
{ &__imlib_RGBA_to_BGR888_fast, &__imlib_RGBA_to_BGR888_fast } },
{ { &__imlib_RGBA_to_RGB8888_fast, &__imlib_RGBA_to_RGB8888_fast },
{ &__imlib_RGBA_to_BGR8888_fast, &__imlib_RGBA_to_BGR8888_fast } },
{ { &__imlib_RGBA_to_RGB332_fast, &__imlib_RGBA_to_RGB332_dither },
{ &__imlib_RGBA_to_RGB332_fast, &__imlib_RGBA_to_RGB332_dither } },
{ { &__imlib_RGBA_to_RGB232_fast, &__imlib_RGBA_to_RGB232_dither },
{ &__imlib_RGBA_to_RGB232_fast, &__imlib_RGBA_to_RGB232_dither } },
{ { &__imlib_RGBA_to_RGB222_fast, &__imlib_RGBA_to_RGB222_dither },
{ &__imlib_RGBA_to_RGB222_fast, &__imlib_RGBA_to_RGB222_dither } },
{ { &__imlib_RGBA_to_RGB221_fast, &__imlib_RGBA_to_RGB221_dither },
{ &__imlib_RGBA_to_RGB221_fast, &__imlib_RGBA_to_RGB221_dither } },
{ { &__imlib_RGBA_to_RGB121_fast, &__imlib_RGBA_to_RGB121_dither },
{ &__imlib_RGBA_to_RGB121_fast, &__imlib_RGBA_to_RGB121_dither } },
{ { &__imlib_RGBA_to_RGB111_fast, &__imlib_RGBA_to_RGB111_dither },
{ &__imlib_RGBA_to_RGB111_fast, &__imlib_RGBA_to_RGB111_dither } },
{ { &__imlib_RGBA_to_RGB1_fast, &__imlib_RGBA_to_RGB1_dither },
{ &__imlib_RGBA_to_RGB1_fast, &__imlib_RGBA_to_RGB1_dither } },
};
#ifdef DO_MMX_ASM
static ImlibRGBAFunction mmx_functions[11][2][2] = {
{ { &__imlib_mmx_rgb555_fast, &__imlib_RGBA_to_RGB555_dither },
{ &__imlib_mmx_bgr555_fast, &__imlib_RGBA_to_BGR555_dither } },
{ { &__imlib_mmx_rgb565_fast, &__imlib_RGBA_to_RGB565_dither },
{ &__imlib_mmx_bgr565_fast, &__imlib_RGBA_to_BGR565_dither } },
{ { &__imlib_RGBA_to_RGB888_fast, &__imlib_RGBA_to_RGB888_fast },
{ &__imlib_RGBA_to_BGR888_fast, &__imlib_RGBA_to_BGR888_fast } },
{ { &__imlib_RGBA_to_RGB8888_fast, &__imlib_RGBA_to_RGB8888_fast },
{ &__imlib_RGBA_to_BGR8888_fast, &__imlib_RGBA_to_BGR8888_fast } },
{ { &__imlib_RGBA_to_RGB332_fast, &__imlib_RGBA_to_RGB332_dither },
{ &__imlib_RGBA_to_RGB332_fast, &__imlib_RGBA_to_RGB332_dither } },
{ { &__imlib_RGBA_to_RGB232_fast, &__imlib_RGBA_to_RGB232_dither },
{ &__imlib_RGBA_to_RGB232_fast, &__imlib_RGBA_to_RGB232_dither } },
{ { &__imlib_RGBA_to_RGB222_fast, &__imlib_RGBA_to_RGB222_dither },
{ &__imlib_RGBA_to_RGB222_fast, &__imlib_RGBA_to_RGB222_dither } },
{ { &__imlib_RGBA_to_RGB221_fast, &__imlib_RGBA_to_RGB221_dither },
{ &__imlib_RGBA_to_RGB221_fast, &__imlib_RGBA_to_RGB221_dither } },
{ { &__imlib_RGBA_to_RGB121_fast, &__imlib_RGBA_to_RGB121_dither },
{ &__imlib_RGBA_to_RGB121_fast, &__imlib_RGBA_to_RGB121_dither } },
{ { &__imlib_RGBA_to_RGB111_fast, &__imlib_RGBA_to_RGB111_dither },
{ &__imlib_RGBA_to_RGB111_fast, &__imlib_RGBA_to_RGB111_dither } },
{ { &__imlib_RGBA_to_RGB1_fast, &__imlib_RGBA_to_RGB1_dither },
{ &__imlib_RGBA_to_RGB1_fast, &__imlib_RGBA_to_RGB1_dither } },
};
#endif
switch (depth) {
case 15: did = 0; break;
case 16: did = 1; break;
case 24: did = 2; break;
case 32: did = 3; break;
case 8: did = palette_type + 4; break;
default: return __imlib_RGBA_to_Nothing;
}
if (did >= 11) return __imlib_RGBA_to_Nothing;
/*\ Boolean sanity \*/
bgr = bgr ? 1 : 0; hiq = hiq ? 1 : 0;
#ifdef DO_MMX_ASM
return mmx_functions[did][bgr][hiq];
#endif
return functions[did][bgr][hiq];
}
ImlibRGBAFunction
__imlib_GetMaskFunction(char hiq)
{
return hiq ? &__imlib_RGBA_to_A1_dither : &__imlib_RGBA_to_A1_fast;
}

View File

@ -4,88 +4,18 @@
void __imlib_RGBASetupContext(Context *ct);
void __imlib_RGBA_init(void *rd, void *gd, void *bd, int depth,
DATA8 palette_type);
void __imlib_RGBA_to_RGB565_fast(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB565_dither(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB555_fast(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB555_dither(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_BGR565_fast(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_BGR565_dither(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_BGR555_fast(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_BGR555_dither(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB332_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB332_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB232_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB232_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB222_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB222_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB221_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB221_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB121_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB121_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB111_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB111_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB1_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB1_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_A1_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_A1_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB8888_fast(DATA32 *src , int src_jump,
DATA32 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_BGR8888_fast(DATA32 *src , int src_jump,
DATA32 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_RGB888_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void __imlib_RGBA_to_BGR888_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
typedef void (*ImlibRGBAFunction)(DATA32*, int, DATA8*,
int, int, int, int, int);
ImlibRGBAFunction
__imlib_GetRGBAFunction(int depth, char bgr, char hiq, DATA8 palette_type);
ImlibRGBAFunction
__imlib_GetMaskFunction(char hiq);
#ifdef DO_MMX_ASM
void __imlib_mmx_rgb555_fast(DATA32*, int, DATA8*, int, int, int, int, int);
void __imlib_mmx_bgr555_fast(DATA32*, int, DATA8*, int, int, int, int, int);
void __imlib_mmx_rgb565_fast(DATA32*, int, DATA8*, int, int, int, int, int);
void __imlib_mmx_bgr565_fast(DATA32*, int, DATA8*, int, int, int, int, int);
#endif
#endif