diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2022-02-07 16:30:23 +0000 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2022-02-07 19:55:23 +0000 |
commit | d3b0f42bba612880f65d7e1446ca6a8757340bf3 (patch) | |
tree | ed389a4202415a3bbdde3eaaa5aa7392f9a05355 /pdf/pdf_image.c | |
parent | 3ee68db403b270b0a6534233f0579af55d094d2d (diff) | |
download | ghostpdl-d3b0f42bba612880f65d7e1446ca6a8757340bf3.tar.gz |
PDFI: Optimise transparency setup/teardown.
For various operations (text/shadings/images), we currently find
a bbox (which involves a gsave/grestore pair) regardless of whether
we actually need the bbox.
Here we add some simple code to short circuit this work if transparency
in use. The big win here is with text.
Diffstat (limited to 'pdf/pdf_image.c')
-rw-r--r-- | pdf/pdf_image.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c index 19bc85e62..93651c5b1 100644 --- a/pdf/pdf_image.c +++ b/pdf/pdf_image.c @@ -1599,6 +1599,7 @@ pdfi_do_image(pdf_context *ctx, pdf_dict *page_dict, pdf_dict *stream_dict, pdf_ gs_offset_t stream_offset; float save_strokeconstantalpha = 0.0f, save_fillconstantalpha = 0.0f; pdf_string *EODString = NULL; + int trans_required; #if DEBUG_IMAGES dbgmprintf(ctx->memory, "pdfi_do_image BEGIN\n"); @@ -2034,9 +2035,13 @@ pdfi_do_image(pdf_context *ctx, pdf_dict *page_dict, pdf_dict *stream_dict, pdf_ } } - code = pdfi_image_setup_trans(ctx, &trans_state); - if (code < 0) - goto cleanupExit; + trans_required = pdfi_trans_required(ctx); + + if (trans_required) { + code = pdfi_image_setup_trans(ctx, &trans_state); + if (code < 0) + goto cleanupExit; + } /* Render the image */ code = pdfi_render_image(ctx, pim, new_stream, @@ -2047,9 +2052,11 @@ pdfi_do_image(pdf_context *ctx, pdf_dict *page_dict, pdf_dict *stream_dict, pdf_ dmprintf1(ctx->memory, "WARNING: pdfi_do_image: error %d from pdfi_render_image\n", code); } - code1 = pdfi_trans_teardown(ctx, &trans_state); - if (code == 0) - code = code1; + if (trans_required) { + code1 = pdfi_trans_teardown(ctx, &trans_state); + if (code == 0) + code = code1; + } cleanupExit: if (code < 0) |