summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2009-12-02 22:54:13 +0100
committerTor Andersson <tor@ghostscript.com>2009-12-02 22:54:13 +0100
commit6af1fed04cea6c3d7fe086c593c57fdc8fed8719 (patch)
tree45a9abc2ea8c7905a765fe3dbb196a266d5c5edf /fitz
parent0345e9e83bd16b39fffecd3bda584996f642b8cd (diff)
downloadmupdf-6af1fed04cea6c3d7fe086c593c57fdc8fed8719.tar.xz
Killing time. Butchered display tree and disabled all calls to it.
Diffstat (limited to 'fitz')
-rw-r--r--fitz/Jamfile9
-rw-r--r--fitz/fitz.h2
-rw-r--r--fitz/fitz_draw.h13
-rw-r--r--fitz/fitz_tree.h4
-rw-r--r--fitz/node_misc1.c65
-rw-r--r--fitz/node_misc2.c296
-rw-r--r--fitz/node_path.c147
-rw-r--r--fitz/node_text.c83
-rw-r--r--fitz/node_toxml.c186
-rw-r--r--fitz/node_tree.c108
-rw-r--r--fitz/res_colorspace.c2
-rw-r--r--fitz/res_font.c10
-rw-r--r--fitz/res_image.c2
-rw-r--r--fitz/res_shade.c2
14 files changed, 107 insertions, 822 deletions
diff --git a/fitz/Jamfile b/fitz/Jamfile
index f9d8d5f5..14b15d74 100644
--- a/fitz/Jamfile
+++ b/fitz/Jamfile
@@ -68,22 +68,15 @@ if $(HAVE_JBIG2DEC) { Library libfitz : filt_jbig2d.c ; }
if $(HAVE_OPENJPEG) { Library libfitz : filt_jpxd.c ; }
#
-# Resources and display tree.
+# Resources.
#
Library libfitz :
-
- node_toxml.c
- node_misc1.c
- node_misc2.c
node_path.c
node_text.c
- node_tree.c
-
res_colorspace.c
res_font.c
res_image.c
res_shade.c
-
;
diff --git a/fitz/fitz.h b/fitz/fitz.h
index 0e9bcd08..caba61e4 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -3,7 +3,7 @@
#include "fitz_base.h"
#include "fitz_stream.h"
-#include "fitz_tree.h"
+#include "fitz_res.h"
#include "fitz_draw.h"
#endif
diff --git a/fitz/fitz_draw.h b/fitz/fitz_draw.h
index 7e3baa9e..c22b8a1c 100644
--- a/fitz/fitz_draw.h
+++ b/fitz/fitz_draw.h
@@ -60,10 +60,9 @@ void fz_dropael(fz_ael *ael);
fz_error fz_scanconvert(fz_gel *gel, fz_ael *ael, int eofill,
fz_irect clip, fz_pixmap *pix, unsigned char *argb, int over);
-fz_error fz_fillpath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness);
-fz_error fz_strokepath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness, float linewidth);
-fz_error fz_dashpath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness, float linewidth);
-
+fz_error fz_fillpath(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness);
+fz_error fz_strokepath(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness, float linewidth);
+fz_error fz_dashpath(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness, float linewidth);
/*
* Function pointers -- they can be replaced by cpu-optimized versions
@@ -132,9 +131,5 @@ struct fz_renderer_s
extern void fz_accelerate(void);
-fz_error fz_newrenderer(fz_renderer **gcp, fz_colorspace *pcm, int maskonly, int gcmem);
+fz_renderer * fz_newrenderer(fz_colorspace *pcm, int maskonly, int gcmem);
void fz_droprenderer(fz_renderer *gc);
-fz_error fz_rendertree(fz_pixmap **out, fz_renderer *gc, fz_tree *tree, fz_matrix ctm, fz_irect bbox, int white);
-fz_error fz_rendertreeover(fz_renderer *gc, fz_pixmap *dest, fz_tree *tree, fz_matrix ctm);
-
-
diff --git a/fitz/fitz_tree.h b/fitz/fitz_tree.h
index 29da14cb..74962048 100644
--- a/fitz/fitz_tree.h
+++ b/fitz/fitz_tree.h
@@ -319,7 +319,7 @@ struct fz_colorspace_s
void (*convcolor)(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv);
void (*toxyz)(fz_colorspace *, float *src, float *xyz);
void (*fromxyz)(fz_colorspace *, float *xyz, float *dst);
- void (*freefunc)(fz_colorspace *);
+ void (*drop)(fz_colorspace *);
};
struct fz_colorcube1_s { unsigned char v[17]; };
@@ -386,7 +386,7 @@ struct fz_image_s
{
int refs;
fz_error (*loadtile)(fz_image*,fz_pixmap*);
- void (*freefunc)(fz_image*);
+ void (*drop)(fz_image*);
fz_colorspace *cs;
int w, h, n, a;
};
diff --git a/fitz/node_misc1.c b/fitz/node_misc1.c
index 48bd1278..128406e3 100644
--- a/fitz/node_misc1.c
+++ b/fitz/node_misc1.c
@@ -32,44 +32,39 @@ fz_initnode(fz_node *node, fz_nodekind kind)
void
fz_dropnode(fz_node *node)
{
- fz_node *next;
+ if (node->first)
+ fz_dropnode(node->first);
+ if (node->next)
+ fz_dropnode(node->next);
- while (node)
+ switch (node->kind)
{
- if (node->first)
- fz_dropnode(node->first);
-
- switch (node->kind)
- {
- case FZ_NTRANSFORM:
- case FZ_NOVER:
- case FZ_NMASK:
- case FZ_NBLEND:
- break;
- case FZ_NCOLOR:
- fz_dropsolidnode((fz_solidnode *) node);
- break;
- case FZ_NPATH:
- fz_droppathnode((fz_pathnode *) node);
- break;
- case FZ_NTEXT:
- fz_droptextnode((fz_textnode *) node);
- break;
- case FZ_NIMAGE:
- fz_dropimagenode((fz_imagenode *) node);
- break;
- case FZ_NSHADE:
- fz_dropshadenode((fz_shadenode *) node);
- break;
- case FZ_NLINK:
- fz_droplinknode((fz_linknode *) node);
- break;
- }
-
- next = node->next;
- fz_free(node);
- node = next;
+ case FZ_NTRANSFORM:
+ case FZ_NOVER:
+ case FZ_NMASK:
+ case FZ_NBLEND:
+ break;
+ case FZ_NCOLOR:
+ fz_dropsolidnode((fz_solidnode *) node);
+ break;
+ case FZ_NPATH:
+ fz_droppathnode((fz_pathnode *) node);
+ break;
+ case FZ_NTEXT:
+ fz_droptextnode((fz_textnode *) node);
+ break;
+ case FZ_NIMAGE:
+ fz_dropimagenode((fz_imagenode *) node);
+ break;
+ case FZ_NSHADE:
+ fz_dropshadenode((fz_shadenode *) node);
+ break;
+ case FZ_NLINK:
+ fz_droplinknode((fz_linknode *) node);
+ break;
}
+
+ fz_free(node);
}
fz_rect
diff --git a/fitz/node_misc2.c b/fitz/node_misc2.c
deleted file mode 100644
index 330c09de..00000000
--- a/fitz/node_misc2.c
+++ /dev/null
@@ -1,296 +0,0 @@
-#include "fitz_base.h"
-#include "fitz_tree.h"
-
-/*
- * Over
- */
-
-fz_error
-fz_newovernode(fz_node **nodep)
-{
- fz_node *node;
-
- node = *nodep = fz_malloc(sizeof (fz_overnode));
- if (!node)
- return fz_rethrow(-1, "out of memory");
-
- fz_initnode(node, FZ_NOVER);
-
- return fz_okay;
-}
-
-fz_rect
-fz_boundovernode(fz_overnode *node, fz_matrix ctm)
-{
- fz_node *child;
- fz_rect bbox;
- fz_rect temp;
-
- child = node->super.first;
- if (!child)
- return fz_emptyrect;
-
- bbox = fz_boundnode(child, ctm);
-
- child = child->next;
- while (child)
- {
- temp = fz_boundnode(child, ctm);
- bbox = fz_mergerects(temp, bbox);
- child = child->next;
- }
-
- return bbox;
-}
-
-/*
- * Mask
- */
-
-fz_error
-fz_newmasknode(fz_node **nodep)
-{
- fz_node *node;
-
- node = *nodep = fz_malloc(sizeof (fz_masknode));
- if (!node)
- return fz_rethrow(-1, "out of memory");
-
- fz_initnode(node, FZ_NMASK);
-
- return fz_okay;
-}
-
-fz_rect
-fz_boundmasknode(fz_masknode *node, fz_matrix ctm)
-{
- fz_node *shape;
- fz_node *color;
- fz_rect one, two;
-
- shape = node->super.first;
- color = shape->next;
-
- one = fz_boundnode(shape, ctm);
- two = fz_boundnode(color, ctm);
- return fz_intersectrects(one, two);
-}
-
-/*
- * Blend
- */
-
-fz_error
-fz_newblendnode(fz_node **nodep, fz_blendkind b, int i, int k)
-{
- fz_blendnode *node;
-
- node = fz_malloc(sizeof (fz_blendnode));
- if (!node)
- return fz_rethrow(-1, "out of memory");
- *nodep = (fz_node*)node;
-
- fz_initnode((fz_node*)node, FZ_NBLEND);
- node->mode = b;
- node->isolated = i;
- node->knockout = k;
-
- return fz_okay;
-}
-
-fz_rect
-fz_boundblendnode(fz_blendnode *node, fz_matrix ctm)
-{
- fz_node *child;
- fz_rect bbox;
- fz_rect temp;
-
- child = node->super.first;
- if (!child)
- return fz_emptyrect;
-
- bbox = fz_boundnode(child, ctm);
-
- child = child->next;
- while (child)
- {
- temp = fz_boundnode(child, ctm);
- bbox = fz_mergerects(temp, bbox);
- child = child->next;
- }
-
- return bbox;
-}
-
-void
-fz_dropblendnode(fz_blendnode *node)
-{
- fz_dropcolorspace(node->cs);
-}
-
-/*
- * Transform
- */
-
-fz_error
-fz_newtransformnode(fz_node **nodep, fz_matrix m)
-{
- fz_transformnode *node;
-
- node = fz_malloc(sizeof (fz_transformnode));
- if (!node)
- return fz_rethrow(-1, "out of memory");
- *nodep = (fz_node*)node;
-
- fz_initnode((fz_node*)node, FZ_NTRANSFORM);
- node->m = m;
-
- return fz_okay;
-}
-
-fz_rect
-fz_boundtransformnode(fz_transformnode *node, fz_matrix ctm)
-{
- if (!node->super.first)
- return fz_emptyrect;
- return fz_boundnode(node->super.first, fz_concat(node->m, ctm));
-}
-
-/*
- * Link to tree
- */
-
-fz_error
-fz_newlinknode(fz_node **nodep, fz_tree *subtree)
-{
- fz_linknode *node;
-
- node = fz_malloc(sizeof (fz_linknode));
- if (!node)
- return fz_rethrow(-1, "out of memory");
- *nodep = (fz_node*)node;
-
- fz_initnode((fz_node*)node, FZ_NLINK);
- node->tree = fz_keeptree(subtree);
-
- return fz_okay;
-}
-
-void
-fz_droplinknode(fz_linknode *node)
-{
- fz_droptree(node->tree);
-}
-
-fz_rect
-fz_boundlinknode(fz_linknode *node, fz_matrix ctm)
-{
- return fz_boundtree(node->tree, ctm);
-}
-
-/*
- * Solid color
- */
-
-fz_error
-fz_newsolidnode(fz_node **nodep, float a, fz_colorspace *cs, int n, float *v)
-{
- fz_solidnode *node;
- int i;
-
- node = fz_malloc(sizeof(fz_solidnode) + sizeof(float) * n);
- if (!node)
- return fz_rethrow(-1, "out of memory");
- *nodep = (fz_node*)node;
-
- fz_initnode((fz_node*)node, FZ_NCOLOR);
- node->a = a;
- node->cs = fz_keepcolorspace(cs);
- node->n = n;
- for (i = 0; i < n; i++)
- node->samples[i] = v[i];
-
- return fz_okay;
-}
-
-fz_rect
-fz_boundsolidnode(fz_solidnode *node, fz_matrix ctm)
-{
- return fz_infiniterect;
-}
-
-void
-fz_dropsolidnode(fz_solidnode *node)
-{
- fz_dropcolorspace(node->cs);
-}
-
-/*
- * Image node
- */
-
-fz_error
-fz_newimagenode(fz_node **nodep, fz_image *image)
-{
- fz_imagenode *node;
-
- node = fz_malloc(sizeof (fz_imagenode));
- if (!node)
- return fz_rethrow(-1, "out of memory");
- *nodep = (fz_node*)node;
-
- fz_initnode((fz_node*)node, FZ_NIMAGE);
- node->image = fz_keepimage(image);
-
- return fz_okay;
-}
-
-void
-fz_dropimagenode(fz_imagenode *node)
-{
- fz_dropimage(node->image);
-}
-
-fz_rect
-fz_boundimagenode(fz_imagenode *node, fz_matrix ctm)
-{
- fz_rect bbox;
- bbox.x0 = 0;
- bbox.y0 = 0;
- bbox.x1 = 1;
- bbox.y1 = 1;
- return fz_transformaabb(ctm, bbox);
-}
-
-/*
- * Shade node
- */
-
-fz_error
-fz_newshadenode(fz_node **nodep, fz_shade *shade)
-{
- fz_shadenode *node;
-
- node = fz_malloc(sizeof (fz_shadenode));
- if (!node)
- return fz_rethrow(-1, "out of memory");
- *nodep = (fz_node*)node;
-
- fz_initnode((fz_node*)node, FZ_NSHADE);
- node->shade = fz_keepshade(shade);
-
- return fz_okay;
-}
-
-void
-fz_dropshadenode(fz_shadenode *node)
-{
- fz_dropshade(node->shade);
-}
-
-fz_rect
-fz_boundshadenode(fz_shadenode *node, fz_matrix ctm)
-{
- return fz_boundshade(node->shade, ctm);
-}
-
diff --git a/fitz/node_path.c b/fitz/node_path.c
index 1ef469eb..bca274d3 100644
--- a/fitz/node_path.c
+++ b/fitz/node_path.c
@@ -1,17 +1,12 @@
#include "fitz_base.h"
-#include "fitz_tree.h"
+#include "fitz_res.h"
-fz_error
-fz_newpathnode(fz_pathnode **pathp)
+fz_path *
+fz_newpath(void)
{
- fz_pathnode *path;
-
- path = *pathp = fz_malloc(sizeof(fz_pathnode));
- if (!path)
- return fz_rethrow(-1, "out of memory");
-
- fz_initnode((fz_node*)path, FZ_NPATH);
+ fz_path *path;
+ path = fz_malloc(sizeof(fz_path));
path->paint = FZ_FILL;
path->linecap = 0;
path->linejoin = 0;
@@ -22,99 +17,55 @@ fz_newpathnode(fz_pathnode **pathp)
path->cap = 0;
path->els = nil;
- return fz_okay;
-}
-
-fz_error
-fz_clonepathnode(fz_pathnode **pathp, fz_pathnode *oldpath)
-{
- fz_pathnode *path;
-
- path = *pathp = fz_malloc(sizeof(fz_pathnode));
- if (!path)
- return fz_rethrow(-1, "out of memory");
-
- fz_initnode((fz_node*)path, FZ_NPATH);
-
- path->paint = FZ_FILL;
- path->linecap = 0;
- path->linejoin = 0;
- path->linewidth = 1.0;
- path->miterlimit = 10.0;
- path->dash = nil;
- path->len = oldpath->len;
- path->cap = oldpath->len;
-
- path->els = fz_malloc(sizeof (fz_pathel) * path->len);
- if (!path->els) {
- fz_free(path);
- return fz_rethrow(-1, "out of memory");
- }
- memcpy(path->els, oldpath->els, sizeof(fz_pathel) * path->len);
-
- return fz_okay;
+ return path;
}
void
-fz_droppathnode(fz_pathnode *node)
+fz_droppath(fz_path *node)
{
fz_free(node->dash);
fz_free(node->els);
}
-static fz_error
-growpath(fz_pathnode *path, int n)
+static void
+growpath(fz_path *path, int n)
{
- int newcap;
- fz_pathel *newels;
-
+ if (path->len + n < path->cap)
+ return;
while (path->len + n > path->cap)
- {
- newcap = path->cap + 36;
- newels = fz_realloc(path->els, sizeof (fz_pathel) * newcap);
- if (!newels)
- return fz_rethrow(-1, "out of memory");
- path->cap = newcap;
- path->els = newels;
- }
-
- return fz_okay;
+ path->cap = path->cap + 36;
+ path->els = fz_realloc(path->els, sizeof (fz_pathel) * path->cap);
}
-fz_error
-fz_moveto(fz_pathnode *path, float x, float y)
+void
+fz_moveto(fz_path *path, float x, float y)
{
- if (growpath(path, 3) != fz_okay)
- return fz_rethrow(-1, "out of memory");
+ growpath(path, 3);
path->els[path->len++].k = FZ_MOVETO;
path->els[path->len++].v = x;
path->els[path->len++].v = y;
- return fz_okay;
}
-fz_error
-fz_lineto(fz_pathnode *path, float x, float y)
+void
+fz_lineto(fz_path *path, float x, float y)
{
if (path->len == 0)
- return fz_throw("no current point");
- if (growpath(path, 3) != fz_okay)
- return fz_rethrow(-1, "out of memory");
+ fz_moveto(path, 0, 0);
+ growpath(path, 3);
path->els[path->len++].k = FZ_LINETO;
path->els[path->len++].v = x;
path->els[path->len++].v = y;
- return fz_okay;
}
-fz_error
-fz_curveto(fz_pathnode *path,
+void
+fz_curveto(fz_path *path,
float x1, float y1,
float x2, float y2,
float x3, float y3)
{
if (path->len == 0)
- return fz_throw("no current point");
- if (growpath(path, 7) != fz_okay)
- return fz_rethrow(-1, "out of memory");
+ fz_moveto(path, 0, 0);
+ growpath(path, 7);
path->els[path->len++].k = FZ_CURVETO;
path->els[path->len++].v = x1;
path->els[path->len++].v = y1;
@@ -122,40 +73,33 @@ fz_curveto(fz_pathnode *path,
path->els[path->len++].v = y2;
path->els[path->len++].v = x3;
path->els[path->len++].v = y3;
- return fz_okay;
}
-fz_error
-fz_curvetov(fz_pathnode *path, float x2, float y2, float x3, float y3)
+void
+fz_curvetov(fz_path *path, float x2, float y2, float x3, float y3)
{
float x1 = path->els[path->len-2].v;
float y1 = path->els[path->len-1].v;
- return fz_curveto(path, x1, y1, x2, y2, x3, y3);
+ fz_curveto(path, x1, y1, x2, y2, x3, y3);
}
-fz_error
-fz_curvetoy(fz_pathnode *path, float x1, float y1, float x3, float y3)
+void
+fz_curvetoy(fz_path *path, float x1, float y1, float x3, float y3)
{
- return fz_curveto(path, x1, y1, x3, y3, x3, y3);
+ fz_curveto(path, x1, y1, x3, y3, x3, y3);
}
-fz_error
-fz_closepath(fz_pathnode *path)
+void
+fz_closepath(fz_path *path)
{
if (path->len == 0)
- {
- fz_warn("tried to close an empty path");
- return fz_okay;
- }
-
- if (growpath(path, 1) != fz_okay)
- return fz_rethrow(-1, "out of memory");
+ return;
+ growpath(path, 1);
path->els[path->len++].k = FZ_CLOSEPATH;
- return fz_okay;
}
-fz_error
-fz_endpath(fz_pathnode *path, fz_pathkind paint, fz_stroke *stroke, fz_dash *dash)
+void
+fz_setpathstate(fz_path *path, fz_pathkind paint, fz_stroke *stroke, fz_dash *dash)
{
path->paint = paint;
path->dash = dash;
@@ -166,8 +110,6 @@ fz_endpath(fz_pathnode *path, fz_pathkind paint, fz_stroke *stroke, fz_dash *das
path->linewidth = stroke->linewidth;
path->miterlimit = stroke->miterlimit;
}
-
- return fz_okay;
}
static inline fz_rect boundexpand(fz_rect r, fz_point p)
@@ -180,7 +122,7 @@ static inline fz_rect boundexpand(fz_rect r, fz_point p)
}
fz_rect
-fz_boundpathnode(fz_pathnode *path, fz_matrix ctm)
+fz_boundpath(fz_path *path, fz_matrix ctm)
{
fz_point p;
fz_rect r = fz_emptyrect;
@@ -232,7 +174,7 @@ fz_boundpathnode(fz_pathnode *path, fz_matrix ctm)
}
void
-fz_printpathnode(fz_pathnode *path, int indent)
+fz_printpath(fz_path *path, int indent)
{
float x, y;
int i = 0;
@@ -287,7 +229,7 @@ fz_printpathnode(fz_pathnode *path, int indent)
}
void
-fz_debugpathnode(fz_pathnode *path, int indent)
+fz_debugpath(fz_path *path, int indent)
{
float x, y;
int i = 0;
@@ -325,22 +267,19 @@ fz_debugpathnode(fz_pathnode *path, int indent)
}
}
-fz_error
-fz_newdash(fz_dash **dashp, float phase, int len, float *array)
+fz_dash *
+fz_newdash(float phase, int len, float *array)
{
fz_dash *dash;
int i;
- dash = *dashp = fz_malloc(sizeof(fz_dash) + sizeof(float) * len);
- if (!dash)
- return fz_rethrow(-1, "out of memory");
-
+ dash = fz_malloc(sizeof(fz_dash) + sizeof(float) * len);
dash->len = len;
dash->phase = phase;
for (i = 0; i < len; i++)
dash->array[i] = array[i];
- return fz_okay;
+ return dash;
}
void
diff --git a/fitz/node_text.c b/fitz/node_text.c
index c7d973b7..8f11ed26 100644
--- a/fitz/node_text.c
+++ b/fitz/node_text.c
@@ -1,67 +1,30 @@
#include "fitz_base.h"
-#include "fitz_tree.h"
+#include "fitz_res.h"
-fz_error
-fz_newtextnode(fz_textnode **textp, fz_font *font)
+fz_text *
+fz_newtext(fz_font *font)
{
- fz_textnode *text;
-
- text = fz_malloc(sizeof(fz_textnode));
- if (!text)
- return fz_rethrow(-1, "out of memory");
-
- fz_initnode((fz_node*)text, FZ_NTEXT);
+ fz_text *text;
+ text = fz_malloc(sizeof(fz_text));
text->font = fz_keepfont(font);
text->trm = fz_identity();
text->len = 0;
text->cap = 0;
text->els = nil;
- *textp = text;
- return fz_okay;
-}
-
-fz_error
-fz_clonetextnode(fz_textnode **textp, fz_textnode *oldtext)
-{
- fz_textnode *text;
-
- text = *textp = fz_malloc(sizeof(fz_textnode));
- if (!text)
- return fz_rethrow(-1, "out of memory");
-
- fz_initnode((fz_node*)text, FZ_NTEXT);
-
- text->font = fz_keepfont(oldtext->font);
- text->trm = oldtext->trm;
- text->len = oldtext->len;
- text->cap = oldtext->len;
- text->els = nil;
-
- text->els = fz_malloc(sizeof(fz_textel) * text->len);
- if (!text->els)
- {
- fz_dropfont(text->font);
- fz_free(text);
- return fz_rethrow(-1, "out of memory");
- }
-
- memcpy(text->els, oldtext->els, sizeof(fz_textel) * text->len);
-
- *textp = text;
- return fz_okay;
+ return text;
}
void
-fz_droptextnode(fz_textnode *text)
+fz_droptext(fz_text *text)
{
fz_dropfont(text->font);
fz_free(text->els);
}
fz_rect
-fz_boundtextnode(fz_textnode *text, fz_matrix ctm)
+fz_boundtext(fz_text *text, fz_matrix ctm)
{
fz_matrix trm;
fz_rect bbox;
@@ -109,35 +72,23 @@ fz_boundtextnode(fz_textnode *text, fz_matrix ctm)
return bbox;
}
-static fz_error
-growtext(fz_textnode *text, int n)
+static void
+growtext(fz_text *text, int n)
{
- int newcap;
- fz_textel *newels;
-
+ if (text->len + n < text->cap)
+ return;
while (text->len + n > text->cap)
- {
- newcap = text->cap + 36;
- newels = fz_realloc(text->els, sizeof (fz_textel) * newcap);
- if (!newels)
- return fz_rethrow(-1, "out of memory");
- text->cap = newcap;
- text->els = newels;
- }
-
- return fz_okay;
+ text->cap = text->cap + 36;
+ text->els = fz_realloc(text->els, sizeof (fz_textel) * text->cap);
}
-fz_error
-fz_addtext(fz_textnode *text, int gid, int ucs, float x, float y)
+void
+fz_addtext(fz_text *text, int gid, int ucs, float x, float y)
{
- if (growtext(text, 1) != fz_okay)
- return fz_rethrow(-1, "out of memory");
+ growtext(text, 1);
text->els[text->len].ucs = ucs;
text->els[text->len].gid = gid;
text->els[text->len].x = x;
text->els[text->len].y = y;
text->len++;
- return fz_okay;
}
-
diff --git a/fitz/node_toxml.c b/fitz/node_toxml.c
deleted file mode 100644
index 173b41b7..00000000
--- a/fitz/node_toxml.c
+++ /dev/null
@@ -1,186 +0,0 @@
-#include "fitz_base.h"
-#include "fitz_tree.h"
-
-static void indent(int level)
-{
- while (level--)
- putchar(' ');
-}
-
-static void xmlnode(fz_node *node, int level);
-
-static void xmlover(fz_overnode *node, int level)
-{
- fz_node *child;
- indent(level);
- printf("<over>\n");
- for (child = node->super.first; child; child = child->next)
- xmlnode(child, level + 1);
- indent(level);
- printf("</over>\n");
-}
-
-static void xmlmask(fz_masknode *node, int level)
-{
- fz_node *child;
- indent(level);
- printf("<mask>\n");
- for (child = node->super.first; child; child = child->next)
- xmlnode(child, level + 1);
- indent(level);
- printf("</mask>\n");
-}
-
-static void xmlblend(fz_blendnode *node, int level)
-{
- fz_node *child;
- indent(level);
- printf("<blend mode=\"%d\" isolated=\"%d\" knockout=\"%d\">\n",
- node->mode, node->isolated, node->knockout);
- for (child = node->super.first; child; child = child->next)
- xmlnode(child, level + 1);
- indent(level);
- printf("</blend>\n");
-}
-
-static void xmltransform(fz_transformnode *node, int level)
-{
- indent(level);
- printf("<transform matrix=\"%g %g %g %g %g %g\">\n",
- node->m.a, node->m.b,
- node->m.c, node->m.d,
- node->m.e, node->m.f);
- xmlnode(node->super.first, level + 1);
- indent(level);
- printf("</transform>\n");
-}
-
-static void xmlsolid(fz_solidnode *node, int level)
-{
- int i;
- indent(level);
- printf("<solid colorspace=\"%s\" alpha=\"%g\" v=\"", node->cs->name, node->a);
- for (i = 0; i < node->n; i++)
- {
- printf("%g", node->samples[i]);
- if (i < node->n - 1)
- putchar(' ');
- }
- printf("\" />\n");
-}
-
-static void xmllink(fz_linknode *node, int level)
-{
- indent(level);
- printf("<link name=\"%p\" />\n", (void *) node->tree);
-}
-
-static void xmlpath(fz_pathnode *node, int level)
-{
- int i;
-
- indent(level);
-
- if (node->paint == FZ_STROKE)
- {
- printf("<path fill=\"stroke\" cap=\"%d\" join=\"%d\" width=\"%g\" miter=\"%g\"",
- node->linecap,
- node->linejoin,
- node->linewidth,
- node->miterlimit);
- if (node->dash)
- {
- printf(" phase=\"%g\" array=\"", node->dash->phase);
- for (i = 0; i < node->dash->len; i++)
- printf("%g ", node->dash->array[i]);
- printf("\"");
- }
- printf(">\n");
- }
- else
- {
- printf("<path fill=\"%s\">\n",
- node->paint == FZ_FILL ? "nonzero" : "evenodd");
- }
-
- fz_debugpathnode(node, level + 2);
-
- indent(level);
- printf("</path>\n");
-}
-
-static void xmltext(fz_textnode *node, int level)
-{
- int i;
-
- indent(level);
- printf("<text font=\"%s\" matrix=\"%g %g %g %g\">\n", node->font->name,
- node->trm.a, node->trm.b, node->trm.c, node->trm.d);
-
- for (i = 0; i < node->len; i++)
- {
- indent(level + 1);
- if (node->els[i].ucs >= 32 && node->els[i].ucs < 128)
- printf("<g ucs=\"%c\" gid=%d x=\"%g\" y=\"%g\" />\n",
- node->els[i].ucs, node->els[i].gid, node->els[i].x, node->els[i].y);
- else
- printf("<g ucs=\"U+%04X\" gid=%d x=\"%g\" y=\"%g\" />\n",
- node->els[i].ucs, node->els[i].gid, node->els[i].x, node->els[i].y);
- }
-
- indent(level);
- printf("</text>\n");
-}
-
-static void xmlimage(fz_imagenode *node, int level)
-{
- fz_image *image = node->image;
- indent(level);
- printf("<image w=\"%d\" h=\"%d\" n=\"%d\" a=\"%d\" />\n",
- image->w, image->h, image->n, image->a);
-}
-
-static void xmlshade(fz_shadenode *node, int level)
-{
- indent(level);
- printf("<shade />\n");
-}
-
-static void xmlnode(fz_node *node, int level)
-{
- if (!node)
- {
- indent(level);
- printf("<nil />\n");
- return;
- }
-
- switch (node->kind)
- {
- case FZ_NOVER: xmlover((fz_overnode*)node, level); break;
- case FZ_NMASK: xmlmask((fz_masknode*)node, level); break;
- case FZ_NBLEND: xmlblend((fz_blendnode*)node, level); break;
- case FZ_NTRANSFORM: xmltransform((fz_transformnode*)node, level); break;
- case FZ_NCOLOR: xmlsolid((fz_solidnode*)node, level); break;
- case FZ_NPATH: xmlpath((fz_pathnode*)node, level); break;
- case FZ_NTEXT: xmltext((fz_textnode*)node, level); break;
- case FZ_NIMAGE: xmlimage((fz_imagenode*)node, level); break;
- case FZ_NSHADE: xmlshade((fz_shadenode*)node, level); break;
- case FZ_NLINK: xmllink((fz_linknode*)node, level); break;
- }
-}
-
-void
-fz_debugnode(fz_node *node)
-{
- xmlnode(node, 0);
-}
-
-void
-fz_debugtree(fz_tree *tree)
-{
- printf("<tree>\n");
- xmlnode(tree->root, 1);
- printf("</tree>\n");
-}
-
diff --git a/fitz/node_tree.c b/fitz/node_tree.c
deleted file mode 100644
index 6dc035e1..00000000
--- a/fitz/node_tree.c
+++ /dev/null
@@ -1,108 +0,0 @@
-#include "fitz_base.h"
-#include "fitz_tree.h"
-
-fz_error
-fz_newtree(fz_tree **treep)
-{
- fz_tree *tree;
-
- tree = *treep = fz_malloc(sizeof (fz_tree));
- if (!tree)
- return fz_rethrow(-1, "out of memory");
-
- tree->refs = 1;
- tree->root = nil;
- tree->head = nil;
-
- return fz_okay;
-}
-
-fz_tree *
-fz_keeptree(fz_tree *tree)
-{
- tree->refs ++;
- return tree;
-}
-
-void
-fz_droptree(fz_tree *tree)
-{
- if (--tree->refs == 0)
- {
- if (tree->root)
- fz_dropnode(tree->root);
- fz_free(tree);
- }
-}
-
-fz_rect
-fz_boundtree(fz_tree *tree, fz_matrix ctm)
-{
- if (tree->root)
- return fz_boundnode(tree->root, ctm);
- return fz_emptyrect;
-}
-
-void
-fz_insertnodefirst(fz_node *parent, fz_node *child)
-{
- child->parent = parent;
- child->next = parent->first;
- parent->first = child;
- if (!parent->last)
- parent->last = child;
-}
-
-void
-fz_insertnodelast(fz_node *parent, fz_node *child)
-{
- child->parent = parent;
- if (!parent->first)
- parent->first = child;
- else
- parent->last->next = child;
- parent->last = child;
-}
-
-void
-fz_insertnodeafter(fz_node *prev, fz_node *child)
-{
- fz_node *parent = prev->parent;
- child->parent = parent;
- if (parent->last == prev)
- parent->last = child;
- child->next = prev->next;
- prev->next = child;
-}
-
-void
-fz_removenode(fz_node *child)
-{
- fz_node *parent = child->parent;
- fz_node *prev;
- fz_node *node;
-
- if (parent->first == child)
- {
- parent->first = child->next;
- if (parent->last == child)
- parent->last = nil;
- return;
- }
-
- prev = parent->first;
- node = prev->next;
-
- while (node)
- {
- if (node == child)
- {
- prev->next = child->next;
- }
- prev = node;
- node = node->next;
- }
-
- parent->last = prev;
-}
-
diff --git a/fitz/res_colorspace.c b/fitz/res_colorspace.c
index 9de10973..a3d6f211 100644
--- a/fitz/res_colorspace.c
+++ b/fitz/res_colorspace.c
@@ -1,5 +1,5 @@
#include "fitz_base.h"
-#include "fitz_tree.h"
+#include "fitz_res.h"
void
fz_convertpixmap(fz_colorspace *srcs, fz_pixmap *src, fz_colorspace *dsts, fz_pixmap *dst)
diff --git a/fitz/res_font.c b/fitz/res_font.c
index 16ff3523..64ba5730 100644
--- a/fitz/res_font.c
+++ b/fitz/res_font.c
@@ -1,5 +1,6 @@
#include "fitz_base.h"
-#include "fitz_tree.h"
+#include "fitz_stream.h"
+#include "fitz_res.h"
#include "fitz_draw.h" /* FIXME -- for glyph rendering callbacks */
#include <ft2build.h>
@@ -51,7 +52,7 @@ fz_dropfont(fz_font *font)
{
for (i = 0; i < 256; i++)
if (font->t3procs[i])
- fz_droptree(font->t3procs[i]);
+ ; // XXX fz_droptree(font->t3procs[i]);
fz_free(font->t3procs);
fz_free(font->t3widths);
}
@@ -338,7 +339,7 @@ fz_newtype3font(char *name, fz_matrix matrix)
int i;
font = fz_newfont();
- font->t3procs = fz_malloc(sizeof(fz_tree*) * 256);
+ font->t3procs = fz_malloc(sizeof(fz_buffer*) * 256);
font->t3widths = fz_malloc(sizeof(float) * 256);
strlcpy(font->name, name, sizeof(font->name));
@@ -358,6 +359,7 @@ extern fz_colorspace *pdf_devicegray;
fz_error
fz_rendert3glyph(fz_glyph *glyph, fz_font *font, int gid, fz_matrix trm)
{
+#if 0 // XXX
fz_error error;
fz_renderer *gc;
fz_tree *tree;
@@ -401,7 +403,7 @@ fz_rendert3glyph(fz_glyph *glyph, fz_font *font, int gid, fz_matrix trm)
glyph->w = pixmap->w;
glyph->h = pixmap->h;
glyph->samples = pixmap->samples;
-
+#endif
return fz_okay;
}
diff --git a/fitz/res_image.c b/fitz/res_image.c
index e5918c64..3ccc01dc 100644
--- a/fitz/res_image.c
+++ b/fitz/res_image.c
@@ -1,5 +1,5 @@
#include "fitz_base.h"
-#include "fitz_tree.h"
+#include "fitz_res.h"
fz_image *
fz_keepimage(fz_image *image)
diff --git a/fitz/res_shade.c b/fitz/res_shade.c
index 2d1b1cea..5efa1827 100644
--- a/fitz/res_shade.c
+++ b/fitz/res_shade.c
@@ -1,5 +1,5 @@
#include "fitz_base.h"
-#include "fitz_tree.h"
+#include "fitz_res.h"
fz_shade *
fz_keepshade(fz_shade *shade)