summaryrefslogtreecommitdiff
path: root/fitzdraw
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2010-01-07 14:25:59 +0100
committerTor Andersson <tor@ghostscript.com>2010-01-07 14:25:59 +0100
commitce5bbd9d57287b041e249a21bc88ad87a4c4f9ff (patch)
tree0e3c31f0da3515349a53fccf931db0139eb89c2b /fitzdraw
parent3417c5d2f429b5166a630fc9eb20c9854283ffcc (diff)
downloadmupdf-ce5bbd9d57287b041e249a21bc88ad87a4c4f9ff.tar.xz
Draw images and shadings.
Diffstat (limited to 'fitzdraw')
-rw-r--r--fitzdraw/Jamfile1
-rw-r--r--fitzdraw/glyphcache.c1
-rw-r--r--fitzdraw/imagescale.c29
-rw-r--r--fitzdraw/meshdraw.c19
-rw-r--r--fitzdraw/pixmap.c38
5 files changed, 28 insertions, 60 deletions
diff --git a/fitzdraw/Jamfile b/fitzdraw/Jamfile
index 613e2d7a..b1489b93 100644
--- a/fitzdraw/Jamfile
+++ b/fitzdraw/Jamfile
@@ -11,7 +11,6 @@ Library libfitzdraw :
pathscan.c
pathfill.c
pathstroke.c
-# render.c
blendmodes.c
;
diff --git a/fitzdraw/glyphcache.c b/fitzdraw/glyphcache.c
index dd06d2d3..e9443934 100644
--- a/fitzdraw/glyphcache.c
+++ b/fitzdraw/glyphcache.c
@@ -297,7 +297,6 @@ evictall(fz_glyphcache *arena)
void
fz_renderglyph(fz_glyphcache *arena, fz_glyph *glyph, fz_font *font, int cid, fz_matrix ctm)
{
- fz_error error;
fz_key key;
fz_val *val;
int size;
diff --git a/fitzdraw/imagescale.c b/fitzdraw/imagescale.c
index 19c8abd7..970b3468 100644
--- a/fitzdraw/imagescale.c
+++ b/fitzdraw/imagescale.c
@@ -177,16 +177,16 @@ void (*fz_scol2)(byte *src, byte *dst, int w, int denom) = scol2;
void (*fz_scol4)(byte *src, byte *dst, int w, int denom) = scol4;
void (*fz_scol5)(byte *src, byte *dst, int w, int denom) = scol5;
-fz_error
-fz_newscaledpixmap(fz_pixmap **dstp, int w, int h, int n, int xdenom, int ydenom)
+fz_pixmap *
+fz_newscaledpixmap(int w, int h, int n, int xdenom, int ydenom)
{
int ow = (w + xdenom - 1) / xdenom;
int oh = (h + ydenom - 1) / ydenom;
- return fz_newpixmap(dstp, 0, 0, ow, oh, n);
+ return fz_newpixmap(0, 0, ow, oh, n);
}
/* TODO: refactor */
-fz_error
+void
fz_scalepixmaptile(fz_pixmap *dst, int xoffs, int yoffs, fz_pixmap *src, int xdenom, int ydenom)
{
unsigned char *buf;
@@ -209,8 +209,6 @@ fz_scalepixmaptile(fz_pixmap *dst, int xoffs, int yoffs, fz_pixmap *src, int xde
assert(dst->w >= xoffs + ow && dst->h >= yoffs + oh);
buf = fz_malloc(ow * n * ydenom);
- if (!buf)
- return fz_rethrow(-1, "out of memory");
switch (n)
{
@@ -274,13 +272,11 @@ fz_scalepixmaptile(fz_pixmap *dst, int xoffs, int yoffs, fz_pixmap *src, int xde
}
fz_free(buf);
- return fz_okay;
}
-fz_error
-fz_scalepixmap(fz_pixmap **dstp, fz_pixmap *src, int xdenom, int ydenom)
+fz_pixmap *
+fz_scalepixmap(fz_pixmap *src, int xdenom, int ydenom)
{
- fz_error error;
fz_pixmap *dst;
unsigned char *buf;
int y, iy, oy;
@@ -295,15 +291,8 @@ fz_scalepixmap(fz_pixmap **dstp, fz_pixmap *src, int xdenom, int ydenom)
n = src->n;
buf = fz_malloc(ow * n * ydenom);
- if (!buf)
- return fz_rethrow(-1, "out of memory");
- error = fz_newpixmap(&dst, 0, 0, ow, oh, src->n);
- if (error)
- {
- fz_free(buf);
- return error;
- }
+ dst = fz_newpixmap(0, 0, ow, oh, src->n);
switch (n)
{
@@ -366,7 +355,5 @@ fz_scalepixmap(fz_pixmap **dstp, fz_pixmap *src, int xdenom, int ydenom)
}
fz_free(buf);
- *dstp = dst;
- return fz_okay;
+ return dst;
}
-
diff --git a/fitzdraw/meshdraw.c b/fitzdraw/meshdraw.c
index 2078371f..9722e9ec 100644
--- a/fitzdraw/meshdraw.c
+++ b/fitzdraw/meshdraw.c
@@ -310,7 +310,7 @@ fz_drawtriangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n)
* mesh drawing
*/
-fz_error
+void
fz_rendershade(fz_shade *shade, fz_matrix ctm, fz_colorspace *destcs, fz_pixmap *dest)
{
unsigned char clut[256][3];
@@ -329,17 +329,12 @@ fz_rendershade(fz_shade *shade, fz_matrix ctm, fz_colorspace *destcs, fz_pixmap
if (shade->usefunction)
{
n = 3;
- error = fz_newpixmap(&temp, dest->x, dest->y, dest->w, dest->h, 2);
- if (error)
- return error;
+ temp = fz_newpixmap(dest->x, dest->y, dest->w, dest->h, 2);
}
else if (shade->cs != destcs)
{
n = 2 + shade->cs->n;
- error = fz_newpixmap(&temp, dest->x, dest->y, dest->w, dest->h,
- shade->cs->n + 1);
- if (error)
- return error;
+ temp = fz_newpixmap(dest->x, dest->y, dest->w, dest->h, shade->cs->n + 1);
}
else
{
@@ -357,7 +352,7 @@ fz_rendershade(fz_shade *shade, fz_matrix ctm, fz_colorspace *destcs, fz_pixmap
p.y = shade->mesh[(i * 3 + k) * n + 1];
p = fz_transformpoint(ctm, p);
if (isnan(p.y) || isnan(p.x)) // How is this happening?
- goto baddata;
+ goto baddata;
tri[k][0] = p.x;
tri[k][1] = p.y;
for (j = 2; j < n; j++)
@@ -392,15 +387,13 @@ baddata:
d += 4;
}
- fz_droppixmap(temp);
+ fz_freepixmap(temp);
}
else if (shade->cs != destcs)
{
fz_convertpixmap(shade->cs, temp, destcs, dest);
- fz_droppixmap(temp);
+ fz_freepixmap(temp);
}
-
- return fz_okay;
}
diff --git a/fitzdraw/pixmap.c b/fitzdraw/pixmap.c
index 96e08b84..d5aed102 100644
--- a/fitzdraw/pixmap.c
+++ b/fitzdraw/pixmap.c
@@ -1,14 +1,11 @@
#include "fitz.h"
-fz_error
-fz_newpixmap(fz_pixmap **pixp, int x, int y, int w, int h, int n)
+fz_pixmap *
+fz_newpixmap(int x, int y, int w, int h, int n)
{
fz_pixmap *pix;
- pix = *pixp = fz_malloc(sizeof(fz_pixmap));
- if (!pix)
- return fz_rethrow(-1, "out of memory");
-
+ pix = fz_malloc(sizeof(fz_pixmap));
pix->x = x;
pix->y = y;
pix->w = w;
@@ -16,33 +13,26 @@ fz_newpixmap(fz_pixmap **pixp, int x, int y, int w, int h, int n)
pix->n = n;
pix->samples = fz_malloc(pix->w * pix->h * pix->n * sizeof(fz_sample));
- if (!pix->samples) {
- fz_free(pix);
- return fz_rethrow(-1, "out of memory");
- }
-
- return fz_okay;
+
+ return pix;
}
-fz_error
-fz_newpixmapwithrect(fz_pixmap **pixp, fz_irect r, int n)
+fz_pixmap *
+fz_newpixmapwithrect(fz_irect r, int n)
{
- return fz_newpixmap(pixp, r.x0, r.y0, r.x1 - r.x0, r.y1 - r.y0, n);
+ return fz_newpixmap(r.x0, r.y0, r.x1 - r.x0, r.y1 - r.y0, n);
}
-fz_error
-fz_newpixmapcopy(fz_pixmap **pixp, fz_pixmap *old)
+fz_pixmap *
+fz_newpixmapcopy(fz_pixmap *old)
{
- fz_error error;
- error = fz_newpixmap(pixp, old->x, old->y, old->w, old->h, old->n);
- if (error)
- return error;
- memcpy((*pixp)->samples, old->samples, old->w * old->h * old->n);
- return fz_okay;
+ fz_pixmap *pix = fz_newpixmap(old->x, old->y, old->w, old->h, old->n);
+ memcpy(pix->samples, old->samples, old->w * old->h * old->n);
+ return pix;
}
void
-fz_droppixmap(fz_pixmap *pix)
+fz_freepixmap(fz_pixmap *pix)
{
fz_free(pix->samples);
fz_free(pix);