summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Jamrules3
-rw-r--r--apps/Jamfile8
-rw-r--r--apps/unix/x11pdf.c11
-rw-r--r--apps/unix/ximage.c4
-rw-r--r--raster/imagescale.c96
-rw-r--r--raster/imageunpack.c13
-rw-r--r--raster/porterduff.c28
7 files changed, 122 insertions, 41 deletions
diff --git a/Jamrules b/Jamrules
index 92609009..e0619ba3 100644
--- a/Jamrules
+++ b/Jamrules
@@ -41,7 +41,6 @@ switch $(OS)
HAVE_X11 = yes ;
NEED_STRLCPY = yes ;
NEED_STRLCAT = yes ;
- NEED_STRSEP = yes ;
FLAG_CCALL += -std=gnu99 -DHAVE_C99 ;
FLAG_LDALL += -L/opt/local/lib -L/usr/X11R6/lib ;
@@ -52,7 +51,7 @@ switch $(OS)
FLAG_CCPROFILE = -g -qp ;
case gcc-X86 :
# add -msse -msse2 when such functions exist...
- FLAG_CCRELEASE = -DARCH_X86 -O3 -march=pentium -mmmx ;
+ FLAG_CCRELEASE = -DARCH_X86 -O3 -g -march=k8 -mmmx -std=gnu99 -ftree-vectorize -ftree-vectorizer-verbose=2 ;
}
case MACOSX :
diff --git a/apps/Jamfile b/apps/Jamfile
index f526c4c9..b3fffb3a 100644
--- a/apps/Jamfile
+++ b/apps/Jamfile
@@ -54,6 +54,14 @@ if $(HAVE_X11) = yes
LINKLIBS on apparition$(SUFEXE) = $(LINKLIBS) -lX11 -lXext ;
}
+if $(HAVE_GLX) = yes
+{
+ SubDir TOP apps unix ;
+ Main glxview : glxpdf.c ;
+ LinkLibraries glxview : libpdfapp $(FITZLIBS) ;
+ LINKLIBS on glxview$(SUFEXE) = $(LINKLIBS) -lX11 -lGL ;
+}
+
if $(OS) = noMACOSX
{
SubDir TOP apps macosx ;
diff --git a/apps/unix/x11pdf.c b/apps/unix/x11pdf.c
index 5941d4d0..54aaae36 100644
--- a/apps/unix/x11pdf.c
+++ b/apps/unix/x11pdf.c
@@ -200,7 +200,7 @@ static void fillrect(int x, int y, int w, int h)
static void invertcopyrect()
{
- unsigned char *p;
+ unsigned t, *p;
int x, y;
int x0 = gapp.selr.x0 - gapp.panx;
@@ -215,14 +215,11 @@ static void invertcopyrect()
for (y = y0; y < y1; y++)
{
- p = gapp.image->samples + (y * gapp.image->w + x0) * 4;
+ p = (unsigned *)(gapp.image->samples + (y * gapp.image->w + x0) * 4);
for (x = x0; x < x1; x++)
{
- p[0] = 255 - p[0];
- p[1] = 255 - p[1];
- p[2] = 255 - p[2];
- p[3] = 255 - p[3];
- p += 4;
+ *p = ~0 - *p;
+ p ++;
}
}
diff --git a/apps/unix/ximage.c b/apps/unix/ximage.c
index 22e04a41..b37cf544 100644
--- a/apps/unix/ximage.c
+++ b/apps/unix/ximage.c
@@ -440,8 +440,8 @@ static void
ximage_convert_argb8888(PARAMS)
{
int x, y;
- unsigned *s = (unsigned *)src;
- unsigned *d = (unsigned *)dst;
+ unsigned * restrict s = (unsigned * restrict )src;
+ unsigned * restrict d = (unsigned * restrict )dst;
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
d[x] = s[x];
diff --git a/raster/imagescale.c b/raster/imagescale.c
index 6d12086d..38310a4e 100644
--- a/raster/imagescale.c
+++ b/raster/imagescale.c
@@ -4,10 +4,10 @@
typedef unsigned char byte;
-static void srown(byte *src, byte *dst, int w, int denom, int n)
+static inline void srown(byte * restrict src, byte * restrict dst, unsigned w, unsigned denom, unsigned n)
{
- int x, left, k;
- int sum[FZ_MAXCOLORS];
+ unsigned x, left, k;
+ unsigned sum[FZ_MAXCOLORS];
left = 0;
for (k = 0; k < n; k++)
@@ -35,6 +35,37 @@ static void srown(byte *src, byte *dst, int w, int denom, int n)
dst[k] = sum[k] / left;
}
+static inline void srownp2(byte * restrict src, byte * restrict dst, unsigned w, unsigned log2denom, unsigned n)
+{
+ unsigned 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 == (1<<log2denom))
+ {
+ left = 0;
+ for (k = 0; k < n; k++)
+ {
+ dst[k] = sum[k] >> log2denom;
+ sum[k] = 0;
+ }
+ dst += n;
+ }
+ }
+
+ /* left overs */
+ if (left)
+ for (k = 0; k < n; k++)
+ dst[k] = sum[k] / left;
+}
+
static void srow1(byte *src, byte *dst, int w, int denom)
{
srown(src, dst, w, denom, 1);
@@ -55,7 +86,12 @@ static void srow5(byte *src, byte *dst, int w, int denom)
srown(src, dst, w, denom, 5);
}
-static void scoln(byte *src, byte *dst, int w, int denom, int n)
+static void srow5p2(byte * restrict src, byte * restrict dst, int w, int log2denom)
+{
+ srownp2(src, dst, w, log2denom, 5);
+}
+
+static inline void scoln(byte * restrict src, byte * restrict dst, int w, int denom, int n)
{
int x, y, k;
byte *s;
@@ -75,6 +111,26 @@ static void scoln(byte *src, byte *dst, int w, int denom, int n)
}
}
+static inline void scolnp2(byte *src, byte *dst, int w, int log2denom, int n)
+{
+ 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 < (1<<log2denom); y++)
+ for (k = 0; k < n; k++)
+ sum[k] += s[y * w * n + k];
+ for (k = 0; k < n; k++)
+ dst[k] = sum[k] >> log2denom;
+ dst += n;
+ }
+}
+
static void scol1(byte *src, byte *dst, int w, int denom)
{
scoln(src, dst, w, denom, 1);
@@ -95,6 +151,11 @@ static void scol5(byte *src, byte *dst, int w, int denom)
scoln(src, dst, w, denom, 5);
}
+static void scol5p2(byte *src, byte *dst, int w, int denom)
+{
+ scolnp2(src, dst, w, denom, 5);
+}
+
void (*fz_srown)(byte *src, byte *dst, int w, int denom, int n) = srown;
void (*fz_srow1)(byte *src, byte *dst, int w, int denom) = srow1;
void (*fz_srow2)(byte *src, byte *dst, int w, int denom) = srow2;
@@ -115,6 +176,7 @@ fz_scalepixmap(fz_pixmap **dstp, fz_pixmap *src, int xdenom, int ydenom)
unsigned char *buf;
int y, iy, oy;
int ow, oh, n;
+ int ydenom2 = ydenom;
void (*srowx)(byte *src, byte *dst, int w, int denom) = nil;
void (*scolx)(byte *src, byte *dst, int w, int denom) = nil;
@@ -139,7 +201,23 @@ fz_scalepixmap(fz_pixmap **dstp, fz_pixmap *src, int xdenom, int ydenom)
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;
+ case 5: srowx = fz_srow5; scolx = fz_scol5;
+ if (!(xdenom & (xdenom - 1)))
+ {
+ unsigned v = xdenom;
+ xdenom = 0;
+ while ((v >>= 1)) xdenom++;
+ srowx = srow5p2;
+ }
+ if (!(ydenom & (ydenom - 1)))
+ {
+ unsigned v = ydenom2;
+ ydenom2 = 0;
+ while ((v >>= 1)) ydenom2++;
+ scolx = scol5p2;
+ }
+
+ break;
}
if (srowx && scolx)
@@ -150,7 +228,7 @@ fz_scalepixmap(fz_pixmap **dstp, fz_pixmap *src, int xdenom, int ydenom)
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);
+ scolx(buf, dst->samples + oy * dst->w * n, dst->w, ydenom2);
}
ydenom = src->h - y;
@@ -160,7 +238,7 @@ fz_scalepixmap(fz_pixmap **dstp, fz_pixmap *src, int xdenom, int ydenom)
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);
+ scolx(buf, dst->samples + oy * dst->w * n, dst->w, ydenom2);
}
}
@@ -172,7 +250,7 @@ fz_scalepixmap(fz_pixmap **dstp, fz_pixmap *src, int xdenom, int ydenom)
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);
+ fz_scoln(buf, dst->samples + oy * dst->w * n, dst->w, ydenom2, n);
}
ydenom = src->h - y;
@@ -182,7 +260,7 @@ fz_scalepixmap(fz_pixmap **dstp, fz_pixmap *src, int xdenom, int ydenom)
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);
+ fz_scoln(buf, dst->samples + oy * dst->w * n, dst->w, ydenom2, n);
}
}
diff --git a/raster/imageunpack.c b/raster/imageunpack.c
index b650b0f2..a3642d3d 100644
--- a/raster/imageunpack.c
+++ b/raster/imageunpack.c
@@ -13,7 +13,7 @@ static void decodetile(fz_pixmap *pix, int skip, float *decode)
int min[FZ_MAXCOLORS];
int max[FZ_MAXCOLORS];
int sub[FZ_MAXCOLORS];
- int useless = 1;
+ int needed = 0;
byte *p = pix->samples;
int n = pix->n;
int wh = pix->w * pix->h;
@@ -28,11 +28,10 @@ static void decodetile(fz_pixmap *pix, int skip, float *decode)
min[i] = decode[(i - skip) * 2] * 255;
max[i] = decode[(i - skip) * 2 + 1] * 255;
sub[i] = max[i] - min[i];
- if (min[i] != 0 || max[i] != 255)
- useless = 0;
+ needed |= (min[i] != 0) | (max[i] != 255);
}
- if (useless)
+ if (!needed)
return;
while (wh--)
@@ -170,11 +169,11 @@ static void loadtile1(byte *src, int sw, byte *dst, int dw, int w, int h, int pa
} \
}
-static void loadtile2(byte *src, int sw, byte *dst, int dw, int w, int h, int pad)
+static void loadtile2(byte * restrict src, int sw, byte * restrict dst, int dw, int w, int h, int pad)
TILE(ttwo)
-static void loadtile4(byte *src, int sw, byte *dst, int dw, int w, int h, int pad)
+static void loadtile4(byte * restrict src, int sw, byte * restrict dst, int dw, int w, int h, int pad)
TILE(tnib)
-static void loadtile8(byte *src, int sw, byte *dst, int dw, int w, int h, int pad)
+static void loadtile8(byte * restrict src, int sw, byte * restrict dst, int dw, int w, int h, int pad)
TILE(toct)
void (*fz_decodetile)(fz_pixmap *pix, int skip, float *decode) = decodetile;
diff --git a/raster/porterduff.c b/raster/porterduff.c
index ab974151..74b34ac2 100644
--- a/raster/porterduff.c
+++ b/raster/porterduff.c
@@ -10,7 +10,7 @@ typedef unsigned char byte;
/* dst = src over dst */
static void
-duff_non(byte *sp0, int sw, int sn, byte *dp0, int dw, int w0, int h)
+duff_non(byte * restrict sp0, int sw, int sn, byte * restrict dp0, int dw, int w0, int h)
{
int k;
while (h--)
@@ -36,7 +36,7 @@ duff_non(byte *sp0, int sw, int sn, byte *dp0, int dw, int w0, int h)
/* dst = src in msk */
static void
-duff_nimcn(byte *sp0, int sw, int sn, byte *mp0, int mw, int mn, byte *dp0, int dw, int w0, int h)
+duff_nimcn(byte * restrict sp0, int sw, int sn, byte * restrict mp0, int mw, int mn, byte * restrict dp0, int dw, int w0, int h)
{
int k;
while (h--)
@@ -62,7 +62,7 @@ duff_nimcn(byte *sp0, int sw, int sn, byte *mp0, int mw, int mn, byte *dp0, int
/* dst = src in msk over dst */
static void
-duff_nimon(byte *sp0, int sw, int sn, byte *mp0, int mw, int mn, byte *dp0, int dw, int w0, int h)
+duff_nimon(byte * restrict sp0, int sw, int sn, byte * restrict mp0, int mw, int mn, byte * restrict dp0, int dw, int w0, int h)
{
int k;
while (h--)
@@ -91,7 +91,7 @@ duff_nimon(byte *sp0, int sw, int sn, byte *mp0, int mw, int mn, byte *dp0, int
}
}
-static void duff_1o1(byte *sp0, int sw, byte *dp0, int dw, int w0, int h)
+static void duff_1o1(byte * restrict sp0, int sw, byte * restrict dp0, int dw, int w0, int h)
{
/* duff_non(sp0, sw, 1, dp0, dw, w0, h); */
while (h--)
@@ -133,7 +133,7 @@ static void duff_4o4(byte *sp0, int sw, byte *dp0, int dw, int w0, int h)
}
}
-static void duff_1i1c1(byte *sp0, int sw, byte *mp0, int mw, byte *dp0, int dw, int w0, int h)
+static void duff_1i1c1(byte * restrict sp0, int sw, byte * restrict mp0, int mw, byte * restrict dp0, int dw, int w0, int h)
{
/* duff_nimcn(sp0, sw, 1, mp0, mw, 1, dp0, dw, w0, h); */
while (h--)
@@ -155,7 +155,7 @@ static void duff_1i1c1(byte *sp0, int sw, byte *mp0, int mw, byte *dp0, int dw,
}
}
-static void duff_4i1c4(byte *sp0, int sw, byte *mp0, int mw, byte *dp0, int dw, int w0, int h)
+static void duff_4i1c4(byte * restrict sp0, int sw, byte * restrict mp0, int mw, byte * restrict dp0, int dw, int w0, int h)
{
/* duff_nimcn(sp0, sw, 4, mp0, mw, 1, dp0, dw, w0, h); */
while (h--)
@@ -181,7 +181,7 @@ static void duff_4i1c4(byte *sp0, int sw, byte *mp0, int mw, byte *dp0, int dw,
}
}
-static void duff_1i1o1(byte *sp0, int sw, byte *mp0, int mw, byte *dp0, int dw, int w0, int h)
+static void duff_1i1o1(byte * restrict sp0, int sw, byte * restrict mp0, int mw, byte * restrict dp0, int dw, int w0, int h)
{
/* duff_nimon(sp0, sw, 1, mp0, mw, 1, dp0, dw, w0, h); */
while (h--)
@@ -206,7 +206,7 @@ static void duff_1i1o1(byte *sp0, int sw, byte *mp0, int mw, byte *dp0, int dw,
}
}
-static void duff_4i1o4(byte *sp0, int sw, byte *mp0, int mw, byte *dp0, int dw, int w0, int h)
+static void duff_4i1o4(byte * restrict sp0, int sw, byte * restrict mp0, int mw, byte * restrict dp0, int dw, int w0, int h)
{
/* duff_nimon(sp0, sw, 4, mp0, mw, 1, dp0, dw, w0, h); */
while (h--)
@@ -238,7 +238,7 @@ static void duff_4i1o4(byte *sp0, int sw, byte *mp0, int mw, byte *dp0, int dw,
* Path and text masks
*/
-static void path_1c1(byte *src, int cov, int len, byte *dst)
+static void path_1c1(byte * restrict src, int cov, int len, byte * restrict dst)
{
while (len--)
{
@@ -247,7 +247,7 @@ static void path_1c1(byte *src, int cov, int len, byte *dst)
}
}
-static void path_1o1(byte *src, int cov, int len, byte *dst)
+static void path_1o1(byte * restrict src, int cov, int len, byte * restrict dst)
{
while (len--)
{
@@ -257,7 +257,7 @@ static void path_1o1(byte *src, int cov, int len, byte *dst)
}
}
-static void path_w3i1o4(byte *rgb, byte *src, int cov, int len, byte *dst)
+static void path_w3i1o4(byte * restrict rgb, byte * restrict src, int cov, int len, byte * restrict dst)
{
byte rgb0 = rgb[0];
byte rgb1 = rgb[1];
@@ -275,7 +275,7 @@ static void path_w3i1o4(byte *rgb, byte *src, int cov, int len, byte *dst)
}
}
-static void text_1c1(byte *src0, int srcw, byte *dst0, int dstw, int w0, int h)
+static void text_1c1(byte * restrict src0, int srcw, byte * restrict dst0, int dstw, int w0, int h)
{
while (h--)
{
@@ -291,7 +291,7 @@ static void text_1c1(byte *src0, int srcw, byte *dst0, int dstw, int w0, int h)
}
}
-static void text_1o1(byte *src0, int srcw, byte *dst0, int dstw, int w0, int h)
+static void text_1o1(byte * restrict src0, int srcw, byte * restrict dst0, int dstw, int w0, int h)
{
while (h--)
{
@@ -309,7 +309,7 @@ static void text_1o1(byte *src0, int srcw, byte *dst0, int dstw, int w0, int h)
}
}
-static void text_w3i1o4(byte *rgb, byte *src0, int srcw, byte *dst0, int dstw, int w0, int h)
+static void text_w3i1o4(byte * restrict rgb, byte * restrict src0, int srcw, byte * restrict dst0, int dstw, int w0, int h)
{
unsigned char rgb0 = rgb[0];
unsigned char rgb1 = rgb[1];