diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-04-07 23:41:40 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-04-07 23:41:40 +0200 |
commit | 0dbfc980afc9d318a1fcb68994621006240ce205 (patch) | |
tree | 6a42f3edc99b1bb2dd49a8eb7ea947ad2b889487 | |
parent | f5d521e184ad64893f4fc49cc867da53eff3b2b1 (diff) | |
download | mupdf-0dbfc980afc9d318a1fcb68994621006240ce205.tar.xz |
Fix bug with gsave/grestore nesting when running tiled patterns.
-rw-r--r-- | fitz/dev_list.c | 22 | ||||
-rw-r--r-- | pdf/pdf_build.c | 2 |
2 files changed, 15 insertions, 9 deletions
diff --git a/fitz/dev_list.c b/fitz/dev_list.c index 0cc5e992..71d938d0 100644 --- a/fitz/dev_list.c +++ b/fitz/dev_list.c @@ -375,6 +375,7 @@ void fz_execute_display_list(fz_display_list *list, fz_device *dev, fz_matrix top_ctm, fz_bbox bounds) { fz_display_node *node; + fz_matrix ctm; fz_rect bbox; int clipped = 0; int tiled = 0; @@ -389,24 +390,25 @@ fz_execute_display_list(fz_display_list *list, fz_device *dev, fz_matrix top_ctm for (node = list->first; node; node = node->next) { - fz_matrix ctm = fz_concat(node->ctm, top_ctm); - fz_rect rect = fz_transform_rect(top_ctm, node->rect); + fz_bbox rect = fz_round_rect(fz_transform_rect(top_ctm, node->rect)); /* never skip tiles */ + if (node->cmd == FZ_CMD_BEGIN_TILE) { + tiled++; + goto visible; + } + if (node->cmd == FZ_CMD_END_TILE) { + tiled--; + goto visible; + } if (tiled) goto visible; /* cull objects to draw using a quick visibility test */ - if (clipped || fz_is_empty_bbox(fz_intersect_bbox(fz_round_rect(rect), bounds))) + if (clipped || fz_is_empty_bbox(fz_intersect_bbox(rect, bounds))) { switch (node->cmd) { - case FZ_CMD_BEGIN_TILE: - tiled++; - goto visible; - case FZ_CMD_END_TILE: - tiled--; - goto visible; case FZ_CMD_CLIP_PATH: case FZ_CMD_CLIP_STROKE_PATH: case FZ_CMD_CLIP_TEXT: @@ -432,6 +434,8 @@ fz_execute_display_list(fz_display_list *list, fz_device *dev, fz_matrix top_ctm } visible: + ctm = fz_concat(node->ctm, top_ctm); + switch (node->cmd) { case FZ_CMD_FILL_PATH: diff --git a/pdf/pdf_build.c b/pdf/pdf_build.c index 7218e135..8c043107 100644 --- a/pdf/pdf_build.c +++ b/pdf/pdf_build.c @@ -214,9 +214,11 @@ pdf_show_pattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what) fz_begin_tile(csi->dev, area, pat->bbox, pat->xstep, pat->ystep, ptm); gstate->ctm = ptm; csi->top_ctm = gstate->ctm; + pdf_gsave(csi); error = pdf_run_csi_buffer(csi, pat->resources, pat->contents); if (error) fz_catch(error, "cannot render pattern tile"); + pdf_grestore(csi); while (oldtop < csi->gtop) pdf_grestore(csi); fz_end_tile(csi->dev); |