summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--draw/imagescale.c307
-rw-r--r--draw/imagescalearm.s303
-rw-r--r--draw/imagesmooth.c2
-rw-r--r--fitz/dev_draw.c56
-rw-r--r--fitz/fitz.h15
6 files changed, 12 insertions, 672 deletions
diff --git a/Makefile b/Makefile
index da793520..b40e9af7 100644
--- a/Makefile
+++ b/Makefile
@@ -121,7 +121,6 @@ DRAW_SRC := $(DRAW_ARCH_SRC) \
draw/blendmodes.c \
draw/glyphcache.c \
draw/imagedraw.c \
- draw/imagescale.c \
draw/imagesmooth.c \
draw/imageunpack.c \
draw/meshdraw.c \
diff --git a/draw/imagescale.c b/draw/imagescale.c
deleted file mode 100644
index d40898b1..00000000
--- a/draw/imagescale.c
+++ /dev/null
@@ -1,307 +0,0 @@
-#include "fitz.h"
-
-typedef unsigned char byte;
-
-static inline void srown(byte * restrict src, byte * restrict dst, int w, int denom, int n)
-{
- int invdenom = (1<<16) / denom;
- int x, left, k;
- unsigned sum[FZ_MAXCOLORS];
-
- left = 0;
- for (k = 0; k < n; k++)
- sum[k] = 0;
-
- for (x = 0; x < w; x++)
- {
- for (k = 0; k < n; k++)
- sum[k] += src[x * n + k];
- if (++left == denom)
- {
- left = 0;
- for (k = 0; k < n; k++)
- {
- dst[k] = (sum[k] * invdenom + (1<<15)) >> 16;
- sum[k] = 0;
- }
- dst += n;
- }
- }
-
- /* left overs */
- if (left)
- for (k = 0; k < n; k++)
- dst[k] = sum[k] / left;
-}
-
-/* special-case common 1-5 components - the compiler optimizes this */
-static inline void srowc(byte * restrict src, byte * restrict dst, int w, int denom, int n)
-{
- int invdenom = (1<<16) / denom;
- int x, left;
- unsigned sum1 = 0;
- unsigned sum2 = 0;
- unsigned sum3 = 0;
- unsigned sum4 = 0;
- unsigned sum5 = 0;
-
- assert(n <= 5);
-
- left = denom;
-
- for (x = w; x > 0; x--)
- {
- sum1 += *src++;
- /* the compiler eliminates these if-tests */
- if (n >= 2)
- sum2 += *src++;
- if (n >= 3)
- sum3 += *src++;
- if (n >= 4)
- sum4 += *src++;
- if (n >= 5)
- sum5 += *src++;
-
- if (--left == 0)
- {
- left = denom;
-
- *dst++ = (sum1 * invdenom + (1<<15)) >> 16;
- sum1 = 0;
- if (n >= 2) {
- *dst++ = (sum2 * invdenom + (1<<15)) >> 16;
- sum2 = 0;
- }
- if (n >= 3) {
- *dst++ = (sum3 * invdenom + (1<<15)) >> 16;
- sum3 = 0;
- }
- if (n >= 4) {
- *dst++ = (sum4 * invdenom + (1<<15)) >> 16;
- sum4 = 0;
- }
- if (n >= 5) {
- *dst++ = (sum5 * invdenom + (1<<15)) >> 16;
- sum5 = 0;
- }
- }
- }
-
- /* left overs */
- left = denom - left;
- if (left) {
- *dst++ = sum1 / left;
- if (n >= 2)
- *dst++ = sum2 / left;
- if (n >= 3)
- *dst++ = sum3 / left;
- if (n >= 4)
- *dst++ = sum4 / left;
- if (n >= 5)
- *dst++ = sum5 / left;
- }
-}
-
-static void srow1(byte * restrict src, byte * restrict dst, int w, int denom)
-{
- srowc(src, dst, w, denom, 1);
-}
-
-static void srow2(byte * restrict src, byte * restrict dst, int w, int denom)
-{
- srowc(src, dst, w, denom, 2);
-}
-
-static void srow4(byte * restrict src, byte * restrict dst, int w, int denom)
-{
- srowc(src, dst, w, denom, 4);
-}
-
-static void srow5(byte * restrict src, byte * restrict dst, int w, int denom)
-{
- srowc(src, dst, w, denom, 5);
-}
-
-static inline void scoln(byte * restrict src, byte * restrict dst, int w, int denom, int n)
-{
- int invdenom = (1<<16) / denom;
- int x, y, k;
- byte *s;
- int sum[FZ_MAXCOLORS];
-
- for (x = 0; x < w; x++)
- {
- s = src + (x * n);
- for (k = 0; k < n; k++)
- sum[k] = 0;
- for (y = 0; y < denom; y++)
- for (k = 0; k < n; k++)
- sum[k] += s[y * w * n + k];
- for (k = 0; k < n; k++)
- dst[k] = (sum[k] * invdenom + (1<<15)) >> 16;
- dst += n;
- }
-}
-
-static inline void scolc(byte * restrict src, byte * restrict dst, int w, int denom, int n)
-{
- int invdenom = (1<<16) / denom;
- int x, y;
- int sum0;
- int sum1;
- int sum2;
- int sum3;
- int sum4;
-
- assert(n <= 5);
-
- x = w;
- w *= n;
- for (; x > 0; x--)
- {
- sum0 = 0;
- sum1 = 0;
- sum2 = 0;
- sum3 = 0;
- sum4 = 0;
- for (y = denom; y > 0; y--)
- {
- sum0 += src[0];
- if (n >= 2)
- sum1 += src[1];
- if (n >= 3)
- sum2 += src[2];
- if (n >= 4)
- sum3 += src[3];
- if (n >= 5)
- sum4 += src[4];
- src += w;
- }
- src += n - denom * w;
- *dst++ = (sum0 * invdenom + (1<<15)) >> 16;
- if (n >= 2)
- *dst++ = (sum1 * invdenom + (1<<15)) >> 16;
- if (n >= 3)
- *dst++ = (sum2 * invdenom + (1<<15)) >> 16;
- if (n >= 4)
- *dst++ = (sum3 * invdenom + (1<<15)) >> 16;
- if (n >= 5)
- *dst++ = (sum4 * invdenom + (1<<15)) >> 16;
- }
-}
-
-static void scol1(byte * restrict src, byte * restrict dst, int w, int denom)
-{
- scolc(src, dst, w, denom, 1);
-}
-
-static void scol2(byte * restrict src, byte * restrict dst, int w, int denom)
-{
- scolc(src, dst, w, denom, 2);
-}
-
-static void scol4(byte * restrict src, byte * restrict dst, int w, int denom)
-{
- scolc(src, dst, w, denom, 4);
-}
-
-static void scol5(byte * restrict src, byte * restrict dst, int w, int denom)
-{
- scolc(src, dst, w, denom, 5);
-}
-
-void (*fz_srown)(byte *restrict, byte *restrict, int w, int denom, int n) = srown;
-void (*fz_srow1)(byte *restrict, byte *restrict, int w, int denom) = srow1;
-void (*fz_srow2)(byte *restrict, byte *restrict, int w, int denom) = srow2;
-void (*fz_srow4)(byte *restrict, byte *restrict, int w, int denom) = srow4;
-void (*fz_srow5)(byte *restrict, byte *restrict, int w, int denom) = srow5;
-
-void (*fz_scoln)(byte *restrict, byte *restrict, int w, int denom, int n) = scoln;
-void (*fz_scol1)(byte *restrict, byte *restrict, int w, int denom) = scol1;
-void (*fz_scol2)(byte *restrict, byte *restrict, int w, int denom) = scol2;
-void (*fz_scol4)(byte *restrict, byte *restrict, int w, int denom) = scol4;
-void (*fz_scol5)(byte *restrict, byte *restrict, int w, int denom) = scol5;
-
-fz_pixmap *
-fz_scalepixmap(fz_pixmap *src, int xdenom, int ydenom)
-{
- fz_pixmap *dst;
- unsigned char *buf;
- int y, iy, oy;
- int ow, oh, n;
- int remaining;
-
- void (*srowx)(byte * restrict src, byte * restrict dst, int w, int denom) = nil;
- void (*scolx)(byte * restrict src, byte * restrict dst, int w, int denom) = nil;
-
- ow = (src->w + xdenom - 1) / xdenom;
- oh = (src->h + ydenom - 1) / ydenom;
- n = src->n;
-
- buf = fz_calloc(ydenom, ow * n);
-
- dst = fz_newpixmap(src->colorspace, 0, 0, ow, oh);
-
- switch (n)
- {
- case 1: srowx = fz_srow1; scolx = fz_scol1; break;
- case 2: srowx = fz_srow2; scolx = fz_scol2; break;
- case 4: srowx = fz_srow4; scolx = fz_scol4; break;
- case 5: srowx = fz_srow5; scolx = fz_scol5; break;
- }
-
- if (srowx && scolx)
- {
- for (y = 0, oy = 0; y < (src->h / ydenom) * ydenom; y += ydenom, oy++)
- {
- for (iy = 0; iy < ydenom; iy++)
- {
- srowx(src->samples + (y + iy) * src->w * n,
- buf + iy * ow * n,
- src->w, xdenom);
- }
- scolx(buf, dst->samples + oy * dst->w * n, dst->w, ydenom);
- }
-
- remaining = src->h - y;
- if (remaining)
- {
- for (iy = 0; iy < remaining; iy++)
- {
- srowx(src->samples + (y + iy) * src->w * n,
- buf + iy * ow * n,
- src->w, xdenom);
- }
- scolx(buf, dst->samples + oy * dst->w * n, dst->w, remaining);
- }
- }
-
- else
- {
- for (y = 0, oy = 0; y < (src->h / ydenom) * ydenom; y += ydenom, oy++)
- {
- for (iy = 0; iy < ydenom; iy++)
- {
- fz_srown(src->samples + (y + iy) * src->w * n,
- buf + iy * ow * n,
- src->w, xdenom, n);
- }
- fz_scoln(buf, dst->samples + oy * dst->w * n, dst->w, ydenom, n);
- }
-
- remaining = src->h - y;
- if (remaining)
- {
- for (iy = 0; iy < remaining; iy++)
- {
- fz_srown(src->samples + (y + iy) * src->w * n,
- buf + iy * ow * n,
- src->w, xdenom, n);
- }
- fz_scoln(buf, dst->samples + oy * dst->w * n, dst->w, remaining, n);
- }
- }
-
- fz_free(buf);
- return dst;
-}
diff --git a/draw/imagescalearm.s b/draw/imagescalearm.s
deleted file mode 100644
index 2b90582b..00000000
--- a/draw/imagescalearm.s
+++ /dev/null
@@ -1,303 +0,0 @@
-@ imagescalearm.s is a hand tuned assembler version
-@ of some of the imagescale functions targetted
-@ for ARM based systems (any architecture version).
-@
-@ Copyright (C) 2010 Robin Watts for Artifex Software LLC.
-@ <robin.watts@artifex.com> or <robin.watts@wss.co.uk>
-
- .file "imagescalearm.s"
- .global fz_srow4_arm
- .global fz_scol4_arm
-
- .type fz_srow4_arm, %function
- .text
-
- @ r0 = src
- @ r1 = dst
- @ r2 = w
- @ r3 = denom
-fz_srow4_arm:
- STMFD r13!,{r3-r7,r9-r10,r14}
-
- MOV r12,#1<<16 @ r12 = (1<<16)
- MOV r14,#0 @ r14 = will contain invdenom
-
- @ r14 = r12/r3
- CMP r12,r3, LSL #16
- SUBHS r12,r12,r3, LSL #16
- ADDHS r14,r14,#1<<16
- CMP r12,r3, LSL #15
- SUBHS r12,r12,r3, LSL #15
- ADDHS r14,r14,#1<<15
- CMP r12,r3, LSL #14
- SUBHS r12,r12,r3, LSL #14
- ADDHS r14,r14,#1<<14
- CMP r12,r3, LSL #13
- SUBHS r12,r12,r3, LSL #13
- ADDHS r14,r14,#1<<13
- CMP r12,r3, LSL #12
- SUBHS r12,r12,r3, LSL #12
- ADDHS r14,r14,#1<<12
- CMP r12,r3, LSL #11
- SUBHS r12,r12,r3, LSL #11
- ADDHS r14,r14,#1<<11
- CMP r12,r3, LSL #10
- SUBHS r12,r12,r3, LSL #10
- ADDHS r14,r14,#1<<10
- CMP r12,r3, LSL #9
- SUBHS r12,r12,r3, LSL #9
- ADDHS r14,r14,#1<<9
- CMP r12,r3, LSL #8
- SUBHS r12,r12,r3, LSL #8
- ADDHS r14,r14,#1<<8
- CMP r12,r3, LSL #7
- SUBHS r12,r12,r3, LSL #7
- ADDHS r14,r14,#1<<7
- CMP r12,r3, LSL #6
- SUBHS r12,r12,r3, LSL #6
- ADDHS r14,r14,#1<<6
- CMP r12,r3, LSL #5
- SUBHS r12,r12,r3, LSL #5
- ADDHS r14,r14,#1<<5
- CMP r12,r3, LSL #4
- SUBHS r12,r12,r3, LSL #4
- ADDHS r14,r14,#1<<4
- CMP r12,r3, LSL #3
- SUBHS r12,r12,r3, LSL #3
- ADDHS r14,r14,#1<<3
- CMP r12,r3, LSL #2
- SUBHS r12,r12,r3, LSL #2
- ADDHS r14,r14,#1<<2
- CMP r12,r3, LSL #1
- SUBHS r12,r12,r3, LSL #1
- ADDHS r14,r14,#1<<1
- CMP r12,r3
- SUBHS r12,r12,r3
- ADDHS r14,r14,#1
-
- @ r2 = x = w
- @ r3 = left = denom
- MOV r10,#1<<15 @ r10= 1<<15
- B .L_enter_loop_r4 @ Enter the loop
-.L_store_r4:
- ADD r7, r7, r12 @ r7 = sum3 += r12
- MLA r4, r14,r4, r10 @ r4 = sum0 * invdenom + (1<<15)
- MLA r5, r14,r5, r10 @ r5 = sum1 * invdenom + (1<<15)
- MLA r6, r14,r6, r10 @ r6 = sum2 * invdenom + (1<<15)
- MLA r7, r14,r7, r10 @ r7 = sum3 * invdenom + (1<<15)
- MOV r4, r4, LSR #16 @ r4 = r4 >> 16
- MOV r5, r5, LSR #16 @ r5 = r5 >> 16
- MOV r6, r6, LSR #16 @ r6 = r6 >> 16
- MOV r7, r7, LSR #16 @ r7 = r7 >> 16
- STRB r4, [r1], #1 @ *dst++ = r4
- STRB r5, [r1], #1 @ *dst++ = r5
- STRB r6, [r1], #1 @ *dst++ = r6
- STRB r7, [r1], #1 @ *dst++ = r7
- SUBS r2, r2, #1 @ x--
- BEQ .L_end_r4
- LDR r3, [r13] @ r3 = left = denom
-.L_enter_loop_r4:
- MOV r4, #0 @ r4 = sum0 = 0
- MOV r5, #0 @ r5 = sum1 = 0
- MOV r6, #0 @ r6 = sum2 = 0
- MOV r7, #0 @ r7 = sum3 = 0
-.L_x_loop_r4:
- LDRB r9, [r0], #1 @ r9 = src++
- LDRB r12,[r0], #1 @ r12= src++
- SUBS r3, r3, #1 @ r3 = --left
- ADD r4, r4, r9 @ r4 = sum0 += r9
- LDRB r9, [r0], #1 @ r9 = src++
- ADD r5, r5, r12 @ r5 = sum1 += r12
- LDRB r12,[r0], #1 @ r12= src++
- ADD r6, r6, r9 @ r9 = sum2 += r9
- BEQ .L_store_r4
- ADD r7, r7, r12 @ r7 = sum3 += r12
- SUBS r2, r2, #1 @ x--
- BNE .L_x_loop_r4
-
- @ Trailers
- LDR r0, [r13] @ r0 = denom
- MOV r12,#1<<16 @ r12 = (1<<16)
- MOV r14,#0 @ r14 = will contain invleft
- SUB r3, r0, r3 @ r3 = denom-left
- CMP r12,r3, LSL #16
- SUBHS r12,r12,r3, LSL #16
- ADDHS r14,r14,#1<<16
- CMP r12,r3, LSL #15
- SUBHS r12,r12,r3, LSL #15
- ADDHS r14,r14,#1<<15
- CMP r12,r3, LSL #14
- SUBHS r12,r12,r3, LSL #14
- ADDHS r14,r14,#1<<14
- CMP r12,r3, LSL #13
- SUBHS r12,r12,r3, LSL #13
- ADDHS r14,r14,#1<<13
- CMP r12,r3, LSL #12
- SUBHS r12,r12,r3, LSL #12
- ADDHS r14,r14,#1<<12
- CMP r12,r3, LSL #11
- SUBHS r12,r12,r3, LSL #11
- ADDHS r14,r14,#1<<11
- CMP r12,r3, LSL #10
- SUBHS r12,r12,r3, LSL #10
- ADDHS r14,r14,#1<<10
- CMP r12,r3, LSL #9
- SUBHS r12,r12,r3, LSL #9
- ADDHS r14,r14,#1<<9
- CMP r12,r3, LSL #8
- SUBHS r12,r12,r3, LSL #8
- ADDHS r14,r14,#1<<8
- CMP r12,r3, LSL #7
- SUBHS r12,r12,r3, LSL #7
- ADDHS r14,r14,#1<<7
- CMP r12,r3, LSL #6
- SUBHS r12,r12,r3, LSL #6
- ADDHS r14,r14,#1<<6
- CMP r12,r3, LSL #5
- SUBHS r12,r12,r3, LSL #5
- ADDHS r14,r14,#1<<5
- CMP r12,r3, LSL #4
- SUBHS r12,r12,r3, LSL #4
- ADDHS r14,r14,#1<<4
- CMP r12,r3, LSL #3
- SUBHS r12,r12,r3, LSL #3
- ADDHS r14,r14,#1<<3
- CMP r12,r3, LSL #2
- SUBHS r12,r12,r3, LSL #2
- ADDHS r14,r14,#1<<2
- CMP r12,r3, LSL #1
- SUBHS r12,r12,r3, LSL #1
- ADDHS r14,r14,#1<<1
- CMP r12,r3
- SUBHS r12,r12,r3
- ADDHS r14,r14,#1
-
- MLA r4, r14,r4, r10 @ r4 = sum0 * invleft + (1<<15)
- MLA r5, r14,r5, r10 @ r5 = sum1 * invleft + (1<<15)
- MLA r6, r14,r6, r10 @ r6 = sum2 * invleft + (1<<15)
- MLA r7, r14,r7, r10 @ r7 = sum3 * invleft + (1<<15)
- MOV r4, r4, LSR #16 @ r4 = r4 >> 16
- MOV r5, r5, LSR #16 @ r5 = r5 >> 16
- MOV r6, r6, LSR #16 @ r6 = r6 >> 16
- MOV r7, r7, LSR #16 @ r7 = r7 >> 16
- STRB r4, [r1], #1 @ *dst++ = r4
- STRB r5, [r1], #1 @ *dst++ = r5
- STRB r6, [r1], #1 @ *dst++ = r6
- STRB r7, [r1], #1 @ *dst++ = r7
-.L_end_r4:
- LDMFD r13!,{r3-r7,r9-r10,PC}
-
- .fnend
- .size fz_srow4_arm, .-fz_srow4_arm
-
- .type fz_scol4_arm, %function
- .text
-
- @ r0 = src
- @ r1 = dst
- @ r2 = w
- @ r3 = denom
-fz_scol4_arm:
- STMFD r13!,{r3-r7,r9-r11,r14}
-
- MOV r12,#1<<16 @ r12 = (1<<16)
- MOV r14,#0 @ r14 = will contain invdenom
-
- @ r14 = r12/r3
- CMP r12,r3, LSL #16
- SUBHS r12,r12,r3, LSL #16
- ADDHS r14,r14,#1<<16
- CMP r12,r3, LSL #15
- SUBHS r12,r12,r3, LSL #15
- ADDHS r14,r14,#1<<15
- CMP r12,r3, LSL #14
- SUBHS r12,r12,r3, LSL #14
- ADDHS r14,r14,#1<<14
- CMP r12,r3, LSL #13
- SUBHS r12,r12,r3, LSL #13
- ADDHS r14,r14,#1<<13
- CMP r12,r3, LSL #12
- SUBHS r12,r12,r3, LSL #12
- ADDHS r14,r14,#1<<12
- CMP r12,r3, LSL #11
- SUBHS r12,r12,r3, LSL #11
- ADDHS r14,r14,#1<<11
- CMP r12,r3, LSL #10
- SUBHS r12,r12,r3, LSL #10
- ADDHS r14,r14,#1<<10
- CMP r12,r3, LSL #9
- SUBHS r12,r12,r3, LSL #9
- ADDHS r14,r14,#1<<9
- CMP r12,r3, LSL #8
- SUBHS r12,r12,r3, LSL #8
- ADDHS r14,r14,#1<<8
- CMP r12,r3, LSL #7
- SUBHS r12,r12,r3, LSL #7
- ADDHS r14,r14,#1<<7
- CMP r12,r3, LSL #6
- SUBHS r12,r12,r3, LSL #6
- ADDHS r14,r14,#1<<6
- CMP r12,r3, LSL #5
- SUBHS r12,r12,r3, LSL #5
- ADDHS r14,r14,#1<<5
- CMP r12,r3, LSL #4
- SUBHS r12,r12,r3, LSL #4
- ADDHS r14,r14,#1<<4
- CMP r12,r3, LSL #3
- SUBHS r12,r12,r3, LSL #3
- ADDHS r14,r14,#1<<3
- CMP r12,r3, LSL #2
- SUBHS r12,r12,r3, LSL #2
- ADDHS r14,r14,#1<<2
- CMP r12,r3, LSL #1
- SUBHS r12,r12,r3, LSL #1
- ADDHS r14,r14,#1<<1
- CMP r12,r3
- SUBHS r12,r12,r3
- ADDHS r14,r14,#1
-
- @ r2 = x = w
- @ r3 = y = denom
- MOV r11,r2, LSL #2 @ r11= w = w*n
- RSB r11,r11,#0 @ r11=-w
- MOV r10,#1<<15 @ r10= 1<<15
-.L_x_loop_c4:
- MOV r4, #0 @ r4 = sum0 = 0
- MOV r5, #0 @ r5 = sum1 = 0
- MOV r6, #0 @ r6 = sum2 = 0
- MOV r7, #0 @ r7 = sum3 = 0
-.L_y_loop_c4:
- LDRB r9, [r0, #1] @ r9 = src[1]
- LDRB r12,[r0, #2] @ r12= src[2]
- SUBS r3, r3, #1 @ r3 = y--
- ADD r5, r5, r9 @ r4 = sum1 += r9
- LDRB r9, [r0, #3] @ r9 = src[3]
- ADD r6, r6, r12 @ r5 = sum2 += r12
- LDRB r12,[r0], -r11 @ r12= src[0] src += w
- ADD r7, r7, r9 @ r9 = sum3 += r9
- ADD r4, r4, r12 @ r7 = sum0 += r12
- BGT .L_y_loop_c4
-
- LDR r3, [r13] @ r3 = y = denom
- MLA r4, r14,r4, r10 @ r4 = sum0 * invdenom + (1<<15)
- MLA r5, r14,r5, r10 @ r5 = sum1 * invdenom + (1<<15)
- MLA r6, r14,r6, r10 @ r6 = sum2 * invdenom + (1<<15)
- MLA r7, r14,r7, r10 @ r7 = sum3 * invdenom + (1<<15)
- MLA r0, r3, r11,r0 @ r0 = src += -denom*w
- MOV r4, r4, LSR #16 @ r4 = r4 >> 16
- MOV r5, r5, LSR #16 @ r5 = r5 >> 16
- MOV r6, r6, LSR #16 @ r6 = r6 >> 16
- MOV r7, r7, LSR #16 @ r7 = r7 >> 16
- ADD r0, r0, #4 @ r0 = src += n
- STRB r4, [r1], #1 @ *dst++ = r4
- STRB r5, [r1], #1 @ *dst++ = r5
- STRB r6, [r1], #1 @ *dst++ = r6
- STRB r7, [r1], #1 @ *dst++ = r7
- SUBS r2, r2, #1 @ x--
- BNE .L_x_loop_c4
-
-.L_end_c4:
- LDMFD r13!,{r3-r7,r9-r11,PC}
-
- .fnend
- .size fz_scol4_arm, .-fz_scol4_arm
diff --git a/draw/imagesmooth.c b/draw/imagesmooth.c
index e34c07b2..6254e3e4 100644
--- a/draw/imagesmooth.c
+++ b/draw/imagesmooth.c
@@ -989,7 +989,7 @@ scale_single_col(unsigned char *dst, unsigned char *src, fz_weights *weights, in
#endif /* SINGLE_PIXEL_SPECIALS */
fz_pixmap *
-fz_smoothscalepixmap(fz_pixmap *src, float x, float y, float w, float h)
+fz_scalepixmap(fz_pixmap *src, float x, float y, float w, float h)
{
fz_scalefilter *filter = &fz_scalefilter_simple;
fz_weights *contrib_rows = NULL;
diff --git a/fitz/dev_draw.c b/fitz/dev_draw.c
index fb8c4c72..bf49be08 100644
--- a/fitz/dev_draw.c
+++ b/fitz/dev_draw.c
@@ -6,8 +6,6 @@
#define STACKSIZE 96
-#define SMOOTHSCALE
-
typedef struct fz_drawdevice_s fz_drawdevice;
struct fz_drawdevice_s
@@ -528,25 +526,15 @@ fz_drawfillshade(void *user, fz_shade *shade, fz_matrix ctm, float alpha)
}
}
-static int
-fz_calcimagescale(fz_pixmap *image, fz_matrix ctm, int *dx, int *dy)
-{
- float sx = image->w / sqrtf(ctm.a * ctm.a + ctm.b * ctm.b) * 0.66f;
- float sy = image->h / sqrtf(ctm.c * ctm.c + ctm.d * ctm.d) * 0.66f;
- *dx = sx > 1 ? sx : 1;
- *dy = sy > 1 ? sy : 1;
- return *dx > 1 || *dy > 1;
-}
-
static fz_pixmap *
-fz_smoothtransformpixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int dy)
+fz_transformpixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int dy)
{
fz_pixmap *scaled;
if ((ctm->a != 0) && (ctm->b == 0) && (ctm->c == 0) && (ctm->d != 0))
{
/* Unrotated or X flip or Yflip or XYflip */
- scaled = fz_smoothscalepixmap(image, ctm->e, ctm->f, ctm->a, ctm->d);
+ scaled = fz_scalepixmap(image, ctm->e, ctm->f, ctm->a, ctm->d);
if (scaled == nil)
return nil;
ctm->a = scaled->w;
@@ -558,7 +546,7 @@ fz_smoothtransformpixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx,
if ((ctm->a == 0) && (ctm->b != 0) && (ctm->c != 0) && (ctm->d == 0))
{
/* Other orthogonal flip/rotation cases */
- scaled = fz_smoothscalepixmap(image, ctm->f, ctm->e, ctm->b, ctm->c);
+ scaled = fz_scalepixmap(image, ctm->f, ctm->e, ctm->b, ctm->c);
if (scaled == nil)
return nil;
ctm->b = scaled->w;
@@ -570,7 +558,7 @@ fz_smoothtransformpixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx,
/* Downscale, non rectilinear case */
if ((dx > 0) && (dy > 0))
{
- scaled = fz_smoothscalepixmap(image, 0, 0, (float)dx, (float)dy);
+ scaled = fz_scalepixmap(image, 0, 0, (float)dx, (float)dy);
return scaled;
}
return nil;
@@ -610,30 +598,22 @@ fz_drawfillimage(void *user, fz_pixmap *image, fz_matrix ctm, float alpha)
image = converted;
}
-#ifdef SMOOTHSCALE
dx = sqrtf(ctm.a * ctm.a + ctm.b * ctm.b);
dy = sqrtf(ctm.c * ctm.c + ctm.d * ctm.d);
if (dx < image->w && dy < image->h)
{
- scaled = fz_smoothtransformpixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy);
+ scaled = fz_transformpixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy);
if (scaled == nil)
{
if (dx < 1)
dx = 1;
if (dy < 1)
dy = 1;
- scaled = fz_smoothscalepixmap(image, image->x, image->y, dx, dy);
+ scaled = fz_scalepixmap(image, image->x, image->y, dx, dy);
}
if (scaled != nil)
image = scaled;
}
-#else
- if (fz_calcimagescale(image, ctm, &dx, &dy))
- {
- scaled = fz_scalepixmap(image, dx, dy);
- image = scaled;
- }
-#endif
if (image->colorspace != model && after)
{
@@ -665,30 +645,22 @@ fz_drawfillimagemask(void *user, fz_pixmap *image, fz_matrix ctm,
if (image->w == 0 || image->h == 0)
return;
-#ifdef SMOOTHSCALE
dx = sqrtf(ctm.a * ctm.a + ctm.b * ctm.b);
dy = sqrtf(ctm.c * ctm.c + ctm.d * ctm.d);
if (dx < image->w && dy < image->h)
{
- scaled = fz_smoothtransformpixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy);
+ scaled = fz_transformpixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy);
if (scaled == nil)
{
if (dx < 1)
dx = 1;
if (dy < 1)
dy = 1;
- scaled = fz_smoothscalepixmap(image, image->x, image->y, dx, dy);
+ scaled = fz_scalepixmap(image, image->x, image->y, dx, dy);
}
if (scaled != nil)
image = scaled;
}
-#else
- if (fz_calcimagescale(image, ctm, &dx, &dy))
- {
- scaled = fz_scalepixmap(image, dx, dy);
- image = scaled;
- }
-#endif
fz_convertcolor(colorspace, color, model, colorfv);
for (i = 0; i < model->n; i++)
@@ -736,30 +708,22 @@ fz_drawclipimagemask(void *user, fz_pixmap *image, fz_matrix ctm)
fz_clearpixmap(mask);
fz_clearpixmap(dest);
-#ifdef SMOOTHSCALE
dx = sqrtf(ctm.a * ctm.a + ctm.b * ctm.b);
dy = sqrtf(ctm.c * ctm.c + ctm.d * ctm.d);
if (dx < image->w && dy < image->h)
{
- scaled = fz_smoothtransformpixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy);
+ scaled = fz_transformpixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy);
if (scaled == nil)
{
if (dx < 1)
dx = 1;
if (dy < 1)
dy = 1;
- scaled = fz_smoothscalepixmap(image, image->x, image->y, dx, dy);
+ scaled = fz_scalepixmap(image, image->x, image->y, dx, dy);
}
if (scaled != nil)
image = scaled;
}
-#else
- if (fz_calcimagescale(image, ctm, &dx, &dy))
- {
- scaled = fz_scalepixmap(image, dx, dy);
- image = scaled;
- }
-#endif
fz_paintimage(mask, bbox, image, ctm, 255);
diff --git a/fitz/fitz.h b/fitz/fitz.h
index 9af91a3f..b8972871 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -693,8 +693,7 @@ void fz_premultiplypixmap(fz_pixmap *pix);
fz_pixmap *fz_alphafromgray(fz_pixmap *gray, int luminosity);
fz_bbox fz_boundpixmap(fz_pixmap *pix);
-fz_pixmap *fz_scalepixmap(fz_pixmap *src, int xdenom, int ydenom);
-fz_pixmap *fz_smoothscalepixmap(fz_pixmap *src, float x, float y, float w, float h);
+fz_pixmap *fz_scalepixmap(fz_pixmap *src, float x, float y, float w, float h);
fz_error fz_writepnm(fz_pixmap *pixmap, char *filename);
fz_error fz_writepam(fz_pixmap *pixmap, char *filename, int savealpha);
@@ -1203,16 +1202,4 @@ void fz_paintpixmapbbox(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_bbox bbox)
void fz_blendpixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_blendmode blendmode);
-extern void (*fz_srown)(unsigned char *restrict, unsigned char *restrict, int w, int denom, int n);
-extern void (*fz_srow1)(unsigned char *restrict, unsigned char *restrict, int w, int denom);
-extern void (*fz_srow2)(unsigned char *restrict, unsigned char *restrict, int w, int denom);
-extern void (*fz_srow4)(unsigned char *restrict, unsigned char *restrict, int w, int denom);
-extern void (*fz_srow5)(unsigned char *restrict, unsigned char *restrict, int w, int denom);
-
-extern void (*fz_scoln)(unsigned char *restrict, unsigned char *restrict, int w, int denom, int n);
-extern void (*fz_scol1)(unsigned char *restrict, unsigned char *restrict, int w, int denom);
-extern void (*fz_scol2)(unsigned char *restrict, unsigned char *restrict, int w, int denom);
-extern void (*fz_scol4)(unsigned char *restrict, unsigned char *restrict, int w, int denom);
-extern void (*fz_scol5)(unsigned char *restrict, unsigned char *restrict, int w, int denom);
-
#endif