optimise... THIS! BIATCH! :)

SVN revision: 13181
This commit is contained in:
Carsten Haitzler 2005-02-03 07:28:07 +00:00
parent 34afa1d5c4
commit f7da483fcc
8 changed files with 64 additions and 21 deletions

View File

@ -34,6 +34,7 @@ evas_common_blend_alpha_color_rgba_to_rgb_c (DATA8 *src, DATA32 *dst, int len, D
*dst_ptr = col;
break;
default:
BLEND_ALPHA_SETUP(aa, tmp);
BLEND_COLOR(aa, R_VAL(dst_ptr),
R_VAL(&col), R_VAL(dst_ptr),
tmp);
@ -111,7 +112,7 @@ evas_common_blend_alpha_color_rgba_to_rgb_mmx (DATA8 *src, DATA32 *dst, int len,
punpckhdq_r2r(mm3, mm3);
psrlw_i2r(1, mm3);
psrlq_i2r(16, mm3);
// psrlq_i2r(16, mm3);
punpcklbw_r2r(mm4, mm1);
punpcklbw_r2r(mm4, mm2);
@ -162,6 +163,7 @@ evas_common_blend_alpha_color_rgba_to_rgba_c (DATA8 *src, DATA32 *dst, int len,
BLEND_COLOR(aa, A_VAL(dst_ptr),
255, A_VAL(dst_ptr),
tmp);
BLEND_ALPHA_SETUP(a, tmp);
BLEND_COLOR(a, R_VAL(dst_ptr),
R_VAL(&col), R_VAL(dst_ptr),
tmp);

View File

@ -20,6 +20,7 @@ evas_common_blend_color_rgba_to_rgb_c(DATA32 src, DATA32 *dst, int len)
{
DATA32 tmp;
BLEND_ALPHA_SETUP(A_VAL(&src), tmp);
BLEND_COLOR(A_VAL(&src), R_VAL(dst_ptr),
R_VAL(&src), R_VAL(dst_ptr),
tmp);
@ -54,7 +55,7 @@ evas_common_blend_color_rgba_to_rgb_mmx(DATA32 src, DATA32 *dst, int len)
punpckhdq_r2r(mm3, mm3);
psrlw_i2r(1, mm3);
psrlq_i2r(16, mm3);
// psrlq_i2r(16, mm3);
while (dst_ptr < dst_end_ptr)
{
@ -99,6 +100,7 @@ evas_common_blend_color_rgba_to_rgba_c(DATA32 src, DATA32 *dst, int len)
BLEND_COLOR(A_VAL(&src), A_VAL(dst_ptr),
255, A_VAL(dst_ptr),
tmp);
BLEND_ALPHA_SETUP(a, tmp);
BLEND_COLOR(a, R_VAL(dst_ptr),
R_VAL(&src), R_VAL(dst_ptr),
tmp);

View File

@ -12,6 +12,7 @@
BLEND_COLOR(A_VAL(src), A_VAL(dst), \
255, A_VAL(dst), \
__tmp); \
BLEND_ALPHA_SETUP(__a, __tmp); \
BLEND_COLOR(__a, R_VAL(dst), \
R_VAL(src), R_VAL(dst), \
__tmp); \
@ -30,6 +31,7 @@
\
if (A_VAL(src)) /* hmmm - do we need this? */ \
{ \
BLEND_ALPHA_SETUP(A_VAL(src), __tmp); \
BLEND_COLOR(A_VAL(src), R_VAL(dst), \
R_VAL(src), R_VAL(dst), \
__tmp); \

View File

@ -33,6 +33,7 @@ evas_common_blend_pixels_cmod_rgba_to_rgb_c(DATA32 *src, DATA32 *dst, int len, D
B_VAL(dst_ptr) = bmod[B_VAL(src_ptr)];
break;
default:
BLEND_ALPHA_SETUP(a, tmp);
BLEND_COLOR(a, R_VAL(dst_ptr),
rmod[R_VAL(src_ptr)], R_VAL(dst_ptr),
tmp);
@ -80,6 +81,7 @@ evas_common_blend_pixels_cmod_rgba_to_rgba_c(DATA32 *src, DATA32 *dst, int len,
a = _evas_pow_lut[(aa << 8) | A_VAL(dst_ptr)];
BLEND_COLOR(aa,A_VAL(dst_ptr),
255,A_VAL(dst_ptr),tmp);
BLEND_ALPHA_SETUP(a, tmp);
BLEND_COLOR(a, R_VAL(dst_ptr),
rmod[R_VAL(src_ptr)], R_VAL(dst_ptr),
tmp);

View File

@ -35,6 +35,7 @@ evas_common_blend_pixels_mul_color_rgba_to_rgb_c(DATA32 *src, DATA32 *dst, int l
*dst_ptr = *src_ptr;
break;
default:
BLEND_ALPHA_SETUP(a, tmp);
BLEND_COLOR(a, R_VAL(dst_ptr),
R_VAL(src_ptr), R_VAL(dst_ptr),
tmp);
@ -68,6 +69,7 @@ evas_common_blend_pixels_mul_color_rgba_to_rgb_c(DATA32 *src, DATA32 *dst, int l
B_VAL(dst_ptr) = ((B_VAL(src_ptr) * (B_VAL(&mul_color) + 1)) >> 8);
break;
default:
BLEND_ALPHA_SETUP(a, tmp);
BLEND_COLOR(a, R_VAL(dst_ptr),
((R_VAL(src_ptr) * (R_VAL(&mul_color) + 1)) >> 8), R_VAL(dst_ptr),
tmp);
@ -150,7 +152,7 @@ evas_common_blend_pixels_mul_color_rgba_to_rgb_mmx(DATA32 *src, DATA32 *dst, int
punpckhdq_r2r(mm3, mm3);
psrlw_i2r(1, mm3);
psrlq_i2r(16, mm3);
// psrlq_i2r(16, mm3);
punpcklbw_r2r(mm4, mm1);
punpcklbw_r2r(mm4, mm2);
@ -205,6 +207,7 @@ evas_common_blend_pixels_mul_color_rgba_to_rgba_c(DATA32 *src, DATA32 *dst, int
BLEND_COLOR(aa, A_VAL(dst_ptr),
255, A_VAL(dst_ptr),
tmp);
BLEND_ALPHA_SETUP(a, tmp);
BLEND_COLOR(a, R_VAL(dst_ptr),
R_VAL(src_ptr), R_VAL(dst_ptr),
tmp);
@ -244,6 +247,7 @@ evas_common_blend_pixels_mul_color_rgba_to_rgba_c(DATA32 *src, DATA32 *dst, int
BLEND_COLOR(aa, A_VAL(dst_ptr),
255, A_VAL(dst_ptr),
tmp);
BLEND_ALPHA_SETUP(a, tmp);
BLEND_COLOR(a, R_VAL(dst_ptr),
((R_VAL(src_ptr) * (R_VAL(&mul_color) + 1)) >> 8), R_VAL(dst_ptr),
tmp);

View File

@ -34,6 +34,7 @@ evas_common_blend_pixels_rgba_to_rgb_c(DATA32 *src, DATA32 *dst, int len)
*dst_ptr = *src_ptr;
break;
default:
BLEND_ALPHA_SETUP(a, tmp);
BLEND_COLOR(a, R_VAL(dst_ptr),
R_VAL(src_ptr), R_VAL(dst_ptr),
tmp);
@ -74,28 +75,28 @@ evas_common_blend_pixels_rgba_to_rgb_mmx(DATA32 *src, DATA32 *dst, int len)
*dst_ptr = *src_ptr;
break;
default:
movd_m2r(src_ptr[0], mm1);
movd_m2r(dst_ptr[0], mm2);
movd_m2r(src_ptr[0], mm1); // mm1 = [ ][ ][AR][GB] (SRC)
movd_m2r(dst_ptr[0], mm2); // mm2 = [ ][ ][ar][gb] (DST)
movq_r2r(mm1, mm3);
punpcklbw_r2r(mm3, mm3);
punpckhwd_r2r(mm3, mm3);
punpckhdq_r2r(mm3, mm3);
psrlw_i2r(1, mm3);
movq_r2r(mm1, mm3); // mm3 = [ ][ ][AR][GB]
punpcklbw_r2r(mm3, mm3); // mm3 = [AA][RR][GG][BB]
punpckhwd_r2r(mm3, mm3); // mm3 = [AA][AA][RR][RR]
punpckhdq_r2r(mm3, mm3); // mm3 = [AA][AA][AA][AA]
psrlw_i2r(1, mm3); // mm3 = [AA/2][AA/2][AA/2][AA/2]
psrlq_i2r(16, mm3);
// psrlq_i2r(16, mm3); // mm3 = [00][AA/2][AA/2][AA/2]
punpcklbw_r2r(mm4, mm1);
punpcklbw_r2r(mm4, mm2);
punpcklbw_r2r(mm4, mm1); // mm1 = [0A][0R][0G][0B]
punpcklbw_r2r(mm4, mm2); // mm2 = [0a][0r][0g][0b]
psubw_r2r(mm2, mm1);
psllw_i2r(1, mm1);
paddw_r2r(mm5, mm1);
pmulhw_r2r(mm3, mm1);
paddw_r2r(mm1, mm2);
packuswb_r2r(mm4, mm2);
movd_r2m(mm2, dst_ptr[0]);
psubw_r2r(mm2, mm1); // mm1 = [A-a][R-r][G-g][B-b]
psllw_i2r(1, mm1); // mm1 = [A*2][R*2][G*2][B*2]
paddw_r2r(mm5, mm1); // mm1 = [A+1][R+1][G+1][B+1]
pmulhw_r2r(mm3, mm1); // mm1 = [A*0][(R*AA)>>16][(G*AA)>>16][(B*AA)>>16]
paddw_r2r(mm1, mm2); // mm2 = [0a][R-r][G-g][B-b]
packuswb_r2r(mm4, mm2); // mm2 = [ ][ ][AR][GB]
movd_r2m(mm2, dst_ptr[0]); // DST = mm2
break;
}
src_ptr++;
@ -132,6 +133,7 @@ evas_common_blend_pixels_rgba_to_rgba_c(DATA32 *src, DATA32 *dst, int len)
BLEND_COLOR(aa, A_VAL(dst_ptr),
255, A_VAL(dst_ptr),
tmp);
BLEND_ALPHA_SETUP(a, tmp);
BLEND_COLOR(a, R_VAL(dst_ptr),
R_VAL(src_ptr), R_VAL(dst_ptr),
tmp);

View File

@ -59,6 +59,7 @@ evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x1, int y1, in
BLEND_COLOR(A_VAL(&(col)), A_VAL(ptr),
255, A_VAL(ptr),
__blend_tmp);
BLEND_ALPHA_SETUP(__blend_a, __blend_tmp);
BLEND_COLOR(__blend_a, R_VAL(ptr),
R_VAL(&(col)), R_VAL(ptr),
__blend_tmp);
@ -74,6 +75,7 @@ evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x1, int y1, in
DATA32 __blend_tmp;
ptr = dst->image->data + (y1 * dst->image->w) + x1;
BLEND_ALPHA_SETUP(A_VAL(&(col)), __blend_tmp);
BLEND_COLOR(A_VAL(&(col)), R_VAL(ptr),
R_VAL(&(col)), R_VAL(ptr),
__blend_tmp);
@ -152,6 +154,7 @@ evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x1, int y1, in
BLEND_COLOR(A_VAL(&(col)), A_VAL(ptr),
255, A_VAL(ptr),
__blend_tmp);
BLEND_ALPHA_SETUP(__blend_a, __blend_tmp);
BLEND_COLOR(__blend_a, R_VAL(ptr),
R_VAL(&(col)), R_VAL(ptr),
__blend_tmp);
@ -191,6 +194,7 @@ evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x1, int y1, in
BLEND_COLOR(A_VAL(&(col)), A_VAL(ptr),
255, A_VAL(ptr),
__blend_tmp);
BLEND_ALPHA_SETUP(__blend_a, __blend_tmp);
BLEND_COLOR(__blend_a, R_VAL(ptr),
R_VAL(&(col)), R_VAL(ptr),
__blend_tmp);
@ -227,6 +231,7 @@ evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x1, int y1, in
{
DATA32 __blend_tmp;
BLEND_ALPHA_SETUP(A_VAL(&(col)), __blend_tmp);
BLEND_COLOR(A_VAL(&(col)), R_VAL(ptr),
R_VAL(&(col)), R_VAL(ptr),
__blend_tmp);
@ -260,6 +265,7 @@ evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x1, int y1, in
{
DATA32 __blend_tmp;
BLEND_ALPHA_SETUP(A_VAL(&(col)), __blend_tmp);
BLEND_COLOR(A_VAL(&(col)), R_VAL(ptr),
R_VAL(&(col)), R_VAL(ptr),
__blend_tmp);

View File

@ -541,11 +541,34 @@ x++;
#define GB_VAL(p) ((DATA16 *)(p)[1])
#endif
/* thanks to some chats with Mirek Fidler... the new blender code for C
* blender fallbacks is faster. benchmarks (for the blending code only):
*
* OLD BLENDER:
* MMX: 0.606
* C: 1.026
*
* NEW BLENDER:
* C: 0.716
*/
#if 0 /* old blender */
#define BLEND_ALPHA_SETUP(a, tmp)
#define BLEND_COLOR(a, nc, c, cc, tmp) \
{ \
(tmp) = ((c) - (cc)) * (a); \
(nc) = (cc) + (((tmp) + ((tmp) >> 8) + 0x80) >> 8); \
}
#else /* new blender - faster! */
#define BLEND_ALPHA_SETUP(a, tmp) \
{ \
(tmp) = ((a) + ((a) >> 7)); \
}
#define BLEND_COLOR(a, nc, c, cc, tmp) \
{ \
(nc) = ((((tmp) * ((c) - (cc))) >> 8) + (cc)); \
}
#endif
#define PIXEL_SOLID_ALPHA 0xff000000