blum blum blum

SVN revision: 2477
This commit is contained in:
Carsten Haitzler 2000-04-13 03:02:19 +00:00
parent 1759a0c9e4
commit 7968e8e119
6 changed files with 1401 additions and 161 deletions

File diff suppressed because it is too large Load Diff

View File

@ -51,8 +51,8 @@
#define LOOP_END \
} \
p1 += src_jump; \
p2 += dst_jump; \
p1 += srcw - w; \
p2 += dstw - w; \
}
#define LOOP_END_WITH_INCREMENT \
@ -62,34 +62,10 @@
/* COPY OPS */
#ifdef DO_MMX_ASM
static DATA8 mmx_data[] =
{
255, 0,255, 0,255, 0,255, 0, /* components */
255, 0, 0, 0, 0, 0, 0, 0, /* mask_red */
0, 0,255, 0, 0, 0, 0, 0, /* mask_green */
0, 0, 0, 0, 255,0, 0, 0, /* mask_blue */
0, 0, 0,255, 0, 0, 0, 0, /* mask_alpha */
255,255,255,255,255,255, 0, 0 /* mask */
};
#endif
static void
__imlib_BlendRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_BlendRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
#ifdef DO_MMX_ASM
int y;
__imlib_toggle_mmx();
for (y = 0; y < h; y++)
{
__imlib_asm_blend_rgba_to_rgb(src, dst, w, mmx_data);
src += w + src_jump;
dst += w + dst_jump;
}
__imlib_toggle_mmx();
#else
LOOP_START_2
a = A_VAL(p1);
@ -98,26 +74,25 @@ __imlib_BlendRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
BLEND_COLOR(a, B_VAL(p2), B_VAL(p1), B_VAL(p2));
LOOP_END_WITH_INCREMENT
#endif
}
static void
__imlib_BlendRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_BlendRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
a = A_VAL(p1);
SATURATE_UPPER(a, A_VAL(p1) + (255 - A_VAL(p2)));
BLEND_COLOR(a, R_VAL(p2), R_VAL(p1), R_VAL(p2));
BLEND_COLOR(a, G_VAL(p2), G_VAL(p1), G_VAL(p2));
BLEND_COLOR(a, B_VAL(p2), B_VAL(p1), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), a + A_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_VAL(p1) + A_VAL(p2));
LOOP_END_WITH_INCREMENT
}
static void
__imlib_BlendRGBToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_BlendRGBToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START
@ -128,7 +103,7 @@ __imlib_BlendRGBToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
}
static void
__imlib_CopyRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_CopyRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START
@ -139,7 +114,7 @@ __imlib_CopyRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
}
static void
__imlib_CopyRGBToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_CopyRGBToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START
@ -150,7 +125,7 @@ __imlib_CopyRGBToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
}
static void
__imlib_CopyRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_CopyRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
/* FIXME: This could be a memcpy operation. */
@ -164,7 +139,7 @@ __imlib_CopyRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
/* ADD OPS */
static void
__imlib_AddBlendRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_AddBlendRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_2
@ -178,7 +153,7 @@ __imlib_AddBlendRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
}
static void
__imlib_AddBlendRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_AddBlendRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
@ -193,7 +168,7 @@ __imlib_AddBlendRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
}
static void
__imlib_AddCopyRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_AddCopyRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_1
@ -206,7 +181,7 @@ __imlib_AddCopyRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
}
static void
__imlib_AddCopyRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_AddCopyRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
@ -222,7 +197,7 @@ __imlib_AddCopyRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
/* SUBTRACT OPS */
static void
__imlib_SubBlendRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_SubBlendRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_2
@ -237,7 +212,7 @@ __imlib_SubBlendRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
}
static void
__imlib_SubBlendRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_SubBlendRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
@ -253,7 +228,7 @@ __imlib_SubBlendRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
}
static void
__imlib_SubCopyRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_SubCopyRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_1
@ -266,7 +241,7 @@ __imlib_SubCopyRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
}
static void
__imlib_SubCopyRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_SubCopyRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
@ -283,7 +258,7 @@ __imlib_SubCopyRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
/* RESHADE OPS */
static void
__imlib_ReBlendRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_ReBlendRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_2
@ -293,14 +268,12 @@ __imlib_ReBlendRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
RESHADE_COLOR_WITH_ALPHA(a, R_VAL(p2), R_VAL(p1), R_VAL(p2));
RESHADE_COLOR_WITH_ALPHA(a, G_VAL(p2), G_VAL(p1), G_VAL(p2));
RESHADE_COLOR_WITH_ALPHA(a, B_VAL(p2), B_VAL(p1), B_VAL(p2));
WRITE_RGB_PRESERVE_ALPHA(p2, nr, ng, nb);
LOOP_END_WITH_INCREMENT
}
static void
__imlib_ReBlendRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_ReBlendRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
@ -316,7 +289,7 @@ __imlib_ReBlendRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
}
static void
__imlib_ReCopyRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_ReCopyRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_1
@ -329,7 +302,7 @@ __imlib_ReCopyRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
}
static void
__imlib_ReCopyRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_ReCopyRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
@ -359,12 +332,11 @@ __imlib_ReCopyRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
/* WITH COLOMOD */
/* COPY OPS */
static void
__imlib_BlendRGBAToRGBCmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_BlendRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_2
@ -378,7 +350,7 @@ __imlib_BlendRGBAToRGBCmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
}
static void
__imlib_BlendRGBAToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_BlendRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
@ -393,7 +365,7 @@ __imlib_BlendRGBAToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump
}
static void
__imlib_BlendRGBToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_BlendRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
@ -407,7 +379,7 @@ __imlib_BlendRGBToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
}
static void
__imlib_CopyRGBAToRGBCmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_CopyRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START
@ -420,7 +392,7 @@ __imlib_CopyRGBAToRGBCmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
}
static void
__imlib_CopyRGBToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_CopyRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START
@ -434,7 +406,7 @@ __imlib_CopyRGBToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
}
static void
__imlib_CopyRGBAToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_CopyRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
/* FIXME: This could be a memcpy operation. */
@ -451,7 +423,7 @@ __imlib_CopyRGBAToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
/* ADD OPS */
static void
__imlib_AddBlendRGBAToRGBCmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_AddBlendRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_2
@ -465,7 +437,7 @@ __imlib_AddBlendRGBAToRGBCmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_ju
}
static void
__imlib_AddBlendRGBAToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_AddBlendRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
@ -480,7 +452,7 @@ __imlib_AddBlendRGBAToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_j
}
static void
__imlib_AddCopyRGBAToRGBCmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_AddCopyRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_1
@ -493,7 +465,7 @@ __imlib_AddCopyRGBAToRGBCmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jum
}
static void
__imlib_AddCopyRGBAToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_AddCopyRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
@ -509,7 +481,7 @@ __imlib_AddCopyRGBAToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_ju
/* SUBTRACT OPS */
static void
__imlib_SubBlendRGBAToRGBCmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_SubBlendRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_2
@ -524,7 +496,7 @@ __imlib_SubBlendRGBAToRGBCmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_ju
}
static void
__imlib_SubBlendRGBAToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_SubBlendRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
@ -540,7 +512,7 @@ __imlib_SubBlendRGBAToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_j
}
static void
__imlib_SubCopyRGBAToRGBCmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_SubCopyRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_1
@ -553,7 +525,7 @@ __imlib_SubCopyRGBAToRGBCmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jum
}
static void
__imlib_SubCopyRGBAToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_SubCopyRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
@ -570,7 +542,7 @@ __imlib_SubCopyRGBAToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_ju
/* RESHADE OPS */
static void
__imlib_ReBlendRGBAToRGBCmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_ReBlendRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_2
@ -580,14 +552,12 @@ __imlib_ReBlendRGBAToRGBCmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jum
RESHADE_COLOR_WITH_ALPHA(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
RESHADE_COLOR_WITH_ALPHA(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
RESHADE_COLOR_WITH_ALPHA(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
WRITE_RGB_PRESERVE_ALPHA(p2, nr, ng, nb);
LOOP_END_WITH_INCREMENT
}
static void
__imlib_ReBlendRGBAToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_ReBlendRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
@ -603,7 +573,7 @@ __imlib_ReBlendRGBAToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_ju
}
static void
__imlib_ReCopyRGBAToRGBCmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_ReCopyRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_1
@ -616,7 +586,7 @@ __imlib_ReCopyRGBAToRGBCmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump
}
static void
__imlib_ReCopyRGBAToRGBACmod(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_ReCopyRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
@ -726,6 +696,90 @@ __imlib_GetBlendFunction(ImlibOp op, char blend, char merge_alpha, char rgb_src,
}
else
{
#ifdef DO_MMX_ASM
switch(op)
{
case OP_COPY:
if (merge_alpha)
{
if (rgb_src)
{
if (blend)
blender = __imlib_BlendRGBToRGBA;
else
blender = __imlib_mmx_copy_rgba_to_rgba;
}
else
{
if (blend)
/* had to disable - bug - alpha value isnt saturated at full 255 - its just */
/* a bit off */
/* blender = __imlib_mmx_blend_rgba_to_rgba;*/
blender = __imlib_BlendRGBAToRGBA;
else
blender = __imlib_mmx_copy_rgba_to_rgba;
}
}
else
{
if (blend)
blender = __imlib_mmx_blend_rgba_to_rgb;
else
blender = __imlib_mmx_copy_rgba_to_rgb;
}
break;
case OP_ADD:
if (merge_alpha)
{
if (blend)
blender = __imlib_mmx_add_blend_rgba_to_rgba;
else
blender = __imlib_mmx_add_copy_rgba_to_rgba;
}
else
{
if (blend)
blender = __imlib_mmx_add_blend_rgba_to_rgb;
else
blender = __imlib_mmx_add_copy_rgba_to_rgb;
}
break;
case OP_SUBTRACT:
if (merge_alpha)
{
if (blend)
blender = __imlib_mmx_subtract_blend_rgba_to_rgba;
else
blender = __imlib_mmx_subtract_copy_rgba_to_rgba;
}
else
{
if (blend)
blender = __imlib_mmx_subtract_blend_rgba_to_rgb;
else
blender = __imlib_mmx_subtract_copy_rgba_to_rgb;
}
break;
case OP_RESHADE:
if (merge_alpha)
{
if (blend)
blender = __imlib_mmx_reshade_blend_rgba_to_rgba;
else
blender = __imlib_mmx_reshade_copy_rgba_to_rgba;
}
else
{
if (blend)
blender = __imlib_mmx_reshade_blend_rgba_to_rgb;
else
blender = __imlib_mmx_reshade_copy_rgba_to_rgb;
}
break;
default:
break;
}
#else
switch(op)
{
case OP_COPY:
@ -807,6 +861,7 @@ __imlib_GetBlendFunction(ImlibOp op, char blend, char merge_alpha, char rgb_src,
default:
break;
}
#endif
}
return blender;
@ -859,8 +914,8 @@ __imlib_BlendRGBAToData(DATA32 *src, int src_w, int src_h, DATA32 *dst,
blender = __imlib_GetBlendFunction(op, blend, merge_alpha, rgb_src, cm);
if (blender)
blender(src + (sy * src_w) + sx, src_w - w,
dst + (dy * dst_w) + dx, dst_w - w, w, h, cm);
blender(src + (sy * src_w) + sx, src_w,
dst + (dy * dst_w) + dx, dst_w, w, h, cm);
}
#define LINESIZE 16
@ -1064,9 +1119,9 @@ __imlib_BlendImageToImage(ImlibImage *im_src, ImlibImage *im_dst,
/* setup h */
h = dh;
/* set our scaling up in x / y dir flags */
if (dw > sw)
if (dw >= sw)
xup = 1;
if (dh > sh)
if (dh >= sh)
yup = 1;
if (!IMAGE_HAS_ALPHA(im_dst))
merge_alpha = 0;

View File

@ -129,7 +129,7 @@
/* Saturate values in the range [0, 512) */
#define SATURATE_UPPER(nc, v) \
tmp = (v); \
nc = (tmp | ((tmp & 256) - ((tmp & 256) >> 8)));
nc = (tmp | (-(tmp >> 8)));
/* Saturate values in the range (-256, 256) */
#define SATURATE_LOWER(nc, v) \
@ -139,7 +139,7 @@
/* Saturate values in the range (-256, 512) */
#define SATURATE_BOTH(nc, v) \
tmp = (v); \
nc = (tmp | ((tmp & 256) - ((tmp & 256) >> 8))) & (~(tmp >> 9));
nc = (tmp | (-(tmp >> 8))) & (~(tmp >> 9));
/*
* 1) Operations
@ -344,4 +344,54 @@ __imlib_BlendRGBAToData(DATA32 *src, int src_w, int src_h, DATA32 *dst,
int dst_w, int dst_h, int sx, int sy, int dx, int dy,
int w, int h, char blend, char merge_alpha,
ImlibColorModifier *cm, ImlibOp op, char rgb_src);
#ifdef DO_MMX_ASM
void
__imlib_mmx_blend_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_blend_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_copy_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_copy_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_add_blend_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_add_blend_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_add_copy_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_add_copy_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_subtract_blend_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_subtract_blend_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_subtract_copy_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_subtract_copy_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_reshade_blend_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_reshade_blend_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_reshade_copy_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_reshade_copy_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
#endif
#endif

View File

@ -259,7 +259,7 @@ __imlib_RenderImage(Display *d, ImlibImage *im,
if (!(im->flags & F_HAS_ALPHA))
rgb_src = 1;
blender = __imlib_GetBlendFunction(op, 1, 0, rgb_src, NULL);
blender(pointer, jump, back + (y * dw), 0, dw, hh, NULL);
blender(pointer, jump + dw, back + (y * dw), dw, dw, hh, NULL);
pointer = back + (y * dw);
jump = 0;
}

View File

@ -301,6 +301,154 @@ __imlib_SharpenImage(ImlibImage *im, int rad)
im->data = data;
}
ImlibFilter *
__imlib_CreateFilter(int w, int h, int x, int y)
{
ImlibFilter *fil;
fil = malloc(sizeof(ImlibFilter));
fil->w = w;
fil->h = h;
fil->x = x;
fil->y = y;
fil->r = malloc(fil->w * fil->h * sizeof(short));
fil->g = malloc(fil->w * fil->h * sizeof(short));
fil->b = malloc(fil->w * fil->h * sizeof(short));
fil->a = malloc(fil->w * fil->h * sizeof(short));
memset(fil->r, 0, (fil->w * fil->h * sizeof(short)));
memset(fil->g, 0, (fil->w * fil->h * sizeof(short)));
memset(fil->b, 0, (fil->w * fil->h * sizeof(short)));
memset(fil->a, 0, (fil->w * fil->h * sizeof(short)));
fil->r[fil->x + fil->y * fil->w] = 256;
fil->g[fil->x + fil->y * fil->w] = 256;
fil->b[fil->x + fil->y * fil->w] = 256;
fil->a[fil->x + fil->y * fil->w] = 256;
return fil;
}
void
__imlib_FreeFilter(ImlibFilter *fil)
{
free(fil->r);
free(fil->g);
free(fil->b);
free(fil->a);
free(fil);
}
#define FILTER_ADD(p) do { \
if (fil->a[fi]) a += A_VAL(p) * fil->a[fi]; \
if (fil->r[fi]) r += R_VAL(p) * fil->r[fi]; \
if (fil->g[fi]) g += G_VAL(p) * fil->g[fi]; \
if (fil->b[fi]) b += B_VAL(p) * fil->b[fi]; \
fi++; } while (0)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
void
__imlib_FilterImage(ImlibImage *im, ImlibFilter *fil)
{
DATA32 *data, *px, *py, *p1, *p2;
int fi, a, r, g, b, x, y, fx, fy;
int fx1, fx2, fx3, fy1, fy2, fy3;
data = malloc(im->w * im->h * sizeof(DATA32));
p1 = im->data;
p2 = data;
for (y = 0; y < im->h; y++) {
/*\ Calculate vertical block sizes \*/
fy1 = fil->y - y;
if (fy1 < 0) fy1 = 0;
if (fy1 > fil->h) fy1 = fil->h;
fy2 = (im->h - (y - fil->y));
if (fy2 < 0) fy2 = 0;
if (fy2 > (fil->h - fy1)) fy2 = fil->h - fy1;
fy3 = fil->h - (fy1 + fy2);
for (x = 0; x < im->w; x++) {
/*\ Calculate horizontal block sizes \*/
fx1 = fil->x - x;
if (fx1 < 0) fx1 = 0;
if (fx1 > fil->w) fx1 = fil->w;
fx2 = (im->w - (x - fil->x));
if (fx2 < 0) fx2 = 0;
if (fx2 > (fil->w - fx1)) fx2 = fil->w - fx1;
fx3 = fil->w - (fx1 + fx2);
a = r = g = b = fi = 0;
py = p1;
for (fy = fy1; --fy >= 0; ) {
px = py;
/*\ Left edge outside \*/
for (fx = fx1; --fx >= 0; ) {
FILTER_ADD(px);
}
px = py + (x - fil->x) + fx1;
/*\ Middle part \*/
for (fx = fx2; --fx >= 0; ) {
FILTER_ADD(px);
px++;
}
px = py + (im->w - 1);
/*\ Right edge outside \*/
for (fx = fx3; --fx >= 0; ) {
FILTER_ADD(px);
}
}
/*\ Middle part \*/
py = p1 + im->w * ((y - fil->y) + fy1);
for (fy = fy2; --fy >= 0; ) {
px = py;
/*\ Left edge outside \*/
for (fx = fx1; --fx >= 0; ) {
FILTER_ADD(px);
}
px = py + (x - fil->x) + fx1;
/*\ Middle part \*/
for (fx = fx2; --fx >= 0; ) {
FILTER_ADD(px);
px++;
}
px = py + (im->w - 1);
/*\ Right edge outside \*/
for (fx = fx3; --fx >= 0; ) {
FILTER_ADD(px);
}
py += im->w;
}
/*\ Lower edge outside \*/
py = p1 + (im->w * (im->h - 1));
for (fy = fy3; --fy >= 0; ) {
px = py;
/*\ Left edge outside \*/
for (fx = fx1; --fx >= 0; ) {
FILTER_ADD(px);
}
px = py + (x - fil->x) + fx1;
/*\ Middle part \*/
for (fx = fx2; --fx >= 0; ) {
FILTER_ADD(px);
px++;
}
px = py + (im->w - 1);
/*\ Right edge outside \*/
for (fx = fx3; --fx >= 0; ) {
FILTER_ADD(px);
}
}
a = (((a >> 8) | (-(a >> 16))) & (~(a >> 17))) & 0xff;
r = (((r >> 8) | (-(r >> 16))) & (~(r >> 17))) & 0xff;
g = (((g >> 8) | (-(g >> 16))) & (~(g >> 17))) & 0xff;
b = (((b >> 8) | (-(b >> 16))) & (~(b >> 17))) & 0xff;
*p2 = (a << 24) | (r << 16) | (g << 8) | (b);
p2++;
}
}
free(im->data);
im->data = data;
}
void
__imlib_TileImageHoriz(ImlibImage *im)
{

View File

@ -1,5 +1,16 @@
#ifndef __RGBADRAW
#define __RGBADRAW 1
typedef struct _imlib_filter ImlibFilter;
struct _imlib_filter
{
short *r, *g, *b, *a;
int w, h, x, y;
};
ImlibFilter *__imlib_CreateFilter(int w, int h, int x, int y);
void __imlib_FreeFilter(ImlibFilter *fil);
void __imlib_FilterImage(ImlibImage *im, ImlibFilter *fil);
void __imlib_FlipImageHoriz(ImlibImage *im);
void __imlib_FlipImageVert(ImlibImage *im);
void __imlib_FlipImageBoth(ImlibImage *im);