asm for colormod ops......... :)

SVN revision: 2600
This commit is contained in:
Carsten Haitzler 2000-05-05 16:28:39 +00:00
parent 15ff380285
commit 01d14d7867
7 changed files with 2532 additions and 631 deletions

View File

@ -16,11 +16,13 @@ include_HEADERS = Imlib2.h
libImlib2_la_SOURCES = rend.c ximage.c scale.c rgba.c image.c color.c grab.c \ libImlib2_la_SOURCES = rend.c ximage.c scale.c rgba.c image.c color.c grab.c \
blend.c file.c rgbadraw.c api.c draw.c context.c \ blend.c file.c rgbadraw.c api.c draw.c context.c \
updates.c colormod.c font.c format.c grad.c rotate.c \ updates.c colormod.c font.c format.c grad.c rotate.c \
filter.c \
Imlib2.h image.h scale.h blend.h context.h updates.h \ Imlib2.h image.h scale.h blend.h context.h updates.h \
color.h draw.h rend.h ximage.h colormod.h file.h \ color.h draw.h rend.h ximage.h colormod.h file.h \
rgba.h common.h grab.h rgbadraw.h font.h format.h \ rgba.h common.h grab.h rgbadraw.h font.h format.h \
rotate.h grad.h filter.h \ rotate.h grad.h filter.h \
asm_blend.S filter.c asm_rgba.S asm_scale.S asm_rotate.S asm_blend.S asm_rgba.S asm_scale.S asm_rotate.S \
asm_blend_cmod.S
libImlib2_la_LIBADD = @DLLDFLAGS@ $(top_builddir)/libltdl/libltdlc.la \ libImlib2_la_LIBADD = @DLLDFLAGS@ $(top_builddir)/libltdl/libltdlc.la \
-lX11 -lXext -lttf $(LDFLAGS) -lX11 -lXext -lttf $(LDFLAGS)
libImlib2_la_DEPENDENCIES = $(top_builddir)/config.h libImlib2_la_DEPENDENCIES = $(top_builddir)/config.h

View File

