diff options
Diffstat (limited to 'draw')
-rw-r--r-- | draw/arch_arm.c | 232 | ||||
-rw-r--r-- | draw/arch_port.c | 486 |
2 files changed, 0 insertions, 718 deletions
diff --git a/draw/arch_arm.c b/draw/arch_arm.c deleted file mode 100644 index 55016a8b..00000000 --- a/draw/arch_arm.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - * ARM specific render optims live here - */ - -#include "fitz.h" - -typedef unsigned char byte; - -/* always surround cpu specific code with HAVE_XXX */ -#ifdef ARCH_ARM - -/* from imagescalearm.s */ -extern void fz_srow4_arm(byte *src, byte *dst, int w, int denom); -extern void fz_scol4_arm(byte *src, byte *dst, int w, int denom); - -static void -path_w4i1o4_arm(byte * restrict rgba, byte * restrict src, byte cov, int len, byte * restrict dst) -{ - /* The ARM code here is a hand coded implementation of the optimized C version. */ - - if (len <= 0) - return; - - asm volatile( - "ldr %0, [%0] @ %0 = rgba \n" - "mov r11,#0 \n" - "mov r8, #0xFF00 \n" - "mov r14,%0,lsr #24 @ r14= alpha \n" - "orr %0, %0, #0xFF000000 @ %0 = rgba |= 0xFF000000 \n" - "orr r8, r8, r8, LSL #16 @ r8 = 0xFF00FF00 \n" - "adds r14,r14,r14,LSR #7 @ r14 = alpha += alpha>>7 \n" - "beq 9f @ if (alpha == 0) bale \n" - "and r6, %0, r8 @ r6 = ga<<8 \n" - "bic %0, %0, r8 @ %0 = rb \n" - "mov r6, r6, LSR #8 @ r6 = ga \n" - "cmp r14,#256 @ if (alpha == 256) \n" - "beq 4f @ no-alpha loop \n" - "B 2f @ enter the loop \n" - "1: @ Loop used for when coverage*alpha == 0 \n" - "subs %3, %3, #1 @ len-- \n" - "ble 9f \n" - "2: \n" - "ldrb r12,[%1] @ r12= *src \n" - "ldr r9, [%4], #4 @ r9 = drb = *dst32++ \n" - "strb r11,[%1], #1 @ r11= *src++ = 0 \n" - "add %2, r12, %2 @ %2 = cov += r12 \n" - "ands %2, %2, #255 @ %2 = cov &= 255 \n" - "beq 1b @ if coverage == 0 loop back \n" - "add r10,%2, %2, LSR #7 @ r10= ca = cov+(cov>>7) \n" - "mul r10,r14,r10 @ r10= ca *= alpha \n" - "and r7, r8, r9 @ r7 = dga = drb & MASK \n" - "mov r10,r10,LSR #8 @ r10= ca >>= 8 \n" - "and r9, r8, r9, LSL #8 @ r9 = drb = (drb<<8) & MASK \n" - "sub r12,r6, r7, LSR #8 @ r12= cga = ga - (dga>>8) \n" - "sub r5, %0, r9, LSR #8 @ r5 = crb = rb - (drb>>8) \n" - "mla r7, r12,r10,r7 @ r7 = dga += cga * ca \n" - "subs %3, %3, #1 @ len-- \n" - "mla r9, r5, r10,r9 @ r9 = drb += crb * ca \n" - "and r7, r8, r7 @ r7 = dga &= MASK \n" - "and r9, r8, r9 @ r9 = drb &= MASK \n" - "orr r9, r7, r9, LSR #8 @ r9 = drb = dga | (drb>>8) \n" - "str r9, [%4, #-4] @ dst32[-1] = r9 \n" - "bgt 2b \n" - "b 9f \n" - "@ --- Solid alpha loop --------------------------------------- \n" - "3: @ Loop used when coverage == 256 \n" - "orr r9, %0, r6, LSL #8 @ r9 = rgba \n" - "str r9, [%4, #-4] @ dst32[-1] = r9 \n" - "4: @ Loop used for when coverage*alpha == 0 \n" - "subs %3, %3, #1 @ len-- \n" - "ble 9f \n" - "5: \n" - "ldrb r12,[%1] @ r12= *src \n" - "ldr r9, [%4], #4 @ r9 = drb = *dst32++ \n" - "strb r11,[%1], #1 @ r11= *src++ = 0 \n" - "add %2, r12, %2 @ %2 = cov += r12 \n" - "ands %2, %2, #255 @ %2 = cov &= 255 \n" - "beq 4b @ if coverage == 0 loop back \n" - "cmp %2, #255 @ if coverage == solid \n" - "beq 3b @ loop back \n" - "add r10,%2, %2, LSR #7 @ r10= ca = cov+(cov>>7) \n" - "and r7, r8, r9 @ r7 = dga = drb & MASK \n" - "and r9, r8, r9, LSL #8 @ r9 = dga = (drb<<8) & MASK \n" - "sub r12,r6, r7, LSR #8 @ r12= cga = ga - (dga>>8) \n" - "sub r5, %0, r9, LSR #8 @ r5 = crb = rb - (drb>>8) \n" - "mla r7, r12,r10,r7 @ r7 = dga += cga * ca \n" - "subs %3, %3, #1 @ len-- \n" - "mla r9, r5, r10,r9 @ r9 = drb += crb * ca \n" - "and r7, r8, r7 @ r7 = dga &= MASK \n" - "and r9, r8, r9 @ r9 = drb &= MASK \n" - "orr r9, r7, r9, LSR #8 @ r9 = drb = dga | (drb>>8) \n" - "str r9, [%4, #-4] @ dst32[-1] = r9 \n" - "bgt 5b \n" - "9: @ End \n" - : - "+r" (rgba), - "+r" (src), - "+r" (cov), - "+r" (len), - "+r" (dst) - : - : - "r5","r6","r7","r8","r9","r10","r11","r12","r14","memory","cc" - ); -} - -static void load_tile8_arm(byte * restrict src, int sw, byte * restrict dst, int dw, int w, int h, int pad) -{ - if ((h == 0) || (w == 0)) - return; - - switch (pad) - { - case 0: - while (h--) - { - memcpy(dst, src, w); - src += sw; - dst += dw; - } - break; - - case 1: - sw -= w; - dw -= w<<1; - asm volatile( - "MOV r11,#255 \n" - "1: \n" - "MOV r5, %[w] @ r5 = x = w \n" - "2: \n" - "LDRB r4, [%[src]], #1 @ r4 = *src++ \n" - "SUBS r5, r5, #1 \n" - "STRB r4, [%[dst]], #1 @ *dst++ = r4 \n" - "STRB r11,[%[dst]], #1 @ *dst++ = 255 \n" - "BGT 2b \n" - "ADD %[src],%[src],%[sw] @ src += sw \n" - "ADD %[dst],%[dst],%[dw] @ dst += dw \n" - "SUBS %[h],%[h],#1 \n" - "BGT 1b \n" - : - [src] "+r" (src), - [sw] "+r" (sw), - [dst] "+r" (dst), - [dw] "+r" (dw), - [h] "+r" (h), - [w] "+r" (w) - : - : - "r4","r5","r11","memory","cc" - ); - break; - - case 3: - sw -= w; - asm volatile( - "MOV r11,#255 \n" - "1: \n" - "MOV r5, %[w] @ r5 = x = w \n" - "MOV r8, %[dst] @ r8 = dp = dst \n" - "2: \n" - "LDRB r4, [%[src]], #1 @ r4 = *src++ \n" - "LDRB r6, [%[src]], #1 @ r6 = *src++ \n" - "LDRB r7, [%[src]], #1 @ r7 = *src++ \n" - "SUBS r5, r5, #3 \n" - "STRB r4, [r8], #1 @ *dp++ = r4 \n" - "STRB r6, [r8], #1 @ *dp++ = r6 \n" - "STRB r7, [r8], #1 @ *dp++ = r7 \n" - "STRB r11,[r8], #1 @ *dp++ = 255 \n" - "BGT 2b \n" - "ADD %[src],%[src],%[sw] @ src += sw \n" - "ADD %[dst],%[dst],%[dw] @ dst += dw \n" - "SUBS %[h],%[h],#1 \n" - "BGT 1b \n" - : - [src] "+r" (src), - [sw] "+r" (sw), - [dst] "+r" (dst), - [dw] "+r" (dw), - [h] "+r" (h), - [w] "+r" (w) - : - : - "r4","r5","r6","r7","r8","r11","memory","cc" - ); - break; - - default: - sw -= w; - asm volatile( - "mov r9,#255 \n" - "1: \n" - "mov r7, %[dst] @ r7 = dp = dst \n" - "mov r8, #1 @ r8 = tpad = 1 \n" - "mov r14,%[w] @ r11= x = w \n" - "2: \n" - "ldrb r10,[%[src]],#1 \n" - "subs r8, r8, #1 \n" - "moveq r8, %[pad] \n" - "streqb r9, [r7], #1 \n" - "strb r10,[r7], #1 \n" - "subs r14,r14, #1 \n" - "bgt 2b \n" - "add %[src],%[src],%[sw] \n" - "add %[dst],%[dst],%[dw] \n" - "subs %[h], %[h], #1 \n" - "bgt 1b \n" - : - [src] "+r" (src), - [sw] "+r" (sw), - [dst] "+r" (dst), - [dw] "+r" (dw), - [h] "+r" (h), - [w] "+r" (w), - [pad] "+r" (pad) - : - : - "r7","r8","r9","r10","r14","memory","cc" - ); - break; - } -} - -void -fz_accelerate_arch(void) -{ - fz_path_w4i1o4 = path_w4i1o4_arm; - fz_loadtile8 = load_tile8_arm; - fz_srow4 = fz_srow4_arm; - fz_scol4 = fz_scol4_arm; -} - -#endif diff --git a/draw/arch_port.c b/draw/arch_port.c deleted file mode 100644 index fa5890b5..00000000 --- a/draw/arch_port.c +++ /dev/null @@ -1,486 +0,0 @@ -#include "fitz.h" - -typedef unsigned char byte; - -/* These C implementations use SWAR (SIMD-within-a-register) techniques. */ - -#if 0 /* TODO: move into porterduff.c functions */ - -#define MASK 0xFF00FF00; - -static void -path_w4i1o4_32bit(byte *rgba, - byte * restrict src, byte cov, int len, byte * restrict dst) -{ - /* COLOR * coverage + DST * (256-coverage) = (COLOR - DST)*coverage + DST*256 */ - unsigned int *dst32 = (unsigned int *)(void *)dst; - int alpha = rgba[3]; - unsigned int rb = rgba[0] | (rgba[2] << 16); - unsigned int ga = rgba[1] | 0xFF0000; - - if (alpha == 0) - return; - - if (alpha != 255) - { - alpha += alpha>>7; /* alpha is now in the 0...256 range */ - while (len--) - { - unsigned int ca, drb, dga, crb, cga; - cov += *src; *src++ = 0; - ca = cov + (cov>>7); /* ca is in 0...256 range */ - ca = (ca*alpha)>>8; /* ca is is in 0...256 range */ - drb = *dst32++; - if (ca != 0) - { - dga = drb & MASK; - drb = (drb<<8) & MASK; - cga = ga - (dga>>8); - crb = rb - (drb>>8); - dga += cga * ca; - drb += crb * ca; - dga &= MASK; - drb &= MASK; - drb = dga | (drb>>8); - dst32[-1] = drb; - } - } - } - else - { - while (len--) - { - unsigned int ca, drb, dga, crb, cga; - cov += *src; *src++ = 0; - ca = cov + (cov>>7); /* ca is in 0...256 range */ - drb = *dst32++; - if (ca == 0) - continue; - if (ca == 255) - { - drb = (ga<<8) | rb; - } - else - { - dga = drb & MASK; - drb = (drb<<8) & MASK; - cga = ga - (dga>>8); - crb = rb - (drb>>8); - dga += cga * ca; - drb += crb * ca; - dga &= MASK; - drb &= MASK; - drb = dga |(drb>>8); - } - dst32[-1] = drb; - } - } -} - -static void -text_w4i1o4_32bit(byte *rgba, - byte * restrict src, int srcw, - byte * restrict dst, int dstw, int w0, int h) -{ - unsigned int *dst32 = (unsigned int *)(void *)dst; - unsigned int alpha = rgba[3]; - unsigned int rb = rgba[0] | (rgba[2] << 16); - unsigned int ga = rgba[1] | 0xFF0000; - - if (alpha == 0) - return; - - srcw -= w0; - dstw = (dstw>>2)-w0; - - if (alpha != 255) - { - alpha += alpha>>7; /* alpha is now in the 0...256 range */ - while (h--) - { - int w = w0; - while (w--) - { - unsigned int ca, drb, dga, crb, cga; - ca = *src++; - drb = *dst32++; - ca += ca>>7; - ca = (ca*alpha)>>8; - if (ca == 0) - continue; - dga = drb & MASK; - drb = (drb<<8) & MASK; - cga = ga - (dga>>8); - crb = rb - (drb>>8); - dga += cga * ca; - drb += crb * ca; - dga &= MASK; - drb &= MASK; - drb = dga | (drb>>8); - dst32[-1] = drb; - } - src += srcw; - dst32 += dstw; - } - } - else - { - while (h--) - { - int w = w0; - while (w--) - { - unsigned int ca, drb, dga, crb, cga; - ca = *src++; - drb = *dst32++; - ca += ca>>7; - if (ca == 0) - continue; - dga = drb & MASK; - drb = (drb<<8) & MASK; - cga = ga - (dga>>8); - crb = rb - (drb>>8); - dga += cga * ca; - drb += crb * ca; - dga &= MASK; - drb &= MASK; - drb = dga | (drb>>8); - dst32[-1] = drb; - } - src += srcw; - dst32 += dstw; - } - } -} - -static void -img_4o4_32bit(byte * restrict src, byte cov, int len, byte * restrict dst, - fz_pixmap *image, int u, int v, int fa, int fb) -{ - unsigned int *dst32 = (unsigned int *)(void *)dst; - unsigned int *samples = (unsigned int *)(void *)image->samples; - int w = image->w; - int h = image->h-1; - - while (len--) - { - unsigned int a, a1, d, d1; - int sa; - cov += *src; *src = 0; src++; - /* (a,a1) = sampleargb(samples, w, h, u, v, argb); */ - { - int ui, ui1, vi, vi1, ud, vd; - unsigned int b, b1, c, c1; - ui1 = 1; - ui = u >> 16; - if (ui < 0) - { - ui = 0; - ui1 = 0; - } - else if (ui >= w-1) - { - ui = w-1; - ui1 = 0; - } - vi1 = w; - vi = v >> 16; - if (vi < 0) - { - vi = 0; - vi1 = 0; - } - else if (vi >= h) - { - vi = h; - vi1 = 0; - } - ui += vi*w; - a = samples[ui]; - b = samples[ui + ui1]; - c = samples[ui + vi1]; - d = samples[ui + ui1 + vi1]; - ud = (u>>8) & 0xFF; - vd = (v>>8) & 0xFF; - ud = FZ_EXPAND(ud); - vd = FZ_EXPAND(vd); - /* (a,a1) = blend(a,b,ud) */ - a1 = a & MASK; - a = (a<<8) & MASK; - b1 = (b>>8) & ~MASK; - b = b & ~MASK; - a = ((b -(a >>8)) * ud + a ) & MASK; - a1 = ((b1-(a1>>8)) * ud + a1) & MASK; - /* (c,c1) = blend(c,d,ud) */ - c1 = c & MASK; - c = (c<<8) & MASK; - d1 = (d>>8) & ~MASK; - d = d & ~MASK; - c = ((d -(c >>8)) * ud + c ) & MASK; - c1 = ((d1-(c1>>8)) * ud + c1) & MASK; - /* (a,a1) = blend((a,a1),(c,c1),vd) */ - a = (((c >>8)-(a >>8)) * vd + a ) & MASK; - a1 = (((c1>>8)-(a1>>8)) * vd + a1) & MASK; - } - sa = (a1>>24); - sa = FZ_COMBINE(FZ_EXPAND(sa), FZ_EXPAND(cov)); - a1 |= 0xFF000000; - d = *dst32++; - d1 = d & MASK; - d = (d<<8) & MASK; - a = (((a >>8)-(d >>8)) * sa + d ) & MASK; - a1 = (((a1>>8)-(d1>>8)) * sa + d1) & MASK; - dst32[-1] = (a>>8) | a1; - u += fa; - v += fb; - } -} - -static void -img_w4i1o4_32bit(byte *rgba, byte * restrict src, byte cov, int len, - byte * restrict dst, fz_pixmap *image, int u, int v, int fa, int fb) -{ - byte *samples = image->samples; - int w = image->w; - int h = image->h-1; - int alpha = FZ_EXPAND(rgba[3]); - unsigned int rb = rgba[0] | (rgba[2] << 16); - unsigned int ga = rgba[1] | 0xFF0000; - unsigned int *dst32 = (unsigned int *)(void *)dst; - - if (alpha == 0) - return; - if (alpha != 256) - { - while (len--) - { - unsigned int ca, drb, dga, crb, cga; - unsigned int a, b; - cov += *src; *src = 0; src++; - drb = *dst32++; - ca = FZ_COMBINE(FZ_EXPAND(cov), alpha); - if (ca != 0) - { - int ui, ui1, vi, vi1, ud, vd; - /* a = samplemask(samples, w, h, u, v); */ - ui1 = 1; - ui = u >> 16; - if (ui < 0) - { - ui = 0; - ui1 = 0; - } - else if (ui >= w-1) - { - ui = w-1; - ui1 = 0; - } - vi1 = w; - vi = v >> 16; - if (vi < 0) - { - vi = 0; - vi1 = 0; - } - else if (vi >= h) - { - vi = h; - vi1 = 0; - } - ui += vi*w; - a = samples[ui]; - b = samples[ui + ui1]; - a |= samples[ui + vi1]<<16; - b |= samples[ui + ui1 + vi1]<<16; - ud = (u>>8) & 0xFF; - vd = (v>>8) & 0xFF; - ud = FZ_EXPAND(ud); - vd = FZ_EXPAND(vd); - /* a = blend(a,b,ud) */ - a = ((b-a) * ud + (a<<8)) & MASK; - /* a = blend(a,a>>16,vd) */ - a = (((a>>24)-(a>>8)) * vd + a); - a = (a>>8) & 0xFF; - ca = FZ_COMBINE(ca, FZ_EXPAND(a)); - } - if (ca != 0) - { - dga = drb & MASK; - drb = (drb<<8) & MASK; - cga = ga - (dga>>8); - crb = rb - (drb>>8); - dga += cga * ca; - drb += crb * ca; - dga &= MASK; - drb &= MASK; - drb = dga | (drb>>8); - dst32[-1] = drb; - } - u += fa; - v += fb; - } - } - else - { - while (len--) - { - unsigned int ca, drb, dga, crb, cga; - unsigned int a, b; - cov += *src; *src = 0; src++; - drb = *dst32++; - if (cov != 0) - { - int ui, ui1, vi, vi1, ud, vd; - /* a = samplemask(samples, w, h, u, v); */ - ui1 = 1; - ui = u >> 16; - if (ui < 0) - { - ui = 0; - ui1 = 0; - } - else if (ui >= w-1) - { - ui = w-1; - ui1 = 0; - } - vi1 = w; - vi = v >> 16; - if (vi < 0) - { - vi = 0; - vi1 = 0; - } - else if (vi >= h) - { - vi = h; - vi1 = 0; - } - ui += vi*w; - a = samples[ui]; - b = samples[ui + ui1]; - a |= samples[ui + vi1]<<16; - b |= samples[ui + ui1 + vi1]<<16; - ud = (u>>8) & 0xFF; - vd = (v>>8) & 0xFF; - ud = FZ_EXPAND(ud); - vd = FZ_EXPAND(vd); - /* a = blend(a,b,ud) */ - a = ((b-a) * ud + (a<<8)) & MASK; - /* a = blend(a,a>>16,vd) */ - a = (((a>>24)-(a>>8)) * vd + a); - a = (a>>8) & 0xFF; - ca = FZ_COMBINE(FZ_EXPAND(cov),FZ_EXPAND(a)); - if (ca != 0) - { - if (ca == 256) - { - drb = (ga<<8) | rb; - } - else - { - dga = drb & MASK; - drb = (drb<<8) & MASK; - cga = ga - (dga>>8); - crb = rb - (drb>>8); - dga += cga * ca; - drb += crb * ca; - dga &= MASK; - drb &= MASK; - drb = dga | (drb>>8); - } - dst32[-1] = drb; - } - } - u += fa; - v += fb; - } - } -} - -static void -img_1o1_32bit(byte * restrict src, byte cov, int len, byte * restrict dst, - fz_pixmap *image, int u, int v, int fa, int fb) -{ - byte *samples = image->samples; - int w = image->w; - int h = image->h-1; - - while (len--) - { - unsigned int a, b; - cov += *src; *src = 0; src++; - if (cov != 0) - { - int ui, ui1, vi, vi1, ud, vd; - /* sa = samplemask(samples, w, h, u, v); */ - ui1 = 1; - ui = u >> 16; - if (ui < 0) - { - ui = 0; - ui1 = 0; - } - else if (ui >= w-1) - { - ui = w-1; - ui1 = 0; - } - vi1 = w; - vi = v >> 16; - if (vi < 0) - { - vi = 0; - vi1 = 0; - } - else if (vi >= h) - { - vi = h; - vi1 = 0; - } - ui += vi*w; - a = samples[ui]; - b = samples[ui + ui1]; - a |= samples[ui + vi1]<<16; - b |= samples[ui + ui1 + vi1]<<16; - ud = (u>>8) & 0xFF; - vd = (v>>8) & 0xFF; - ud = FZ_EXPAND(ud); - vd = FZ_EXPAND(vd); - /* a = blend(a,b,ud) */ - a = ((b-a) * ud + (a<<8)) & MASK; - /* a = blend(a,a>>16,vd) */ - a = (((a>>24)-(a>>8)) * vd + a); - a = (a>>8) & 0xFF; - a = FZ_COMBINE(FZ_EXPAND(a), FZ_EXPAND(cov)); - if (a != 0) - { - if (a == 256) - dst[0] = 255; - else - dst[0] = FZ_BLEND(255, dst[0], a); - } - } - dst++; - u += fa; - v += fb; - } -} - -#endif - -void fz_accelerate(void) -{ - if (sizeof(int) == 4 && sizeof(unsigned int) == 4 && !fz_is_big_endian()) - { -// fz_path_w4i1o4 = path_w4i1o4_32bit; -// fz_text_w4i1o4 = text_w4i1o4_32bit; -// fz_img_4o4 = img_4o4_32bit; -// fz_img_w4i1o4 = img_w4i1o4_32bit; -// fz_img_1o1 = img_1o1_32bit; - } - -#ifdef HAVE_CPUDEP - fz_accelerate_arch(); -#endif -} |