diff options
author | Tor Andersson <tor@ghostscript.com> | 2004-11-24 03:47:04 +0100 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2004-11-24 03:47:04 +0100 |
commit | b48de7618e25bc2cef9d9db4f9b49e1d546e438a (patch) | |
tree | 5f365a90a0bd355073e7d5d1f69e66d2f82b4446 /tree | |
parent | e092458f4403f1424d8fd1f5ec194880a05c3362 (diff) | |
download | mupdf-b48de7618e25bc2cef9d9db4f9b49e1d546e438a.tar.xz |
rewrite of render loop part 3
Diffstat (limited to 'tree')
-rw-r--r-- | tree/debug.c | 14 | ||||
-rw-r--r-- | tree/node1.c | 2 | ||||
-rw-r--r-- | tree/node2.c | 73 | ||||
-rw-r--r-- | tree/path.c | 27 | ||||
-rw-r--r-- | tree/text.c | 2 | ||||
-rw-r--r-- | tree/tree.c | 2 |
6 files changed, 52 insertions, 68 deletions
diff --git a/tree/debug.c b/tree/debug.c index cbfffc20..0f4edada 100644 --- a/tree/debug.c +++ b/tree/debug.c @@ -6,6 +6,16 @@ static void indent(int level) putchar(' '); } +static void showbbox(void *node0) +{ + fz_node *node = node0; + fz_irect bbox; + bbox = fz_roundrect(fz_boundnode(node, fz_identity())); + printf("[%d %d %d %d]", + bbox.min.x, bbox.min.y, + bbox.max.x, bbox.max.y); +} + static void lispnode(fz_node *node, int level); static void lispmeta(fz_metanode *node, int level) @@ -26,7 +36,7 @@ static void lispover(fz_overnode *node, int level) { fz_node *child; indent(level); - printf("(over\n"); + printf("(over "); showbbox(node); printf("\n"); for (child = node->super.first; child; child = child->next) lispnode(child, level + 1); indent(level); @@ -37,7 +47,7 @@ static void lispmask(fz_masknode *node, int level) { fz_node *child; indent(level); - printf("(mask\n"); + printf("(mask "); showbbox(node); printf("\n"); for (child = node->super.first; child; child = child->next) lispnode(child, level + 1); indent(level); diff --git a/tree/node1.c b/tree/node1.c index 19244721..2587077c 100644 --- a/tree/node1.c +++ b/tree/node1.c @@ -90,7 +90,7 @@ fz_boundnode(fz_node *node, fz_matrix ctm) case FZ_NMETA: return fz_boundmetanode((fz_metanode *) node, ctm); } - return fz_infiniterect(); + return fz_emptyrect; } int diff --git a/tree/node2.c b/tree/node2.c index 1374a30f..5c3e3931 100644 --- a/tree/node2.c +++ b/tree/node2.c @@ -23,20 +23,20 @@ fz_boundovernode(fz_overnode *node, fz_matrix ctm) { fz_node *child; fz_rect bbox; - fz_rect r; + fz_rect temp; - bbox = fz_infiniterect(); + child = node->super.first; + if (!child) + return fz_emptyrect; - for (child = node->super.first; child; child = child->next) + bbox = fz_boundnode(child, ctm); + + child = child->next; + while (child) { - r = fz_boundnode(child, ctm); - if (r.max.x >= r.min.x) - { - if (bbox.max.x >= bbox.min.x) - bbox = fz_mergerects(r, bbox); - else - bbox = r; - } + temp = fz_boundnode(child, ctm); + bbox = fz_mergerects(temp, bbox); + child = child->next; } return bbox; @@ -63,25 +63,16 @@ fz_newmasknode(fz_node **nodep) fz_rect fz_boundmasknode(fz_masknode *node, fz_matrix ctm) { - fz_node *child; - fz_rect bbox; - fz_rect r; - - bbox = fz_infiniterect(); + fz_node *shape; + fz_node *color; + fz_rect one, two; - for (child = node->super.first; child; child = child->next) - { - r = fz_boundnode(child, ctm); - if (r.max.x >= r.min.x) - { - if (bbox.max.x >= bbox.min.x) - bbox = fz_intersectrects(r, bbox); - else - bbox = r; - } - } + shape = node->super.first; + color = shape->next; - return bbox; + one = fz_boundnode(shape, ctm); + two = fz_boundnode(color, ctm); + return fz_intersectrects(one, two); } /* @@ -110,25 +101,7 @@ fz_newblendnode(fz_node **nodep, fz_colorspace *cs, fz_blendkind b, int k, int i fz_rect fz_boundblendnode(fz_blendnode *node, fz_matrix ctm) { - fz_node *child; - fz_rect bbox; - fz_rect r; - - bbox = fz_infiniterect(); - - for (child = node->super.first; child; child = child->next) - { - r = fz_boundnode(child, ctm); - if (r.max.x >= r.min.x) - { - if (bbox.max.x >= bbox.min.x) - bbox = fz_mergerects(r, bbox); - else - bbox = r; - } - } - - return bbox; + return fz_emptyrect; } /* @@ -155,7 +128,7 @@ fz_rect fz_boundtransformnode(fz_transformnode *node, fz_matrix ctm) { if (!node->super.first) - return fz_infiniterect(); + return fz_emptyrect; return fz_boundnode(node->super.first, fz_concat(node->m, ctm)); } @@ -198,7 +171,7 @@ fz_rect fz_boundmetanode(fz_metanode *node, fz_matrix ctm) { if (!node->super.first) - return fz_infiniterect(); + return fz_emptyrect; return fz_boundnode(node->super.first, ctm); } @@ -261,7 +234,7 @@ fz_newcolornode(fz_node **nodep, fz_colorspace *cs, int n, float *v) fz_rect fz_boundcolornode(fz_colornode *node, fz_matrix ctm) { - return fz_infiniterect(); + return fz_infiniterect; } /* diff --git a/tree/path.c b/tree/path.c index 74e29a59..ac070025 100644 --- a/tree/path.c +++ b/tree/path.c @@ -168,18 +168,10 @@ fz_endpath(fz_pathnode *path, fz_pathkind paint, fz_stroke *stroke, fz_dash *das static inline fz_rect boundexpand(fz_rect r, fz_point p) { - if (r.min.x > r.max.x) - { - r.min.x = r.max.x = p.x; - r.min.y = r.max.y = p.y; - } - else - { - if (p.x < r.min.x) r.min.x = p.x; - if (p.y < r.min.y) r.min.y = p.y; - if (p.x > r.max.x) r.max.x = p.x; - if (p.y > r.max.y) r.max.y = p.y; - } + if (p.x < r.min.x) r.min.x = p.x; + if (p.y < r.min.y) r.min.y = p.y; + if (p.x > r.max.x) r.max.x = p.x; + if (p.y > r.max.y) r.max.y = p.y; return r; } @@ -187,9 +179,18 @@ fz_rect fz_boundpathnode(fz_pathnode *path, fz_matrix ctm) { fz_point p; - fz_rect r = fz_infiniterect(); + fz_rect r = fz_emptyrect; int i = 0; + if (path->len) + { + p.x = path->els[1].v; + p.y = path->els[2].v; + p = fz_transformpoint(ctm, p); + r.min.x = r.max.x = p.x; + r.min.y = r.max.y = p.y; + } + while (i < path->len) { switch (path->els[i++].k) diff --git a/tree/text.c b/tree/text.c index a7581cf9..ef77f530 100644 --- a/tree/text.c +++ b/tree/text.c @@ -35,7 +35,7 @@ fz_boundtextnode(fz_textnode *text, fz_matrix ctm) int i; if (text->len == 0) - return fz_infiniterect(); + return fz_emptyrect; /* find bbox of glyph origins in ctm space */ diff --git a/tree/tree.c b/tree/tree.c index 0c7cefb1..f07e564f 100644 --- a/tree/tree.c +++ b/tree/tree.c @@ -39,7 +39,7 @@ fz_boundtree(fz_tree *tree, fz_matrix ctm) { if (tree->root) return fz_boundnode(tree->root, ctm); - return fz_infiniterect(); + return fz_emptyrect; } void |