@ -31,6 +31,7 @@
.global __imlib_mmx_copy_rgba_to_rgba .global __imlib_mmx_copy_rgba_to_rgba
.type __imlib_mmx_copy_rgba_to_rgba,@function .type __imlib_mmx_copy_rgba_to_rgba,@function
.global __imlib_mmx_copy_rgb_to_rgba .global __imlib_mmx_copy_rgb_to_rgba
.type __imlib_mmx_copy_rgb_to_rgba,@function .type __imlib_mmx_copy_rgb_to_rgba,@function
.global __imlib_mmx_add_blend_rgba_to_rgb .global __imlib_mmx_add_blend_rgba_to_rgb
.type __imlib_mmx_add_blend_rgba_to_rgb,@function .type __imlib_mmx_add_blend_rgba_to_rgb,@function
@ -40,6 +41,9 @@
.type __imlib_mmx_add_copy_rgba_to_rgb,@function .type __imlib_mmx_add_copy_rgba_to_rgb,@function
.global __imlib_mmx_add_copy_rgba_to_rgba .global __imlib_mmx_add_copy_rgba_to_rgba
.type __imlib_mmx_add_copy_rgba_to_rgba,@function .type __imlib_mmx_add_copy_rgba_to_rgba,@function
.global __imlib_mmx_add_copy_rgb_to_rgba
.type __imlib_mmx_add_copy_rgb_to_rgba,@function
.global __imlib_mmx_subtract_blend_rgba_to_rgb .global __imlib_mmx_subtract_blend_rgba_to_rgb
.type __imlib_mmx_subtract_blend_rgba_to_rgb,@function .type __imlib_mmx_subtract_blend_rgba_to_rgb,@function
.global __imlib_mmx_subtract_blend_rgba_to_rgba .global __imlib_mmx_subtract_blend_rgba_to_rgba
@ -48,6 +52,9 @@
.type __imlib_mmx_subtract_copy_rgba_to_rgb,@function .type __imlib_mmx_subtract_copy_rgba_to_rgb,@function
.global __imlib_mmx_subtract_copy_rgba_to_rgba .global __imlib_mmx_subtract_copy_rgba_to_rgba
.type __imlib_mmx_subtract_copy_rgba_to_rgba,@function .type __imlib_mmx_subtract_copy_rgba_to_rgba,@function
.global __imlib_mmx_subtract_copy_rgb_to_rgba
.type __imlib_mmx_subtract_copy_rgb_to_rgba,@function
.global __imlib_mmx_reshade_blend_rgba_to_rgb .global __imlib_mmx_reshade_blend_rgba_to_rgb
.type __imlib_mmx_reshade_blend_rgba_to_rgb,@function .type __imlib_mmx_reshade_blend_rgba_to_rgb,@function
.global __imlib_mmx_reshade_blend_rgba_to_rgba .global __imlib_mmx_reshade_blend_rgba_to_rgba
@ -56,6 +63,8 @@
.type __imlib_mmx_reshade_copy_rgba_to_rgb,@function .type __imlib_mmx_reshade_copy_rgba_to_rgb,@function
.global __imlib_mmx_reshade_copy_rgba_to_rgba .global __imlib_mmx_reshade_copy_rgba_to_rgba
.type __imlib_mmx_reshade_copy_rgba_to_rgba,@function .type __imlib_mmx_reshade_copy_rgba_to_rgba,@function
.global __imlib_mmx_reshade_copy_rgb_to_rgba
.type __imlib_mmx_reshade_copy_rgb_to_rgba,@function
.bss .bss
.text .text
@ -84,51 +93,49 @@ c1: .word 0x1, 0x1, 0x1, 0x1
/*\ Common code \*/ /*\ Common code \*/
/*\ Set MMX mode, save registers, load common parameters \*/ /*\ Set MMX mode, save registers, load common parameters \*/
#define ENTER \ #define ENTER \
emms; \ pushl %ebp ;\
pushl %ebp; \ movl %esp, %ebp ;\
movl %esp, %ebp; \ pushl %ebx ;\
pushl %ebx; \ pushl %ecx ;\
pushl %ecx; \ pushl %edx ;\
pushl %edx; \ pushl %edi ;\
pushl %edi; \ pushl %esi ;\
pushl %esi; \ movl h, %edx ;\
movl src, %esi; \ movl w, %ebx ;\
movl dst, %edi; \ movl src, %esi ;\
movl w, %ebx; \ movl dst, %edi ;\
movl h, %edx leal (%esi, %ebx, 4), %esi ;\
leal (%edi, %ebx, 4), %edi ;\
negl %ebx ;\
jz 9f ;\
decl %edx ;\
jz 9f ;\
#define LOOP_START \ #define LOOP_START \
decl %edx; \ 8: ;\
js 3f; \
decl %ebx; \
js 3f; \
0: \
movl %ebx, %ecx movl %ebx, %ecx
#define LOOP_END \ #define LOOP_END \
decl %ecx; \ movl sw, %ecx ;\
jns 1b; \ leal (%esi, %ecx, 4), %esi ;\
2: \ movl dw, %ecx ;\
movl sw, %ecx; \ leal (%edi, %ecx, 4), %edi ;\
leal (%esi, %ecx, 4), %esi; \ decl %edx ;\
movl dw, %ecx; \ jns 8b
leal (%edi, %ecx, 4), %edi; \
decl %edx; \
jns 0b
/*\ Unset MMX mode, reset registers, return \*/ /*\ Unset MMX mode, reset registers, return \*/
#define LEAVE \ #define LEAVE \
3: \ 9: ;\
emms; \ emms ;\
popl %esi; \ popl %esi ;\
popl %edi; \ popl %edi ;\
popl %edx; \ popl %edx ;\
popl %ecx; \ popl %ecx ;\
popl %ebx; \ popl %ebx ;\
movl %ebp, %esp; \ movl %ebp, %esp ;\
popl %ebp; \ popl %ebp ;\
ret ret
@ -180,47 +187,8 @@ __imlib_mmx_blend_rgba_to_rgb:
packuswb %mm4, %mm2 packuswb %mm4, %mm2
movd %mm2, (%edi, %ecx, 4) movd %mm2, (%edi, %ecx, 4)
LOOP_END incl %ecx
LEAVE js 1b
__imlib_mmx_copy_rgba_to_rgb:
ENTER
movq m0XXX0XXX, %mm5
movq mX000X000, %mm6
LOOP_START
/*\ Check for oddness \*/
sarl $1, %ecx
jc 1f
/*\ Load source and destination \*/
movd (%esi, %ecx, 8), %mm1
movd (%edi, %ecx, 8), %mm2
/*\ Clear alpha channel of source, get alpha of destination \*/
pand %mm5, %mm1
pand %mm6, %mm2
/*\ d = d | s, and save \*/
por %mm1, %mm2
movd %mm2, (%edi, %ecx, 8)
decl %ecx
js 2f
1:
/*\ Load source and destination \*/
movq (%esi, %ecx, 8), %mm1
movq (%edi, %ecx, 8), %mm2
/*\ Clear alpha channel of source \*/
pand %mm5, %mm1
pand %mm6, %mm2
/*\ d = d | s, and save \*/
por %mm1, %mm2
movq %mm2, (%edi, %ecx, 8)
LOOP_END LOOP_END
LEAVE LEAVE
@ -273,6 +241,52 @@ __imlib_mmx_blend_rgba_to_rgba:
packuswb %mm4, %mm2 packuswb %mm4, %mm2
movd %mm2, (%edi, %ecx, 4) movd %mm2, (%edi, %ecx, 4)
incl %ecx
js 1b
LOOP_END
LEAVE
__imlib_mmx_copy_rgba_to_rgb:
ENTER
movq m0XXX0XXX, %mm5
movq mX000X000, %mm6
/*\ Two at a time: last item is at %ecx = 0 \*/
subl $4, %esi
subl $4, %edi
LOOP_START
incl %ecx
jz 2f
1:
/*\ Load source and destination \*/
movq (%esi, %ecx, 4), %mm1
movq (%edi, %ecx, 4), %mm2
/*\ Clear alpha channel of source, get alpha of destination \*/
pand %mm5, %mm1
pand %mm6, %mm2
/*\ d = d | s, and save \*/
por %mm1, %mm2
movq %mm2, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
pand %mm5, %mm1
pand %mm6, %mm2
por %mm1, %mm2
movd %mm2, (%edi)
3:
LOOP_END LOOP_END
LEAVE LEAVE
@ -280,23 +294,24 @@ __imlib_mmx_blend_rgba_to_rgba:
__imlib_mmx_copy_rgba_to_rgba: __imlib_mmx_copy_rgba_to_rgba:
ENTER ENTER
subl $4, %esi
subl $4, %edi
LOOP_START LOOP_START
incl %ecx
/*\ Check for oddness \*/
sarl $1, %ecx
jc 1f
/*\ Load source, save destination \*/
movd (%esi, %ecx, 8), %mm1
movd %mm1, (%edi, %ecx, 8)
decl %ecx
jz 2f jz 2f
1: 1:
/*\ Load source, save destination \*/ /*\ Load source, save destination \*/
movq (%esi, %ecx, 8), %mm1 movq (%esi, %ecx, 4), %mm1
movq %mm1, (%edi, %ecx, 8) movq %mm1, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd %mm1, (%edi)
3:
LOOP_END LOOP_END
LEAVE LEAVE
@ -306,24 +321,26 @@ __imlib_mmx_copy_rgb_to_rgba:
movq mX000X000, %mm5 movq mX000X000, %mm5
subl $4, %esi
subl $4, %edi
LOOP_START LOOP_START
incl %ecx
/*\ Check for oddness \*/
sarl $1, %ecx
jc 1f
/*\ Load source, make alpha 0xff, save destination \*/
movd (%esi, %ecx, 8), %mm1
por %mm5, %mm1
movd %mm1, (%edi, %ecx, 8)
decl %ecx
jz 2f jz 2f
1: 1:
/*\ Load source, save destination \*/ /*\ Load source, save destination \*/
movq (%esi, %ecx, 8), %mm1 movq (%esi, %ecx, 4), %mm1
por %mm5, %mm1 por %mm5, %mm1
movq %mm1, (%edi, %ecx, 8) movq %mm1, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
por %mm5, %mm1
movd %mm1, (%edi)
3:
LOOP_END LOOP_END
LEAVE LEAVE
@ -362,6 +379,9 @@ __imlib_mmx_add_blend_rgba_to_rgb:
packuswb %mm4, %mm2 packuswb %mm4, %mm2
movd %mm2, (%edi, %ecx, 4) movd %mm2, (%edi, %ecx, 4)
incl %ecx
js 1b
LOOP_END LOOP_END
LEAVE LEAVE
@ -407,6 +427,9 @@ __imlib_mmx_add_blend_rgba_to_rgba:
packuswb %mm4, %mm2 packuswb %mm4, %mm2
movd %mm2, (%edi, %ecx, 4) movd %mm2, (%edi, %ecx, 4)
incl %ecx
js 1b
LOOP_END LOOP_END
LEAVE LEAVE
@ -416,37 +439,34 @@ __imlib_mmx_add_copy_rgba_to_rgb:
movq m0XXX0XXX, %mm5 movq m0XXX0XXX, %mm5
subl $4, %esi
subl $4, %edi
LOOP_START LOOP_START
incl %ecx
/*\ Check for oddness \*/
sarl $1, %ecx
jc 1f
/*\ Load source and destination \*/
movd (%esi, %ecx, 8), %mm1
movd (%edi, %ecx, 8), %mm2
/*\ Clear alpha channel of source \*/
pand %mm5, %mm1
/*\ d = d + s, unsigned saturation, and save \*/
paddusb %mm1, %mm2
movd %mm2, (%edi, %ecx, 8)
decl %ecx
jz 2f jz 2f
1: 1:
/*\ Load source and destination \*/ /*\ Load source and destination \*/
movq (%esi, %ecx, 8), %mm1 movq (%esi, %ecx, 4), %mm1
movq (%edi, %ecx, 8), %mm2 movq (%edi, %ecx, 4), %mm2
/*\ Clear alpha channel of source \*/ /*\ Clear alpha channel of source \*/
pand %mm5, %mm1 pand %mm5, %mm1
/*\ d = d + s, unsigned saturation, and save \*/ /*\ d = d + s, unsigned saturation, and save \*/
paddusb %mm1, %mm2 paddusb %mm1, %mm2
movq %mm2, (%edi, %ecx, 8) movq %mm2, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
pand %mm5, %mm1
paddusb %mm1, %mm2
movd %mm2, (%edi)
3:
LOOP_END LOOP_END
LEAVE LEAVE
@ -454,30 +474,67 @@ __imlib_mmx_add_copy_rgba_to_rgb:
__imlib_mmx_add_copy_rgba_to_rgba: __imlib_mmx_add_copy_rgba_to_rgba:
ENTER ENTER
subl $4, %esi
subl $4, %edi
LOOP_START LOOP_START
incl %ecx
/*\ Check for oddness \*/
sarl $1, %ecx
jc 1f
/*\ Load source and destination \*/
movd (%esi, %ecx, 8), %mm1
movd (%edi, %ecx, 8), %mm2
/*\ d = d + s, unsigned saturation, and save \*/
paddusb %mm1, %mm2
movd %mm2, (%edi, %ecx, 8)
decl %ecx
jz 2f jz 2f
1: 1:
/*\ Load source and destination \*/ /*\ Load source and destination \*/
movq (%esi, %ecx, 8), %mm1 movq (%esi, %ecx, 4), %mm1
movq (%edi, %ecx, 8), %mm2 movq (%edi, %ecx, 4), %mm2
/*\ d = d + s, unsigned saturation, and save \*/ /*\ d = d + s, unsigned saturation, and save \*/
paddusb %mm1, %mm2 paddusb %mm1, %mm2
movq %mm2, (%edi, %ecx, 8) movq %mm2, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
paddusb %mm1, %mm2
movd %mm2, (%edi)
3:
LOOP_END
LEAVE
__imlib_mmx_add_copy_rgb_to_rgba:
ENTER
movq mX000X000, %mm5
subl $4, %esi
subl $4, %edi
LOOP_START
incl %ecx
jz 2f
1:
/*\ Load source and destination \*/
movq (%esi, %ecx, 4), %mm1
movq (%edi, %ecx, 4), %mm2
/*\ d = d + s, unsigned saturation, and save \*/
paddusb %mm1, %mm2
/*\ Make result alpha 0xff \*/
por %mm5, %mm2
movq %mm2, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
paddusb %mm1, %mm2
por %mm5, %mm2
movd %mm2, (%edi)
3:
LOOP_END LOOP_END
LEAVE LEAVE
@ -515,6 +572,9 @@ __imlib_mmx_subtract_blend_rgba_to_rgb:
packuswb %mm4, %mm2 packuswb %mm4, %mm2
movd %mm2, (%edi, %ecx, 4) movd %mm2, (%edi, %ecx, 4)
incl %ecx
js 1b
LOOP_END LOOP_END
LEAVE LEAVE
@ -560,6 +620,9 @@ __imlib_mmx_subtract_blend_rgba_to_rgba:
packuswb %mm4, %mm2 packuswb %mm4, %mm2
movd %mm2, (%edi, %ecx, 4) movd %mm2, (%edi, %ecx, 4)
incl %ecx
js 1b
LOOP_END LOOP_END
LEAVE LEAVE
@ -569,37 +632,34 @@ __imlib_mmx_subtract_copy_rgba_to_rgb:
movq m0XXX0XXX, %mm5 movq m0XXX0XXX, %mm5
subl $4, %esi
subl $4, %edi
LOOP_START LOOP_START
incl %ecx
/*\ Check for oddness \*/
sarl $1, %ecx
jc 1f
/*\ Load source and destination \*/
movd (%esi, %ecx, 8), %mm1
movd (%edi, %ecx, 8), %mm2
/*\ Clear alpha channel of source \*/
pand %mm5, %mm1
/*\ d = d - s, unsigned saturation, and save \*/
psubusb %mm1, %mm2
movd %mm2, (%edi, %ecx, 8)
decl %ecx
jz 2f jz 2f
1: 1:
/*\ Load source and destination \*/ /*\ Load source and destination \*/
movq (%esi, %ecx, 8), %mm1 movq (%esi, %ecx, 4), %mm1
movq (%edi, %ecx, 8), %mm2 movq (%edi, %ecx, 4), %mm2
/*\ Clear alpha channel of source \*/ /*\ Clear alpha channel of source \*/
pand %mm5, %mm1 pand %mm5, %mm1
/*\ d = d - s, unsigned saturation, and save \*/ /*\ d = d - s, unsigned saturation, and save \*/
psubusb %mm1, %mm2 psubusb %mm1, %mm2
movq %mm2, (%edi, %ecx, 8) movq %mm2, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
pand %mm5, %mm1
psubusb %mm1, %mm2
movd %mm2, (%edi)
3:
LOOP_END LOOP_END
LEAVE LEAVE
@ -609,15 +669,16 @@ __imlib_mmx_subtract_copy_rgba_to_rgba:
movq mX000X000, %mm5 movq mX000X000, %mm5
subl $4, %esi
subl $4, %edi
LOOP_START LOOP_START
incl %ecx
/*\ Check for oddness \*/ jz 2f
sarl $1, %ecx 1:
jc 1f
/*\ Load source and destination \*/ /*\ Load source and destination \*/
movd (%esi, %ecx, 8), %mm1 movq (%esi, %ecx, 4), %mm1
movd (%edi, %ecx, 8), %mm2 movq (%edi, %ecx, 4), %mm2
/*\ Negate destination alphas \*/ /*\ Negate destination alphas \*/
pxor %mm5, %mm2 pxor %mm5, %mm2
@ -627,20 +688,56 @@ __imlib_mmx_subtract_copy_rgba_to_rgba:
/*\ Negate result alphas \*/ /*\ Negate result alphas \*/
pxor %mm5, %mm2 pxor %mm5, %mm2
movd %mm2, (%edi, %ecx, 8) movq %mm2, (%edi, %ecx, 4)
decl %ecx
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
pxor %mm5, %mm2
psubusb %mm1, %mm2
pxor %mm5, %mm2
movd %mm2, (%edi)
3:
LOOP_END
LEAVE
__imlib_mmx_subtract_copy_rgb_to_rgba:
ENTER
movq mX000X000, %mm5
subl $4, %esi
subl $4, %edi
LOOP_START
incl %ecx
jz 2f jz 2f
1: 1:
/*\ Load source and destination \*/ /*\ Load source and destination \*/
movq (%esi, %ecx, 8), %mm1 movq (%esi, %ecx, 4), %mm1
movq (%edi, %ecx, 8), %mm2 movq (%edi, %ecx, 4), %mm2
pxor %mm5, %mm2
/*\ d = d - s, unsigned saturation, and save \*/ /*\ d = d - s, unsigned saturation, and save \*/
psubusb %mm1, %mm2 psubusb %mm1, %mm2
pxor %mm5, %mm2
movq %mm2, (%edi, %ecx, 8) /*\ Make result alpha 0xff \*/
por %mm5, %mm2
movq %mm2, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
psubusb %mm1, %mm2
por %mm5, %mm2
movd %mm2, (%edi)
3:
LOOP_END LOOP_END
LEAVE LEAVE
@ -680,6 +777,9 @@ __imlib_mmx_reshade_blend_rgba_to_rgb:
packuswb %mm4, %mm2 packuswb %mm4, %mm2
movd %mm2, (%edi, %ecx, 4) movd %mm2, (%edi, %ecx, 4)
incl %ecx
js 1b
LOOP_END LOOP_END
LEAVE LEAVE
@ -728,6 +828,9 @@ __imlib_mmx_reshade_blend_rgba_to_rgba:
packuswb %mm4, %mm2 packuswb %mm4, %mm2
movd %mm2, (%edi, %ecx, 4) movd %mm2, (%edi, %ecx, 4)
incl %ecx
js 1b
LOOP_END LOOP_END
LEAVE LEAVE
@ -739,15 +842,16 @@ __imlib_mmx_reshade_copy_rgba_to_rgb:
movq m0XXX0XXX, %mm5 movq m0XXX0XXX, %mm5
movq m0VVV0VVV, %mm6 movq m0VVV0VVV, %mm6
subl $4, %esi
subl $4, %edi
LOOP_START LOOP_START
incl %ecx
/*\ Check for oddness \*/ jz 2f
sarl $1, %ecx 1:
jc 1f
/*\ Load source and destination \*/ /*\ Load source and destination \*/
movd (%esi, %ecx, 8), %mm1 movq (%esi, %ecx, 4), %mm1
movd (%edi, %ecx, 8), %mm2 movq (%edi, %ecx, 4), %mm2
/*\ To take advantage of saturation and be able to do 8 bytes /*\ To take advantage of saturation and be able to do 8 bytes
|*| at a time, we divide reshading into two separate steps: |*| at a time, we divide reshading into two separate steps:
@ -770,32 +874,26 @@ __imlib_mmx_reshade_copy_rgba_to_rgb:
/*\ d = d + s1 - s2, unsigned saturation, and save \*/ /*\ d = d + s1 - s2, unsigned saturation, and save \*/
paddusb %mm1, %mm2 paddusb %mm1, %mm2
psubusb %mm3, %mm2 psubusb %mm3, %mm2
movd %mm2, (%edi, %ecx, 8) movq %mm2, (%edi, %ecx, 4)
/*\ MMX ops don't set flags \*/ addl $2, %ecx
decl %ecx js 1b
jz 2f jnz 3f
1: 2:
/*\ Load source and destination \*/ movd (%esi), %mm1
movq (%esi, %ecx, 8), %mm1 movd (%edi), %mm2
movq (%edi, %ecx, 8), %mm2
movq %mm1, %mm3 movq %mm1, %mm3
psubusb %mm6, %mm1 psubusb %mm6, %mm1
paddusb %mm1, %mm1 paddusb %mm1, %mm1
paddusb %mm6, %mm3 paddusb %mm6, %mm3
pxor %mm5, %mm3 pxor %mm5, %mm3
paddusb %mm3, %mm3 paddusb %mm3, %mm3
/*\ Clear alpha channel of s1 and s2 \*/
pand %mm5, %mm1 pand %mm5, %mm1
pand %mm5, %mm3 pand %mm5, %mm3
/*\ d = d + s1 - s2, unsigned saturation, and save \*/
paddusb %mm1, %mm2 paddusb %mm1, %mm2
psubusb %mm3, %mm2 psubusb %mm3, %mm2
movq %mm2, (%edi, %ecx, 8) movd %mm2, (%edi)
3:
LOOP_END LOOP_END
LEAVE LEAVE
@ -807,15 +905,16 @@ __imlib_mmx_reshade_copy_rgba_to_rgba:
movq m0XXX0XXX, %mm5 movq m0XXX0XXX, %mm5
movq m0VVV0VVV, %mm6 movq m0VVV0VVV, %mm6
subl $4, %esi
subl $4, %edi
LOOP_START LOOP_START
incl %ecx
/*\ Check for oddness \*/ jz 2f
sarl $1, %ecx 1:
jc 1f
/*\ Load source and destination \*/ /*\ Load source and destination \*/
movd (%esi, %ecx, 8), %mm1 movq (%esi, %ecx, 4), %mm1
movd (%edi, %ecx, 8), %mm2 movq (%edi, %ecx, 4), %mm2
/*\ This time, the alpha channels have to be added. /*\ This time, the alpha channels have to be added.
|*| For that, the alpha channel of %mm1 should remain |*| For that, the alpha channel of %mm1 should remain
@ -838,16 +937,14 @@ __imlib_mmx_reshade_copy_rgba_to_rgba:
/*\ d = d + s1 - s2, unsigned saturation, and save \*/ /*\ d = d + s1 - s2, unsigned saturation, and save \*/
paddusb %mm1, %mm2 paddusb %mm1, %mm2
psubusb %mm3, %mm2 psubusb %mm3, %mm2
movd %mm2, (%edi, %ecx, 8) movq %mm2, (%edi, %ecx, 4)
/*\ MMX ops don't set flags \*/ addl $2, %ecx
decl %ecx js 1b
jz 2f jnz 3f
1: 2:
/*\ Load source and destination \*/ movd (%esi), %mm1
movq (%esi, %ecx, 8), %mm1 movd (%edi), %mm2
movq (%edi, %ecx, 8), %mm2
movq %mm1, %mm3 movq %mm1, %mm3
psubusb %mm6, %mm1 psubusb %mm6, %mm1
movq %mm1, %mm0 movq %mm1, %mm0
@ -856,15 +953,66 @@ __imlib_mmx_reshade_copy_rgba_to_rgba:
paddusb %mm6, %mm3 paddusb %mm6, %mm3
pxor %mm5, %mm3 pxor %mm5, %mm3
paddusb %mm3, %mm3 paddusb %mm3, %mm3
/*\ Clear alpha channel of s2 \*/
pand %mm5, %mm3 pand %mm5, %mm3
paddusb %mm1, %mm2
psubusb %mm3, %mm2
movd %mm2, (%edi)
3:
LOOP_END
LEAVE
__imlib_mmx_reshade_copy_rgb_to_rgba:
ENTER
pxor %mm4, %mm4
movq m0XXX0XXX, %mm5
movq m0VVV0VVV, %mm6
movq mX000X000, %mm7
subl $4, %esi
subl $4, %edi
LOOP_START
incl %ecx
jz 2f
1:
/*\ Load source and destination \*/
movq (%esi, %ecx, 4), %mm1
movq (%edi, %ecx, 4), %mm2
movq %mm1, %mm3
psubusb %mm6, %mm1
paddusb %mm1, %mm1
paddusb %mm6, %mm3
pxor %mm5, %mm3
paddusb %mm3, %mm3
/*\ d = d + s1 - s2, unsigned saturation, and save \*/ /*\ d = d + s1 - s2, unsigned saturation, and save \*/
paddusb %mm1, %mm2 paddusb %mm1, %mm2
psubusb %mm3, %mm2 psubusb %mm3, %mm2
movq %mm2, (%edi, %ecx, 8)
/*\ Make result alpha 0xff \*/
por %mm7, %mm2
movq %mm2, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
movq %mm1, %mm3
psubusb %mm6, %mm1
paddusb %mm1, %mm1
paddusb %mm6, %mm3
pxor %mm5, %mm3
paddusb %mm3, %mm3
paddusb %mm1, %mm2
psubusb %mm3, %mm2
por %mm7, %mm2
movd %mm2, (%edi)
3:
LOOP_END LOOP_END
LEAVE LEAVE

