summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2010-06-22 19:57:26 +0200
committerTor Andersson <tor@ghostscript.com>2010-06-22 19:57:26 +0200
commit0edb7f95c50f0012ae173b3fa42cebe2905f1826 (patch)
tree94480fda293955fe7a6aa253e5dadd178a0798f8
parent7c2008556ad928cfa2845f1532c63dfdedbd768b (diff)
downloadmupdf-0edb7f95c50f0012ae173b3fa42cebe2905f1826.tar.xz
Add hints flag to device struct so that the interpreter doesn't need to load image resources for dev_text.
-rw-r--r--draw/meshdraw.c4
-rw-r--r--fitz/dev_null.c2
-rw-r--r--fitz/dev_text.c5
-rw-r--r--fitz/fitz_draw.h8
-rw-r--r--mupdf/pdf_interpret.c43
5 files changed, 40 insertions, 22 deletions
diff --git a/draw/meshdraw.c b/draw/meshdraw.c
index e07a1f7d..c0e219c4 100644
--- a/draw/meshdraw.c
+++ b/draw/meshdraw.c
@@ -238,7 +238,7 @@ fz_drawtriangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n, fz_bbox
copyvert(poly[1], bv, n);
copyvert(poly[2], cv, n);
- len = clippoly(poly, temp, 3, n, cx0, 0, 0);
+ len = clippoly(poly, temp, 3, n, cx0, 0, 0);
len = clippoly(temp, poly, len, n, cx1, 0, 1);
len = clippoly(poly, temp, len, n, cy0, 1, 0);
len = clippoly(temp, poly, len, n, cy1, 1, 1);
@@ -268,7 +268,7 @@ fz_drawtriangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n, fz_bbox
y = gel[top][1];
- if (findnext(gel, len, top, &s0, &e0, 1))
+ if (findnext(gel, len, top, &s0, &e0, 1))
return;
if (findnext(gel, len, top, &s1, &e1, -1))
return;
diff --git a/fitz/dev_null.c b/fitz/dev_null.c
index 9e4ee764..1c3788a5 100644
--- a/fitz/dev_null.c
+++ b/fitz/dev_null.c
@@ -22,6 +22,8 @@ fz_newdevice(void *user)
fz_device *dev = fz_malloc(sizeof(fz_device));
memset(dev, 0, sizeof(fz_device));
+ dev->hints = 0;
+
dev->user = user;
dev->freeuser = fz_nullfreeuser;
diff --git a/fitz/dev_text.c b/fitz/dev_text.c
index d08b2f64..29319714 100644
--- a/fitz/dev_text.c
+++ b/fitz/dev_text.c
@@ -340,9 +340,7 @@ fz_textextractspan(fz_textspan **last, fz_text *text, fz_matrix ctm, fz_point *p
int mask = FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING;
if (text->wmode)
mask |= FT_LOAD_VERTICAL_LAYOUT;
- err = FT_Get_Advance(font->ftface, text->els[i].gid, mask, &ftadv);
- if (err)
- fz_warn("freetype get advance (gid %d): %s", text->els[i].gid, ft_errorstring(err));
+ FT_Get_Advance(font->ftface, text->els[i].gid, mask, &ftadv);
adv = ftadv / 65536.0f;
if (text->wmode)
{
@@ -438,6 +436,7 @@ fz_newtextdevice(fz_textspan *root)
tdev->point.y = -1;
dev = fz_newdevice(tdev);
+ dev->hints = FZ_IGNOREIMAGE | FZ_IGNORESHADE;
dev->freeuser = fz_textfreeuser;
dev->filltext = fz_textfilltext;
dev->stroketext = fz_textstroketext;
diff --git a/fitz/fitz_draw.h b/fitz/fitz_draw.h
index e622d81a..077edd0b 100644
--- a/fitz/fitz_draw.h
+++ b/fitz/fitz_draw.h
@@ -71,10 +71,18 @@ fz_pixmap * fz_scalepixmap(fz_pixmap *src, int xdenom, int ydenom);
* The device interface.
*/
+enum
+{
+ FZ_IGNOREIMAGE = 1,
+ FZ_IGNORESHADE = 2,
+};
+
typedef struct fz_device_s fz_device;
struct fz_device_s
{
+ int hints;
+
void *user;
void (*freeuser)(void *);
diff --git a/mupdf/pdf_interpret.c b/mupdf/pdf_interpret.c
index 63516572..3c6170b1 100644
--- a/mupdf/pdf_interpret.c
+++ b/mupdf/pdf_interpret.c
@@ -570,12 +570,15 @@ Lsetcolorspace:
else if (!strcmp(fz_toname(subtype), "Image"))
{
- pdf_image *img;
- error = pdf_loadimage(&img, csi->xref, obj);
- if (error)
- return fz_rethrow(error, "cannot load image (%d %d R)", fz_tonum(obj), fz_togen(obj));
- pdf_showimage(csi, img);
- pdf_dropimage(img);
+ if ((csi->dev->hints & FZ_IGNOREIMAGE) == 0)
+ {
+ pdf_image *img;
+ error = pdf_loadimage(&img, csi->xref, obj);
+ if (error)
+ return fz_rethrow(error, "cannot load image (%d %d R)", fz_tonum(obj), fz_togen(obj));
+ pdf_showimage(csi, img);
+ pdf_dropimage(img);
+ }
}
else if (!strcmp(fz_toname(subtype), "PS"))
@@ -783,12 +786,15 @@ Lsetcolor:
else if (fz_toint(patterntype) == 2)
{
- fz_shade *shd;
- error = pdf_loadshade(&shd, csi->xref, obj);
- if (error)
- return fz_rethrow(error, "cannot load shading (%d %d R)", fz_tonum(obj), fz_togen(obj));
- pdf_setshade(csi, what, shd);
- fz_dropshade(shd);
+ if ((csi->dev->hints & FZ_IGNORESHADE) == 0)
+ {
+ fz_shade *shd;
+ error = pdf_loadshade(&shd, csi->xref, obj);
+ if (error)
+ return fz_rethrow(error, "cannot load shading (%d %d R)", fz_tonum(obj), fz_togen(obj));
+ pdf_setshade(csi, what, shd);
+ fz_dropshade(shd);
+ }
}
else
@@ -1273,11 +1279,14 @@ Lsetcolor:
if (!obj)
return fz_throw("cannot find shading resource: %s", fz_toname(csi->stack[csi->top - 1]));
- error = pdf_loadshade(&shd, csi->xref, obj);
- if (error)
- return fz_rethrow(error, "cannot load shading (%d %d R)", fz_tonum(obj), fz_togen(obj));
- pdf_showshade(csi, shd);
- fz_dropshade(shd);
+ if ((csi->dev->hints & FZ_IGNORESHADE) == 0)
+ {
+ error = pdf_loadshade(&shd, csi->xref, obj);
+ if (error)
+ return fz_rethrow(error, "cannot load shading (%d %d R)", fz_tonum(obj), fz_togen(obj));
+ pdf_showshade(csi, shd);
+ fz_dropshade(shd);
+ }
break;
}
default: