diff options
author | Robin Watts <robin.watts@artifex.com> | 2011-12-16 17:36:18 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2011-12-16 17:36:18 +0000 |
commit | df5b15a77321cc3626d0907bd86a2445af379489 (patch) | |
tree | 98793fa1913b782151fcafa07b24bb8359fcce52 /pdf/pdf_interpret.c | |
parent | 2e8a58ecce2d509c891e774d7cd1145514328d00 (diff) | |
download | mupdf-df5b15a77321cc3626d0907bd86a2445af379489.tar.xz |
More memsqueezing fixes.
Diffstat (limited to 'pdf/pdf_interpret.c')
-rw-r--r-- | pdf/pdf_interpret.c | 150 |
1 files changed, 82 insertions, 68 deletions
diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c index 14d91d23..a6c1714d 100644 --- a/pdf/pdf_interpret.c +++ b/pdf/pdf_interpret.c @@ -431,88 +431,95 @@ pdf_show_path(pdf_csi *csi, int doclose, int dofill, int dostroke, int even_odd) path = csi->path; csi->path = fz_new_path(ctx); - if (doclose) - fz_closepath(ctx, path); + fz_try(ctx) + { + if (doclose) + fz_closepath(ctx, path); - if (dostroke) - bbox = fz_bound_path(path, &gstate->stroke_state, gstate->ctm); - else - bbox = fz_bound_path(path, NULL, gstate->ctm); + if (dostroke) + bbox = fz_bound_path(path, &gstate->stroke_state, gstate->ctm); + else + bbox = fz_bound_path(path, NULL, gstate->ctm); - if (csi->clip) - { - gstate->clip_depth++; - fz_clip_path(csi->dev, path, NULL, csi->clip_even_odd, gstate->ctm); - csi->clip = 0; - } + if (csi->clip) + { + gstate->clip_depth++; + fz_clip_path(csi->dev, path, NULL, csi->clip_even_odd, gstate->ctm); + csi->clip = 0; + } - if (csi->in_hidden_ocg > 0) - dostroke = dofill = 0; + if (csi->in_hidden_ocg > 0) + dostroke = dofill = 0; - if (dofill || dostroke) - pdf_begin_group(csi, bbox); + if (dofill || dostroke) + pdf_begin_group(csi, bbox); - if (dofill) - { - switch (gstate->fill.kind) + if (dofill) { - case PDF_MAT_NONE: - break; - case PDF_MAT_COLOR: - fz_fill_path(csi->dev, path, even_odd, gstate->ctm, - gstate->fill.colorspace, gstate->fill.v, gstate->fill.alpha); - break; - case PDF_MAT_PATTERN: - if (gstate->fill.pattern) + switch (gstate->fill.kind) { - fz_clip_path(csi->dev, path, NULL, even_odd, gstate->ctm); - pdf_show_pattern(csi, gstate->fill.pattern, bbox, PDF_FILL); - fz_pop_clip(csi->dev); - } - break; - case PDF_MAT_SHADE: - if (gstate->fill.shade) - { - fz_clip_path(csi->dev, path, NULL, even_odd, gstate->ctm); - fz_fill_shade(csi->dev, gstate->fill.shade, csi->top_ctm, gstate->fill.alpha); - fz_pop_clip(csi->dev); + case PDF_MAT_NONE: + break; + case PDF_MAT_COLOR: + fz_fill_path(csi->dev, path, even_odd, gstate->ctm, + gstate->fill.colorspace, gstate->fill.v, gstate->fill.alpha); + break; + case PDF_MAT_PATTERN: + if (gstate->fill.pattern) + { + fz_clip_path(csi->dev, path, NULL, even_odd, gstate->ctm); + pdf_show_pattern(csi, gstate->fill.pattern, bbox, PDF_FILL); + fz_pop_clip(csi->dev); + } + break; + case PDF_MAT_SHADE: + if (gstate->fill.shade) + { + fz_clip_path(csi->dev, path, NULL, even_odd, gstate->ctm); + fz_fill_shade(csi->dev, gstate->fill.shade, csi->top_ctm, gstate->fill.alpha); + fz_pop_clip(csi->dev); + } + break; } - break; } - } - if (dostroke) - { - switch (gstate->stroke.kind) + if (dostroke) { - case PDF_MAT_NONE: - break; - case PDF_MAT_COLOR: - fz_stroke_path(csi->dev, path, &gstate->stroke_state, gstate->ctm, - gstate->stroke.colorspace, gstate->stroke.v, gstate->stroke.alpha); - break; - case PDF_MAT_PATTERN: - if (gstate->stroke.pattern) - { - fz_clip_stroke_path(csi->dev, path, &bbox, &gstate->stroke_state, gstate->ctm); - pdf_show_pattern(csi, gstate->stroke.pattern, bbox, PDF_FILL); - fz_pop_clip(csi->dev); - } - break; - case PDF_MAT_SHADE: - if (gstate->stroke.shade) + switch (gstate->stroke.kind) { - fz_clip_stroke_path(csi->dev, path, &bbox, &gstate->stroke_state, gstate->ctm); - fz_fill_shade(csi->dev, gstate->stroke.shade, csi->top_ctm, gstate->stroke.alpha); - fz_pop_clip(csi->dev); + case PDF_MAT_NONE: + break; + case PDF_MAT_COLOR: + fz_stroke_path(csi->dev, path, &gstate->stroke_state, gstate->ctm, + gstate->stroke.colorspace, gstate->stroke.v, gstate->stroke.alpha); + break; + case PDF_MAT_PATTERN: + if (gstate->stroke.pattern) + { + fz_clip_stroke_path(csi->dev, path, &bbox, &gstate->stroke_state, gstate->ctm); + pdf_show_pattern(csi, gstate->stroke.pattern, bbox, PDF_FILL); + fz_pop_clip(csi->dev); + } + break; + case PDF_MAT_SHADE: + if (gstate->stroke.shade) + { + fz_clip_stroke_path(csi->dev, path, &bbox, &gstate->stroke_state, gstate->ctm); + fz_fill_shade(csi->dev, gstate->stroke.shade, csi->top_ctm, gstate->stroke.alpha); + fz_pop_clip(csi->dev); + } + break; } - break; } - } - - if (dofill || dostroke) - pdf_end_group(csi); + if (dofill || dostroke) + pdf_end_group(csi); + } + fz_catch(ctx) + { + fz_free_path(ctx, path); + fz_rethrow(ctx); + } fz_free_path(ctx, path); } @@ -975,7 +982,14 @@ pdf_grestore(pdf_csi *csi) gs = csi->gstate + csi->gtop; while (clip_depth > gs->clip_depth) { - fz_pop_clip(csi->dev); + fz_try(ctx) + { + fz_pop_clip(csi->dev); + } + fz_catch(ctx) + { + /* Silently swallow the problem */ + } clip_depth--; } } |