1558
src/asm_blend_cmod.S Normal file

File diff suppressed because it is too large Load Diff

View File

@ -91,17 +91,6 @@ __imlib_BlendRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
LOOP_END_WITH_INCREMENT LOOP_END_WITH_INCREMENT
} }
static void
__imlib_BlendRGBToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START
*p2 = 0xff000000 | (*p1 & 0x00ffffff);
LOOP_END_WITH_INCREMENT
}
static void static void
__imlib_CopyRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw, __imlib_CopyRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm) int w, int h, ImlibColorModifier *cm)
@ -186,7 +175,6 @@ __imlib_AddCopyRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
{ {
LOOP_START_3 LOOP_START_3
SATURATE_UPPER(a, A_VAL(p1) + (255 - A_VAL(p2)));
ADD_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2)); ADD_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
ADD_COLOR(G_VAL(p2), G_VAL(p1), G_VAL(p2)); ADD_COLOR(G_VAL(p2), G_VAL(p1), G_VAL(p2));
ADD_COLOR(B_VAL(p2), B_VAL(p1), B_VAL(p2)); ADD_COLOR(B_VAL(p2), B_VAL(p1), B_VAL(p2));
@ -195,6 +183,20 @@ __imlib_AddCopyRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
LOOP_END_WITH_INCREMENT LOOP_END_WITH_INCREMENT
} }
static void
__imlib_AddCopyRGBToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
ADD_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
ADD_COLOR(G_VAL(p2), G_VAL(p1), G_VAL(p2));
ADD_COLOR(B_VAL(p2), B_VAL(p1), B_VAL(p2));
A_VAL(p2) = 0xff;
LOOP_END_WITH_INCREMENT
}
/* SUBTRACT OPS */ /* SUBTRACT OPS */
static void static void
@ -254,6 +256,20 @@ __imlib_SubCopyRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
LOOP_END_WITH_INCREMENT LOOP_END_WITH_INCREMENT
} }
static void
__imlib_SubCopyRGBToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
SUB_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
SUB_COLOR(G_VAL(p2), G_VAL(p1), G_VAL(p2));
SUB_COLOR(B_VAL(p2), B_VAL(p1), B_VAL(p2));
A_VAL(p2) = 0xff;
LOOP_END_WITH_INCREMENT
}
/* RESHADE OPS */ /* RESHADE OPS */
@ -314,6 +330,20 @@ __imlib_ReCopyRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
LOOP_END_WITH_INCREMENT LOOP_END_WITH_INCREMENT
} }
static void
__imlib_ReCopyRGBToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
RESHADE_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
RESHADE_COLOR(G_VAL(p2), G_VAL(p1), G_VAL(p2));
RESHADE_COLOR(B_VAL(p2), B_VAL(p1), B_VAL(p2));
A_VAL(p2) = 0xff;
LOOP_END_WITH_INCREMENT
}
@ -369,10 +399,25 @@ __imlib_BlendRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
{ {
LOOP_START_3 LOOP_START_3
R_VAL(p2) = R_CMOD(cm, R_VAL(p1)); SATURATE_UPPER(a, A_CMOD(cm, 0xff) + (255 - A_VAL(p2)));
G_VAL(p2) = G_CMOD(cm, G_VAL(p1)); BLEND_COLOR(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
B_VAL(p2) = B_CMOD(cm, B_VAL(p1)); BLEND_COLOR(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
A_VAL(p2) = 0xff; BLEND_COLOR(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_CMOD(cm, 0xff) + A_VAL(p2));
LOOP_END_WITH_INCREMENT
}
static void
__imlib_BlendRGBToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
a = A_CMOD(cm, 0xff);
BLEND_COLOR(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
BLEND_COLOR(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
BLEND_COLOR(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
LOOP_END_WITH_INCREMENT LOOP_END_WITH_INCREMENT
} }
@ -399,7 +444,7 @@ __imlib_CopyRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
R_VAL(p2) = R_CMOD(cm, R_VAL(p1)); R_VAL(p2) = R_CMOD(cm, R_VAL(p1));
G_VAL(p2) = G_CMOD(cm, G_VAL(p1)); G_VAL(p2) = G_CMOD(cm, G_VAL(p1));
B_VAL(p2) = B_CMOD(cm, B_VAL(p1)); B_VAL(p2) = B_CMOD(cm, B_VAL(p1));
A_VAL(p2) = 0xff; A_VAL(p2) = A_CMOD(cm, 0xff);
LOOP_END_WITH_INCREMENT LOOP_END_WITH_INCREMENT
} }
@ -449,6 +494,35 @@ __imlib_AddBlendRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
LOOP_END_WITH_INCREMENT LOOP_END_WITH_INCREMENT
} }
static void
__imlib_AddBlendRGBToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
a = A_CMOD(cm, 0xff);
ADD_COLOR_WITH_ALPHA(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
ADD_COLOR_WITH_ALPHA(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
ADD_COLOR_WITH_ALPHA(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
LOOP_END_WITH_INCREMENT
}
static void
__imlib_AddBlendRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
SATURATE_UPPER(a, A_CMOD(cm, 0xff) + (255 - A_VAL(p2)));
ADD_COLOR_WITH_ALPHA(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
ADD_COLOR_WITH_ALPHA(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
ADD_COLOR_WITH_ALPHA(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_CMOD(cm, A_VAL(p1)) + A_VAL(p2));
LOOP_END_WITH_INCREMENT
}
static void static void
__imlib_AddCopyRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw, __imlib_AddCopyRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm) int w, int h, ImlibColorModifier *cm)
@ -476,6 +550,20 @@ __imlib_AddCopyRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
LOOP_END_WITH_INCREMENT LOOP_END_WITH_INCREMENT
} }
static void
__imlib_AddCopyRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
ADD_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
ADD_COLOR(G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
ADD_COLOR(B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_CMOD(cm, 0xff) + A_VAL(p2));
LOOP_END_WITH_INCREMENT
}
/* SUBTRACT OPS */ /* SUBTRACT OPS */
static void static void
@ -508,6 +596,36 @@ __imlib_SubBlendRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
LOOP_END_WITH_INCREMENT LOOP_END_WITH_INCREMENT
} }
static void
__imlib_SubBlendRGBToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_2
a = A_CMOD(cm, 0xff);
SUB_COLOR_WITH_ALPHA(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
SUB_COLOR_WITH_ALPHA(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
SUB_COLOR_WITH_ALPHA(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
LOOP_END_WITH_INCREMENT
}
static void
__imlib_SubBlendRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
SATURATE_UPPER(a, A_CMOD(cm, 0xff) + (255 - A_VAL(p2)));
SUB_COLOR_WITH_ALPHA(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
SUB_COLOR_WITH_ALPHA(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
SUB_COLOR_WITH_ALPHA(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_CMOD(cm, 0xff) + A_VAL(p2));
LOOP_END_WITH_INCREMENT
}
static void static void
__imlib_SubCopyRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw, __imlib_SubCopyRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm) int w, int h, ImlibColorModifier *cm)
@ -535,6 +653,20 @@ __imlib_SubCopyRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
LOOP_END_WITH_INCREMENT LOOP_END_WITH_INCREMENT
} }
static void
__imlib_SubCopyRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
SUB_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
SUB_COLOR(G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
SUB_COLOR(B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_CMOD(cm, 0xff) + A_VAL(p2));
LOOP_END_WITH_INCREMENT
}
/* RESHADE OPS */ /* RESHADE OPS */
@ -568,6 +700,36 @@ __imlib_ReBlendRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
LOOP_END_WITH_INCREMENT LOOP_END_WITH_INCREMENT
} }
static void
__imlib_ReBlendRGBToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_2
a = A_CMOD(cm, 0xff);
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));
LOOP_END_WITH_INCREMENT
}
static void
__imlib_ReBlendRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
SATURATE_UPPER(a, A_CMOD(cm, A_VAL(p1)) + (255 - A_VAL(p2)));
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));
SATURATE_UPPER(A_VAL(p2), A_CMOD(cm, 0xff) + A_VAL(p2));
LOOP_END_WITH_INCREMENT
}
static void static void
__imlib_ReCopyRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw, __imlib_ReCopyRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm) int w, int h, ImlibColorModifier *cm)
@ -595,271 +757,169 @@ __imlib_ReCopyRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
LOOP_END_WITH_INCREMENT LOOP_END_WITH_INCREMENT
} }
static void
__imlib_ReCopyRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
int w, int h, ImlibColorModifier *cm)
{
LOOP_START_3
RESHADE_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
RESHADE_COLOR(G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
RESHADE_COLOR(B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_CMOD(cm, 0xff) + A_VAL(p2));
LOOP_END_WITH_INCREMENT
}
/*\ Equivalent functions \*/
#define __imlib_CopyRGBToRGB __imlib_CopyRGBToRGBA
#define __imlib_BlendRGBToRGB __imlib_CopyRGBToRGB
#define __imlib_BlendRGBToRGBA __imlib_CopyRGBToRGBA
#define __imlib_mmx_copy_rgb_to_rgb __imlib_mmx_copy_rgb_to_rgba
#define __imlib_mmx_blend_rgb_to_rgb __imlib_mmx_copy_rgb_to_rgb
#define __imlib_mmx_blend_rgb_to_rgba __imlib_mmx_copy_rgb_to_rgba
#define __imlib_CopyRGBToRGBCmod __imlib_CopyRGBAToRGBCmod
#define __imlib_mmx_copy_rgb_to_rgb_cmod __imlib_mmx_copy_rgba_to_rgb_cmod
#define __imlib_AddCopyRGBToRGB __imlib_AddCopyRGBAToRGB
#define __imlib_AddBlendRGBToRGB __imlib_AddCopyRGBToRGB
#define __imlib_AddBlendRGBToRGBA __imlib_AddCopyRGBToRGBA
#define __imlib_mmx_add_copy_rgb_to_rgb __imlib_mmx_add_copy_rgba_to_rgb
#define __imlib_mmx_add_blend_rgb_to_rgb __imlib_mmx_add_copy_rgb_to_rgb
#define __imlib_mmx_add_blend_rgb_to_rgba __imlib_mmx_add_copy_rgb_to_rgba
#define __imlib_AddCopyRGBToRGBCmod __imlib_AddCopyRGBAToRGBCmod
#define __imlib_mmx_add_copy_rgb_to_rgb_cmod __imlib_mmx_add_copy_rgb_to_rgba_cmod
#define __imlib_SubCopyRGBToRGB __imlib_SubCopyRGBAToRGB
#define __imlib_SubBlendRGBToRGB __imlib_SubCopyRGBToRGB
#define __imlib_SubBlendRGBToRGBA __imlib_SubCopyRGBToRGBA
#define __imlib_mmx_subtract_copy_rgb_to_rgba __imlib_mmx_subtract_copy_rgba_to_rgba
#define __imlib_mmx_subtract_copy_rgb_to_rgb __imlib_mmx_subtract_copy_rgba_to_rgb
#define __imlib_mmx_subtract_blend_rgb_to_rgb __imlib_mmx_subtract_copy_rgb_to_rgb
#define __imlib_mmx_subtract_blend_rgb_to_rgba __imlib_mmx_subtract_copy_rgb_to_rgba
#define __imlib_SubCopyRGBToRGBCmod __imlib_SubCopyRGBAToRGBCmod
#define __imlib_mmx_subtract_copy_rgb_to_rgb_cmod __imlib_mmx_subtract_copy_rgb_to_rgba_cmod
#define __imlib_ReCopyRGBToRGB __imlib_ReCopyRGBAToRGB
#define __imlib_ReBlendRGBToRGB __imlib_ReCopyRGBToRGB
#define __imlib_ReBlendRGBToRGBA __imlib_ReCopyRGBToRGBA
#define __imlib_mmx_reshade_copy_rgb_to_rgba __imlib_mmx_reshade_copy_rgba_to_rgba
#define __imlib_mmx_reshade_copy_rgb_to_rgb __imlib_mmx_reshade_copy_rgba_to_rgb
#define __imlib_mmx_reshade_blend_rgb_to_rgb __imlib_mmx_reshade_copy_rgb_to_rgb
#define __imlib_mmx_reshade_blend_rgb_to_rgba __imlib_mmx_reshade_copy_rgb_to_rgba
#define __imlib_ReCopyRGBToRGBCmod __imlib_ReCopyRGBAToRGBCmod
#define __imlib_mmx_reshade_copy_rgb_to_rgb_cmod __imlib_mmx_reshade_copy_rgb_to_rgba_cmod
ImlibBlendFunction ImlibBlendFunction
__imlib_GetBlendFunction(ImlibOp op, char blend, char merge_alpha, char rgb_src, __imlib_GetBlendFunction(ImlibOp op, char blend, char merge_alpha, char rgb_src,
ImlibColorModifier * cm) ImlibColorModifier * cm)
{ {
ImlibBlendFunction blender = NULL; /*\ [ mmx ][ operation ][ cmod ][ merge_alpha ][ rgb_src ][ blend ] \*/
static ImlibBlendFunction ibfuncs[][4][2][2][2][2] = {
/*\ OP_COPY \*/
{{{{{ __imlib_CopyRGBAToRGB, __imlib_BlendRGBAToRGB },
{ __imlib_CopyRGBToRGB, __imlib_BlendRGBToRGB } },
{{ __imlib_CopyRGBAToRGBA, __imlib_BlendRGBAToRGBA },
{ __imlib_CopyRGBToRGBA, __imlib_BlendRGBToRGBA } } },
{{{ __imlib_CopyRGBAToRGBCmod, __imlib_BlendRGBAToRGBCmod },
{ __imlib_CopyRGBToRGBCmod, __imlib_BlendRGBToRGBCmod } },
{{ __imlib_CopyRGBAToRGBACmod, __imlib_BlendRGBAToRGBACmod },
{ __imlib_CopyRGBToRGBACmod, __imlib_BlendRGBToRGBACmod } } } },
/*\ OP_ADD \*/
{{{{ __imlib_AddCopyRGBAToRGB, __imlib_AddBlendRGBAToRGB },
{ __imlib_AddCopyRGBToRGB, __imlib_AddBlendRGBToRGB } },
{{ __imlib_AddCopyRGBAToRGBA, __imlib_AddBlendRGBAToRGBA },
{ __imlib_AddCopyRGBToRGBA, __imlib_AddBlendRGBToRGBA } } },
{{{ __imlib_AddCopyRGBAToRGBCmod, __imlib_AddBlendRGBAToRGBCmod },
{ __imlib_AddCopyRGBToRGBCmod, __imlib_AddBlendRGBToRGBCmod } },
{{ __imlib_AddCopyRGBAToRGBACmod, __imlib_AddBlendRGBAToRGBACmod },
{ __imlib_AddCopyRGBToRGBACmod, __imlib_AddBlendRGBToRGBACmod } } } },
/*\ OP_SUBTRACT \*/
{{{{ __imlib_SubCopyRGBAToRGB, __imlib_SubBlendRGBAToRGB },
{ __imlib_SubCopyRGBToRGB, __imlib_SubBlendRGBToRGB } },
{{ __imlib_SubCopyRGBAToRGBA, __imlib_SubBlendRGBAToRGBA },
{ __imlib_SubCopyRGBToRGBA, __imlib_SubBlendRGBToRGBA } } },
{{{ __imlib_SubCopyRGBAToRGBCmod, __imlib_SubBlendRGBAToRGBCmod },
{ __imlib_SubCopyRGBToRGBCmod, __imlib_SubBlendRGBToRGBCmod } },
{{ __imlib_SubCopyRGBAToRGBACmod, __imlib_SubBlendRGBAToRGBACmod },
{ __imlib_SubCopyRGBToRGBACmod, __imlib_SubBlendRGBToRGBACmod } } } },
/*\ OP_RESHADE \*/
{{{{ __imlib_ReCopyRGBAToRGB, __imlib_ReBlendRGBAToRGB },
{ __imlib_ReCopyRGBToRGB, __imlib_ReBlendRGBToRGB } },
{{ __imlib_ReCopyRGBAToRGBA, __imlib_ReBlendRGBAToRGBA },
{ __imlib_ReCopyRGBToRGBA, __imlib_ReBlendRGBToRGBA } } },
{{{ __imlib_ReCopyRGBAToRGBCmod, __imlib_ReBlendRGBAToRGBCmod },
{ __imlib_ReCopyRGBToRGBCmod, __imlib_ReBlendRGBToRGBCmod } },
{{ __imlib_ReCopyRGBAToRGBACmod, __imlib_ReBlendRGBAToRGBACmod },
{ __imlib_ReCopyRGBToRGBACmod, __imlib_ReBlendRGBToRGBACmod } } } } },
if (cm)
{
switch(op)
{
case OP_COPY:
if (merge_alpha)
{
if (rgb_src)
{
if (blend)
blender = __imlib_BlendRGBToRGBACmod;
else
blender = __imlib_CopyRGBAToRGBACmod;
}
else
{
if (blend)
blender = __imlib_BlendRGBAToRGBACmod;
else
blender = __imlib_CopyRGBAToRGBACmod;
}
}
else
{
if (blend)
blender = __imlib_BlendRGBAToRGBCmod;
else
blender = __imlib_CopyRGBAToRGBCmod;
}
break;
case OP_ADD:
if (merge_alpha)
{
if (blend)
blender = __imlib_AddBlendRGBAToRGBACmod;
else
blender = __imlib_AddCopyRGBAToRGBACmod;
}
else
{
if (blend)
blender = __imlib_AddBlendRGBAToRGBCmod;
else
blender = __imlib_AddCopyRGBAToRGBCmod;
}
break;
case OP_SUBTRACT:
if (merge_alpha)
{
if (blend)
blender = __imlib_SubBlendRGBAToRGBACmod;
else
blender = __imlib_SubCopyRGBAToRGBACmod;
}
else
{
if (blend)
blender = __imlib_SubBlendRGBAToRGBCmod;
else
blender = __imlib_SubCopyRGBAToRGBCmod;
}
break;
case OP_RESHADE:
if (merge_alpha)
{
if (blend)
blender = __imlib_ReBlendRGBAToRGBACmod;
else
blender = __imlib_ReCopyRGBAToRGBACmod;
}
else
{
if (blend)
blender = __imlib_ReBlendRGBAToRGBCmod;
else
blender = __imlib_ReCopyRGBAToRGBCmod;
}
break;
default:
break;
}
}
else
{
#ifdef DO_MMX_ASM #ifdef DO_MMX_ASM
if (__imlib_get_cpuid() & CPUID_MMX) /*\ OP_COPY \*/
{ {{{{{ __imlib_mmx_copy_rgba_to_rgb, __imlib_mmx_blend_rgba_to_rgb },
switch(op) { __imlib_mmx_copy_rgb_to_rgb, __imlib_mmx_blend_rgb_to_rgb } },
{ {{ __imlib_mmx_copy_rgba_to_rgba, __imlib_mmx_blend_rgba_to_rgba },
case OP_COPY: { __imlib_mmx_copy_rgb_to_rgba, __imlib_mmx_blend_rgb_to_rgba } } },
if (merge_alpha)
{
if (rgb_src)
{
blender = __imlib_mmx_copy_rgb_to_rgba;
}
else
{
if (blend)
blender = __imlib_mmx_blend_rgba_to_rgba;
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
#endif
{
switch(op)
{
case OP_COPY:
if (merge_alpha)
{
if (rgb_src)
{
if (blend)
{
blender = __imlib_BlendRGBToRGBA;
}
else
blender = __imlib_CopyRGBAToRGBA;
}
else
{
if (blend)
blender = __imlib_BlendRGBAToRGBA;
else
blender = __imlib_CopyRGBAToRGBA;
}
}
else
{
if (blend)
blender = __imlib_BlendRGBAToRGB;
else
blender = __imlib_CopyRGBAToRGB;
}
break;
case OP_ADD:
if (merge_alpha)
{
if (blend)
blender = __imlib_AddBlendRGBAToRGBA;
else
blender = __imlib_AddCopyRGBAToRGBA;
}
else
{
if (blend)
blender = __imlib_AddBlendRGBAToRGB;
else
blender = __imlib_AddCopyRGBAToRGB;
}
break;
case OP_SUBTRACT:
if (merge_alpha)
{
if (blend)
blender = __imlib_SubBlendRGBAToRGBA;
else
blender = __imlib_SubCopyRGBAToRGBA;
}
else
{
if (blend)
blender = __imlib_SubBlendRGBAToRGB;
else
blender = __imlib_SubCopyRGBAToRGB;
}
break;
case OP_RESHADE:
if (merge_alpha)
{
if (blend)
blender = __imlib_ReBlendRGBAToRGBA;
else
blender = __imlib_ReCopyRGBAToRGBA;
}
else
{
if (blend)
blender = __imlib_ReBlendRGBAToRGB;
else
blender = __imlib_ReCopyRGBAToRGB;
}
break;
default:
break;
}
}
}
return blender; {{{ __imlib_mmx_copy_rgba_to_rgb_cmod, __imlib_mmx_blend_rgba_to_rgb_cmod },
{ __imlib_mmx_copy_rgb_to_rgb_cmod, __imlib_mmx_blend_rgb_to_rgb_cmod } },
{{ __imlib_mmx_copy_rgba_to_rgba_cmod, __imlib_mmx_blend_rgba_to_rgba_cmod },
{ __imlib_mmx_copy_rgb_to_rgba_cmod, __imlib_mmx_blend_rgb_to_rgba_cmod } } } },
/*\ OP_ADD \*/
{{{{ __imlib_mmx_add_copy_rgba_to_rgb, __imlib_mmx_add_blend_rgba_to_rgb },
{ __imlib_mmx_add_copy_rgb_to_rgb, __imlib_mmx_add_blend_rgb_to_rgb } },
{{ __imlib_mmx_add_copy_rgba_to_rgba, __imlib_mmx_add_blend_rgba_to_rgba },
{ __imlib_mmx_add_copy_rgb_to_rgba, __imlib_mmx_add_blend_rgb_to_rgba } } },
{{{ __imlib_mmx_add_copy_rgba_to_rgb_cmod, __imlib_mmx_add_blend_rgba_to_rgb_cmod },
{ __imlib_mmx_add_copy_rgb_to_rgb_cmod, __imlib_mmx_add_blend_rgb_to_rgb_cmod } },
{{ __imlib_mmx_add_copy_rgba_to_rgba_cmod, __imlib_mmx_add_blend_rgba_to_rgba_cmod },
{ __imlib_mmx_add_copy_rgb_to_rgba_cmod, __imlib_mmx_add_blend_rgb_to_rgba_cmod } } } },
/*\ OP_SUBTRACT \*/
{{{{ __imlib_mmx_subtract_copy_rgba_to_rgb, __imlib_mmx_subtract_blend_rgba_to_rgb },
{ __imlib_mmx_subtract_copy_rgb_to_rgb, __imlib_mmx_subtract_blend_rgb_to_rgb } },
{{ __imlib_mmx_subtract_copy_rgba_to_rgba, __imlib_mmx_subtract_blend_rgba_to_rgba },
{ __imlib_mmx_subtract_copy_rgb_to_rgba, __imlib_mmx_subtract_blend_rgb_to_rgba } } },
{{{ __imlib_mmx_subtract_copy_rgba_to_rgb_cmod, __imlib_mmx_subtract_blend_rgba_to_rgb_cmod },
{ __imlib_mmx_subtract_copy_rgb_to_rgb_cmod, __imlib_mmx_subtract_blend_rgb_to_rgb_cmod } },
{{ __imlib_mmx_subtract_copy_rgba_to_rgba_cmod, __imlib_mmx_subtract_blend_rgba_to_rgba_cmod },
{ __imlib_mmx_subtract_copy_rgb_to_rgba_cmod, __imlib_mmx_subtract_blend_rgb_to_rgba_cmod } } } },
/*\ OP_RESHADE \*/
{{{{ __imlib_mmx_reshade_copy_rgba_to_rgb, __imlib_mmx_reshade_blend_rgba_to_rgb },
{ __imlib_mmx_reshade_copy_rgb_to_rgb, __imlib_mmx_reshade_blend_rgb_to_rgb } },
{{ __imlib_mmx_reshade_copy_rgba_to_rgba, __imlib_mmx_reshade_blend_rgba_to_rgba },
{ __imlib_mmx_reshade_copy_rgb_to_rgba, __imlib_mmx_reshade_blend_rgb_to_rgba } } },
{{{ __imlib_mmx_reshade_copy_rgba_to_rgb_cmod, __imlib_mmx_reshade_blend_rgba_to_rgb_cmod },
{ __imlib_mmx_reshade_copy_rgb_to_rgb_cmod, __imlib_mmx_reshade_blend_rgb_to_rgb_cmod } },
{{ __imlib_mmx_reshade_copy_rgba_to_rgba_cmod, __imlib_mmx_reshade_blend_rgba_to_rgba_cmod },
{ __imlib_mmx_reshade_copy_rgb_to_rgba_cmod, __imlib_mmx_reshade_blend_rgb_to_rgba_cmod } } } } },
#endif
};
int opi = (op == OP_COPY) ? 0
: (op == OP_ADD) ? 1
: (op == OP_SUBTRACT) ? 2
: (op == OP_RESHADE) ? 3 : -1;
int do_mmx = 0;
if (opi == -1) return NULL;
#ifdef DO_MMX_ASM
do_mmx = !!(__imlib_get_cpuid() & CPUID_MMX);
#endif
if (cm && rgb_src && (A_CMOD(cm, 0xff) == 0xff))
blend = 0;
return ibfuncs[!!do_mmx][opi][!!cm][!!merge_alpha][!!rgb_src][!!blend];
} }
void void
@ -948,8 +1008,6 @@ __imlib_BlendImageToImage(ImlibImage *im_src, ImlibImage *im_dst,
rgb_src = 1; rgb_src = 1;
if (merge_alpha) if (merge_alpha)
blend = 1; blend = 1;
else
blend = 0;
} }
__imlib_BlendRGBAToData(im_src->data, im_src->w, im_src->h, __imlib_BlendRGBAToData(im_src->data, im_src->w, im_src->h,
@ -1047,8 +1105,6 @@ __imlib_BlendImageToImage(ImlibImage *im_src, ImlibImage *im_dst,
rgb_src = 1; rgb_src = 1;
if (merge_alpha) if (merge_alpha)
blend = 1; blend = 1;
else
blend = 0;
} }
__imlib_BlendRGBAToData(im_src->data, im_src->w, im_src->h, __imlib_BlendRGBAToData(im_src->data, im_src->w, im_src->h,
im_dst->data, im_dst->w, im_dst->h, im_dst->data, im_dst->w, im_dst->h,
@ -1074,8 +1130,6 @@ __imlib_BlendImageToImage(ImlibImage *im_src, ImlibImage *im_dst,
rgb_src = 1; rgb_src = 1;
if (merge_alpha) if (merge_alpha)
blend = 1; blend = 1;
else
blend = 0;
} }
/* scale in LINESIZE Y chunks and convert to depth*/ /* scale in LINESIZE Y chunks and convert to depth*/
#ifdef DO_MMX_ASM #ifdef DO_MMX_ASM

View File

@ -373,6 +373,9 @@ void
__imlib_mmx_add_copy_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst, __imlib_mmx_add_copy_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm); int dw, int w, int h, ImlibColorModifier *cm);
void void
__imlib_mmx_add_copy_rgb_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, __imlib_mmx_subtract_blend_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm); int dw, int w, int h, ImlibColorModifier *cm);
void void
@ -385,6 +388,9 @@ void
__imlib_mmx_subtract_copy_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst, __imlib_mmx_subtract_copy_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm); int dw, int w, int h, ImlibColorModifier *cm);
void void
__imlib_mmx_subtract_copy_rgb_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, __imlib_mmx_reshade_blend_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm); int dw, int w, int h, ImlibColorModifier *cm);
void void
@ -396,5 +402,94 @@ __imlib_mmx_reshade_copy_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
void void
__imlib_mmx_reshade_copy_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst, __imlib_mmx_reshade_copy_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm); int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_reshade_copy_rgb_to_rgba(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_blend_rgba_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_blend_rgba_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_blend_rgb_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_blend_rgb_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_copy_rgba_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_copy_rgba_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_copy_rgb_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_add_blend_rgba_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_add_blend_rgba_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_add_blend_rgb_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_add_blend_rgb_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_add_copy_rgba_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_add_copy_rgba_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_add_copy_rgb_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_subtract_blend_rgba_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_subtract_blend_rgba_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_subtract_blend_rgb_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_subtract_blend_rgb_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_subtract_copy_rgba_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_subtract_copy_rgba_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_subtract_copy_rgb_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_reshade_blend_rgba_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_reshade_blend_rgba_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_reshade_blend_rgb_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_reshade_blend_rgb_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_reshade_copy_rgba_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_reshade_copy_rgba_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
void
__imlib_mmx_reshade_copy_rgb_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
int dw, int w, int h, ImlibColorModifier *cm);
#endif #endif
#endif #endif

