summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-04-08 02:00:57 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-04-08 02:00:57 +0200
commita1b5f023ccebd339e9a74ef7f3bcc94c0c74d3e0 (patch)
tree1ee557f8a9566e8df97bddd41a5b1fe578bbfcaf
parent4c61a323f057ed5be58ab2c21b73af440a9c3295 (diff)
downloadmupdf-a1b5f023ccebd339e9a74ef7f3bcc94c0c74d3e0.tar.xz
Tweak the display list visibility culling.
-rw-r--r--fitz/dev_list.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/fitz/dev_list.c b/fitz/dev_list.c
index 71d938d0..33e86b73 100644
--- a/fitz/dev_list.c
+++ b/fitz/dev_list.c
@@ -372,40 +372,40 @@ fz_free_display_list(fz_display_list *list)
}
void
-fz_execute_display_list(fz_display_list *list, fz_device *dev, fz_matrix top_ctm, fz_bbox bounds)
+fz_execute_display_list(fz_display_list *list, fz_device *dev, fz_matrix top_ctm, fz_bbox scissor)
{
fz_display_node *node;
fz_matrix ctm;
- fz_rect bbox;
+ fz_rect rect;
+ fz_bbox bbox;
int clipped = 0;
int tiled = 0;
+ int empty;
- if (!fz_is_infinite_bbox(bounds))
+ if (!fz_is_infinite_bbox(scissor))
{
/* add some fuzz at the edges, as especially glyph rects
* are sometimes not actually completely bounding the glyph */
- bounds.x0 -= 20; bounds.y0 -= 20;
- bounds.x1 += 20; bounds.y1 += 20;
+ scissor.x0 -= 20; scissor.y0 -= 20;
+ scissor.x1 += 20; scissor.y1 += 20;
}
for (node = list->first; node; node = node->next)
{
- fz_bbox rect = fz_round_rect(fz_transform_rect(top_ctm, node->rect));
+ /* cull objects to draw using a quick visibility test */
- /* never skip tiles */
- if (node->cmd == FZ_CMD_BEGIN_TILE) {
- tiled++;
- goto visible;
+ if (tiled || node->cmd == FZ_CMD_BEGIN_TILE || node->cmd == FZ_CMD_END_TILE)
+ {
+ empty = 0;
}
- if (node->cmd == FZ_CMD_END_TILE) {
- tiled--;
- goto visible;
+ else
+ {
+ bbox = fz_round_rect(fz_transform_rect(top_ctm, node->rect));
+ bbox = fz_intersect_bbox(bbox, scissor);
+ empty = fz_is_empty_bbox(bbox);
}
- if (tiled)
- goto visible;
- /* cull objects to draw using a quick visibility test */
- if (clipped || fz_is_empty_bbox(fz_intersect_bbox(rect, bounds)))
+ if (clipped || empty)
{
switch (node->cmd)
{
@@ -486,15 +486,15 @@ visible:
fz_pop_clip(dev);
break;
case FZ_CMD_BEGIN_MASK:
- bbox = fz_transform_rect(top_ctm, node->rect);
- fz_begin_mask(dev, bbox, node->flag, node->colorspace, node->color);
+ rect = fz_transform_rect(top_ctm, node->rect);
+ fz_begin_mask(dev, rect, node->flag, node->colorspace, node->color);
break;
case FZ_CMD_END_MASK:
fz_end_mask(dev);
break;
case FZ_CMD_BEGIN_GROUP:
- bbox = fz_transform_rect(top_ctm, node->rect);
- fz_begin_group(dev, bbox,
+ rect = fz_transform_rect(top_ctm, node->rect);
+ fz_begin_group(dev, rect,
node->flag & ISOLATED, node->flag & KNOCKOUT,
node->item.blendmode, node->alpha);
break;
@@ -502,14 +502,16 @@ visible:
fz_end_group(dev);
break;
case FZ_CMD_BEGIN_TILE:
- bbox.x0 = node->color[2];
- bbox.y0 = node->color[3];
- bbox.x1 = node->color[4];
- bbox.y1 = node->color[5];
- fz_begin_tile(dev, node->rect, bbox,
+ tiled++;
+ rect.x0 = node->color[2];
+ rect.y0 = node->color[3];
+ rect.x1 = node->color[4];
+ rect.y1 = node->color[5];
+ fz_begin_tile(dev, node->rect, rect,
node->color[0], node->color[1], ctm);
break;
case FZ_CMD_END_TILE:
+ tiled--;
fz_end_tile(dev);
break;
}