View File

@ -89,9 +89,9 @@ __imlib_DataCmodApply(DATA32 *data, int w, int h, int jump,
for (x = 0; x < w; x++) for (x = 0; x < w; x++)
{ {
R_VAL(p) = R_CMOD(cm, R_VAL(p)); R_VAL(p) = R_CMOD(cm, R_VAL(p));
G_VAL(p) = R_CMOD(cm, G_VAL(p)); G_VAL(p) = G_CMOD(cm, G_VAL(p));
B_VAL(p) = R_CMOD(cm, B_VAL(p)); B_VAL(p) = B_CMOD(cm, B_VAL(p));
A_VAL(p) = R_CMOD(cm, A_VAL(p)); A_VAL(p) = A_CMOD(cm, A_VAL(p));
p++; p++;
} }
p += jump; p += jump;

View File

@ -27,7 +27,7 @@ Colormap cm;
int depth; int depth;
void progress(Imlib_Image *im, char percent, int update_x, int update_y, void progress(Imlib_Image *im, char percent, int update_x, int update_y,
int update_w, int update_h); int update_w, int update_h);
void void
progress(Imlib_Image *im, char percent, progress(Imlib_Image *im, char percent,
@ -76,113 +76,136 @@ int main (int argc, char **argv)
int scaleup = 0; int scaleup = 0;
int scaleboth = 0; int scaleboth = 0;
int origone = 0; int origone = 0;
Imlib_Color_Modifier colormod = 0;
/** /**
* Parse all the command line arguments * Parse all the command line arguments
*/ */
if ((argc > 1) && (!strcmp(argv[1], "-help")) if ((argc > 1) && (!strcmp(argv[1], "-help")))
{ {
printf ("Imlib2 program test. (Imlib v2.0.0.4)\n"); printf ("Imlib2 program test. (Imlib v2.0.0.4)\n");
printf ("usage: imlib2 [options] [file]\n"); printf ("usage: imlib2 [options] [file]\n");
printf ("options are:\n"); printf ("options are:\n");
printf ("-help\t\tDisplays this help.\n"); printf ("-help\t\tDisplays this help.\n");
printf ("-root\t\tDraw in the root window.\n"); printf ("-root\t\tDraw in the root window.\n");
printf ("-smooth\t\tWhen scaling images scale with anti-aliasing.\n"); printf ("-smooth\t\tWhen scaling images scale with anti-aliasing.\n");
printf ("-up\t\tWhen doing scal test scale up, not down.\n"); printf ("-up\t\tWhen doing scal test scale up, not down.\n");
printf ("-both\t\tScale horizontally AND vertically in scale test.\n"); printf ("-both\t\tScale horizontally AND vertically in scale test.\n");
printf ("-orig\t\tKeep original width and height in each pass of scale test.\n"); printf ("-orig\t\tKeep original width and height in each pass of scale test.\n");
printf ("-blend\t\tBlending test.\n"); printf ("-blend\t\tBlending test.\n");
printf ("-dither\t\tTurn dithering on for depths < 24bpp\n"); printf ("-dither\t\tTurn dithering on for depths < 24bpp\n");
printf ("-scale\t\tScale test.\n"); printf ("-colormod <r> <g> <b> <a>\t\tSet up color mod tables\n");
printf ("-noloop\t\tDont loop - timing test.\n"); printf ("-scale\t\tScale test.\n");
printf ("-rotate\t\tAlso rotate background image with mouse in interative test.\n"); printf ("-noloop\t\tDont loop - timing test.\n");
printf ("-size <w> <h>\t\tScale from w x h down in scaling test.\n"); // require parameters w / h printf ("-rotate\t\tAlso rotate background image with mouse in interative test.\n");
printf ("-maxcolors <n>\t\tLimit color allocation count to n colors.\n"); // require parameter nb colors printf ("-size <w> <h>\t\tScale from w x h down in scaling test.\n"); // require parameters w / h
printf ("-text\t\tDisplays the text following this option. Need a loaded font.\n"); printf ("-maxcolors <n>\t\tLimit color allocation count to n colors.\n"); // require parameter nb colors
printf ("-font\t\tLoads a font. The parameter must follow the police_name/size format. Example: loading the grunge font at size 18 is : grunge/18."); printf ("-text\t\tDisplays the text following this option. Need a loaded font.\n");
printf ("The following options requires a file to work properly.\n"); printf ("-font\t\tLoads a font. The parameter must follow the police_name/size format. Example: loading the grunge font at size 18 is : grunge/18.");
printf ("-blast\t\tDisplays the file.\n"); printf ("The following options requires a file to work properly.\n");
printf ("-loop\t\tScales down the image.\n"); printf ("-blast\t\tDisplays the file.\n");
printf ("-blendtest\tPerforms a blending test on the file.\n"); printf ("-loop\t\tScales down the image.\n");
printf ("-rotatetest\tPerforms a rotate test on the file.\n"); printf ("-blendtest\tPerforms a blending test on the file.\n");
printf ("-filter\t\tPerforms filtering. Possible filters are,\n\t\t\t1:Blur filter, 2:Sharpen filter, 3:Color blur filter, \n\t\t\t4:Emboss filter, 5:Grayscale filter, 6:Saturation filter,\n\t\t\t7:Edge detection filter.\n"); printf ("-rotatetest\tPerforms a rotate test on the file.\n");
return 0; printf ("-filter\t\tPerforms filtering. Possible filters are,\n\t\t\t1:Blur filter, 2:Sharpen filter, 3:Color blur filter, \n\t\t\t4:Emboss filter, 5:Grayscale filter, 6:Saturation filter,\n\t\t\t7:Edge detection filter.\n");
return 0;
} }
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
{ {
if (!strcmp(argv[i], "-root")) if (!strcmp(argv[i], "-root"))
root = 1; root = 1;
else if (!strcmp(argv[i], "-smooth")) else if (!strcmp(argv[i], "-smooth"))
aa = 1; aa = 1;
else if (!strcmp(argv[i], "-blast")) else if (!strcmp(argv[i], "-blast"))
interactive = 0;
else if (!strcmp(argv[i], "-loop"))
{
interactive = 0; interactive = 0;
loop = 1; else if (!strcmp(argv[i], "-loop"))
} {
else if (!strcmp(argv[i], "-up")) interactive = 0;
scaleup = 1; loop = 1;
else if (!strcmp(argv[i], "-both")) }
scaleboth = 1; else if (!strcmp(argv[i], "-up"))
else if (!strcmp(argv[i], "-orig")) scaleup = 1;
else if (!strcmp(argv[i], "-both"))
scaleboth = 1;
else if (!strcmp(argv[i], "-orig"))
origone = 1; origone = 1;
else if (!strcmp(argv[i], "-blend")) else if (!strcmp(argv[i], "-blend"))
blend = 1; blend = 1;
else if (!strcmp(argv[i], "-blendtest")) else if (!strcmp(argv[i], "-blendtest"))
{ {
blendtest = 1; blendtest = 1;
interactive = 0; interactive = 0;
}
else if (!strcmp(argv[i], "-dither"))
dith = 1;
else if (!strcmp(argv[i], "-scale"))
scale = 1;
else if (!strcmp(argv[i], "-noloop"))
loop = 0;
else if (!strcmp(argv[i], "-size"))
{
i++;
w = atoi(argv[i++]);
h = atoi(argv[i]);
}
else if (!strcmp(argv[i], "-maxcolors"))
{
i++;
imlib_set_color_usage(atoi(argv[i]));
} }
else if (!strcmp(argv[i], "-font")) else if (!strcmp(argv[i], "-colormod"))
{ {
i++; DATA8 rt[256], gt[256], bt[256], at[256];
fon = argv[i]; double rm, gm, bm, am;
} int j;
else if (!strcmp(argv[i], "-text")) /*\ Setup color mod tables \*/
{ if (!colormod) colormod = imlib_create_color_modifier();
i++; imlib_context_set_color_modifier(colormod);
str = argv[i]; rm = strtod(argv[++i], 0);
} gm = strtod(argv[++i], 0);
else if (!strcmp(argv[i], "-rotate")) bm = strtod(argv[++i], 0);
rotate = 1; am = strtod(argv[++i], 0);
else if (!strcmp(argv[i], "-filter")) imlib_get_color_modifier_tables(rt, gt, bt, at);
{ for (j = 0x100; --j >= 0; ) {
filter = atoi(argv[++i]); rt[j] = ((double)rt[j]) * rm;
interactive = 0; gt[j] = ((double)gt[j]) * gm;
} bt[j] = ((double)bt[j]) * bm;
else if (!strcmp(argv[i], "-rotatetest")) at[j] = ((double)at[j]) * am;
{ }
rottest = 1; imlib_set_color_modifier_tables(rt, gt, bt, at);
interactive = 0; }
} else if (!strcmp(argv[i], "-dither"))
else dith = 1;
file = argv[i]; else if (!strcmp(argv[i], "-scale"))
scale = 1;
else if (!strcmp(argv[i], "-noloop"))
loop = 0;
else if (!strcmp(argv[i], "-size"))
{
i++;
w = atoi(argv[i++]);
h = atoi(argv[i]);
}
else if (!strcmp(argv[i], "-maxcolors"))
{
i++;
imlib_set_color_usage(atoi(argv[i]));
}
else if (!strcmp(argv[i], "-font"))
{
i++;
fon = argv[i];
}
else if (!strcmp(argv[i], "-text"))
{
i++;
str = argv[i];
}
else if (!strcmp(argv[i], "-rotate"))
rotate = 1;
else if (!strcmp(argv[i], "-filter"))
{
filter = atoi(argv[++i]);
interactive = 0;
}
else if (!strcmp(argv[i], "-rotatetest"))
{
rottest = 1;
interactive = 0;
}
else
file = argv[i];
} }
/** /**
* Initialization according to options * Initialization according to options
*/ */
printf("init\n"); printf("init\n");
/** /**
* First tests to determine which rendering task to perform * First tests to determine which rendering task to perform
*/ */
@ -204,7 +227,7 @@ int main (int argc, char **argv)
ButtonMotionMask | PointerMotionMask | ExposureMask); ButtonMotionMask | PointerMotionMask | ExposureMask);
} }
} }
if (!interactive) if (!interactive)
{ {
printf("load %s\n", file); printf("load %s\n", file);
@ -219,7 +242,7 @@ int main (int argc, char **argv)
h = imlib_image_get_height(); h = imlib_image_get_height();
printf("image %i x %i\n", w, h); printf("image %i x %i\n", w, h);
} }
if (!blendtest) if (!blendtest)
{ {
if (!root) if (!root)
@ -241,13 +264,13 @@ int main (int argc, char **argv)
} }
XSync(disp, False); XSync(disp, False);
} }
/** /**
* Start rendering * Start rendering
*/ */
printf("rend\n"); printf("rend\n");
if (!blendtest) if (!blendtest)
{ {
imlib_context_set_display(disp); imlib_context_set_display(disp);
@ -269,7 +292,7 @@ int main (int argc, char **argv)
if (loop) if (loop)
{ {
printf("loop\n"); printf("loop\n");
// first test // first test
if (scaleup) if (scaleup)
{ {
@ -305,7 +328,7 @@ int main (int argc, char **argv)
pixels += (w + i) * (((w + i) * h) / w); pixels += (w + i) * (((w + i) * h) / w);
} }
} }
// else if // second // else if // second
else if (scaleboth) else if (scaleboth)
{ {
@ -318,7 +341,7 @@ int main (int argc, char **argv)
Imlib_Image im_tmp; Imlib_Image im_tmp;
im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h, im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h,
w, (((i) * h) / w)); w, (((i) * h) / w));
if (im_tmp) if (im_tmp)
{ {
imlib_context_set_image(im_tmp); imlib_context_set_image(im_tmp);
@ -387,7 +410,7 @@ int main (int argc, char **argv)
} }
else else
{ {
printf("scale down 0 -> %i incriment by 1\n", w); printf("scale down 0 -> %i incriment by 1\n", w);
for (i = 0; i < w; i++) for (i = 0; i < w; i++)
{ {
if (!blendtest) if (!blendtest)
@ -409,40 +432,41 @@ int main (int argc, char **argv)
} }
} }
} }
// last test // last test
/* else if (scaleboth) /* else if (scaleboth)
{
for (i = 0; i < w * 2; i+= 1)
{ {
for (i = 0; i < w * 2; i+= 1) if (!blendtest)
imlib_render_image_on_drawable_at_size(0, 0,
2 * w - i, (((i) * h) / w));
else
{ {
if (!blendtest) Imlib_Image im_tmp;
imlib_render_image_on_drawable_at_size(0, 0, im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h,
2 * w - i, (((i) * h) / w)); 2 * w - i, (((i) * h) / w));
else if (im_tmp)
{ {
Imlib_Image im_tmp; imlib_context_set_image(im_tmp);
im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h, imlib_free_image();
2 * w - i, (((i) * h) / w));
if (im_tmp)
{
imlib_context_set_image(im_tmp);
imlib_free_image();
}
imlib_context_set_image(im);
} }
pixels += (2 * w - i) * (((i) * h) / w); imlib_context_set_image(im);
} }
pixels += (2 * w - i) * (((i) * h) / w);
} }
} */// end if loop }
} */// end if loop
else if (blendtest) else if (blendtest)
{ {
Imlib_Image im2; Imlib_Image im2;
im2 = imlib_create_image(w, h); im2 = imlib_create_image(w, h);
imlib_context_set_image(im2); imlib_context_set_image(im2);
w = imlib_image_get_width(); w = imlib_image_get_width();
h = imlib_image_get_height(); h = imlib_image_get_height();
imlib_context_set_image(im2); imlib_context_set_image(im2);
imlib_context_set_color_modifier(colormod);
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {
imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h); imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h);
@ -451,7 +475,8 @@ int main (int argc, char **argv)
} }
else if (rottest) else if (rottest)
{ {
int w, h, i; int w, h;
double i;
imlib_context_set_image(im); imlib_context_set_image(im);
imlib_render_image_on_drawable(0, 0); imlib_render_image_on_drawable(0, 0);
@ -462,31 +487,49 @@ int main (int argc, char **argv)
imlib_context_set_blend(1); imlib_context_set_blend(1);
imlib_context_set_image(imlib_create_image(w, h)); imlib_context_set_image(imlib_create_image(w, h));
for (i = h; (i -= 10) >= 0; ) { for (i = 0; i < 1; i += 0.01) {
imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h); imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h);
imlib_context_set_color_modifier(colormod);
imlib_blend_image_onto_image_at_angle(im, 0, 0, 0, w, h, imlib_blend_image_onto_image_at_angle(im, 0, 0, 0, w, h,
0, h - i, w, i); 0, h * i,
w * (1 - i), -(h * i));
imlib_context_set_color_modifier(NULL);
imlib_render_image_on_drawable(0, 0); imlib_render_image_on_drawable(0, 0);
pixels += w * h; pixels += w * h;
} }
for (i = w; (i -= 10) >= 0; ) { for (i = 0; i < 1; i += 0.01) {
imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h); imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h);
imlib_context_set_color_modifier(colormod);
imlib_context_set_operation(IMLIB_OP_ADD);
imlib_blend_image_onto_image_at_angle(im, 0, 0, 0, w, h, imlib_blend_image_onto_image_at_angle(im, 0, 0, 0, w, h,
w - i, h, i, 0); w * i, h,
-(w * i), h * (i - 1));
imlib_context_set_operation(IMLIB_OP_COPY);
imlib_context_set_color_modifier(NULL);
imlib_render_image_on_drawable(0, 0); imlib_render_image_on_drawable(0, 0);
pixels += w * h; pixels += w * h;
} }
for (i = h; (i -= 10) >= 0; ) { for (i = 0; i < 1; i += 0.01) {
imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h); imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h);
imlib_context_set_color_modifier(colormod);
imlib_context_set_operation(IMLIB_OP_SUBTRACT);
imlib_blend_image_onto_image_at_angle(im, 0, 0, 0, w, h, imlib_blend_image_onto_image_at_angle(im, 0, 0, 0, w, h,
w, i, 0, h - i); w, h * (1 - i),
w * (i - 1), h * i);
imlib_context_set_operation(IMLIB_OP_COPY);
imlib_context_set_color_modifier(NULL);
imlib_render_image_on_drawable(0, 0); imlib_render_image_on_drawable(0, 0);
pixels += w * h; pixels += w * h;
} }
for (i = w; (i -= 10) >= 0; ) { for (i = 0; i < 1; i += 0.01) {
imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h); imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h);
imlib_context_set_color_modifier(colormod);
imlib_context_set_operation(IMLIB_OP_RESHADE);
imlib_blend_image_onto_image_at_angle(im, 0, 0, 0, w, h, imlib_blend_image_onto_image_at_angle(im, 0, 0, 0, w, h,
i, 0, w - i, h); w * (1 - i), 0,
w * i, h * (1 - i));
imlib_context_set_operation(IMLIB_OP_COPY);
imlib_context_set_color_modifier(NULL);
imlib_render_image_on_drawable(0, 0); imlib_render_image_on_drawable(0, 0);
pixels += w * h; pixels += w * h;
} }
@ -536,7 +579,7 @@ int main (int argc, char **argv)
imlib_filter_set_green( 0, 0, 0, 1, 1, 1); imlib_filter_set_green( 0, 0, 0, 1, 1, 1);
imlib_filter_set_blue (-1, -1, 0, -1, -1, -1); imlib_filter_set_blue (-1, -1, 0, -1, -1, -1);
imlib_filter_set_blue ( 0, 0, 0, 1, 1, 1); imlib_filter_set_blue ( 0, 0, 0, 1, 1, 1);
imlib_filter_constants(0, 768, 768, 768); imlib_filter_constants(0, 768, 768, 768);
imlib_filter_divisors (0, 6, 6, 6); imlib_filter_divisors (0, 6, 6, 6);
break; break;
@ -630,8 +673,8 @@ int main (int argc, char **argv)
{ {
case Expose: case Expose:
up = imlib_update_append_rect(up, up = imlib_update_append_rect(up,
ev.xexpose.x, ev.xexpose.y, ev.xexpose.x, ev.xexpose.y,
ev.xexpose.width, ev.xexpose.height); ev.xexpose.width, ev.xexpose.height);
break; break;
case ButtonRelease: case ButtonRelease:
exit(0); exit(0);
@ -662,7 +705,7 @@ int main (int argc, char **argv)
im_ic[10] = imlib_load_image("test_images/tnt.png"); im_ic[10] = imlib_load_image("test_images/tnt.png");
im_ic[11] = imlib_load_image("test_images/bulb.png"); im_ic[11] = imlib_load_image("test_images/bulb.png");
im_ic[12] = imlib_load_image("test_images/lock.png"); im_ic[12] = imlib_load_image("test_images/lock.png");
imlib_context_set_image(im); imlib_context_set_image(im);
if (first) if (first)
{ {
@ -731,7 +774,7 @@ int main (int argc, char **argv)
if (fon) if (fon)
{ {
int retw, reth, ty, nx, ny, cx, cy, cw, ch, cp; int retw, reth, ty, nx, ny, cx, cy, cw, ch, cp;
if (!str) if (!str)
str = "This is a test string"; str = "This is a test string";
ty = 50; ty = 50;
@ -739,7 +782,7 @@ int main (int argc, char **argv)
{ {
int al; int al;
double an = (double)i / 10.0; double an = (double)i / 10.0;
imlib_context_set_direction(IMLIB_TEXT_TO_ANGLE); imlib_context_set_direction(IMLIB_TEXT_TO_ANGLE);
imlib_context_set_angle(an); imlib_context_set_angle(an);
@ -821,19 +864,20 @@ int main (int argc, char **argv)
imlib_context_set_image(im_ic[1]);imlib_free_image(); imlib_context_set_image(im_ic[1]);imlib_free_image();
imlib_context_set_image(im_ic[2]);imlib_free_image(); imlib_context_set_image(im_ic[2]);imlib_free_image();
imlib_context_set_image(im_ic[3]);imlib_free_image(); imlib_context_set_image(im_ic[3]);imlib_free_image();
} }
} }
else else
{ {
pixels = 0; pixels = 0;
imlib_context_set_color_modifier(colormod);
for (i = 0; i < w; i++) for (i = 0; i < w; i++)
{ {
imlib_render_image_on_drawable_at_size(0, 0, w, h); imlib_render_image_on_drawable_at_size(0, 0, w, h);
pixels += w * h; pixels += w * h;
} }
} }
/** /**
* Determine horse power of your video card driver * Determine horse power of your video card driver
*/ */