[
https://issues.apache.org/jira/browse/PDFBOX-2126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14049857#comment-14049857
]
Petr Slaby edited comment on PDFBOX-2126 at 7/2/14 12:19 PM:
-------------------------------------------------------------
... or save and restore lastClip as shown in the attached ClipPath.2.patch. The
patch also resets the lastClip before calling processSubStream in annotation
processing. This is necessary e.g. for the attached example_014.pdf containing
an AcroForm.
was (Author: pslabycz):
... or save and restore lastClip as shown in the attached ClipPath.2.patch. The
patch also resets the lastClip before in processSubStream when painting
annotation. This is necessary e.g. for the attached example_014.pdf containing
an AcroForm.
> Optimize clipping
> -----------------
>
> Key: PDFBOX-2126
> URL: https://issues.apache.org/jira/browse/PDFBOX-2126
> Project: PDFBox
> Issue Type: Improvement
> Components: Rendering
> Affects Versions: 2.0.0
> Reporter: Petr Slaby
> Attachments: ClipPath.1.patch, ClipPath.2.patch, ClipPath.patch,
> PDFBOX-1772.pdf, PDFBOX-1772.pdf-1-bad.png, example_010.pdf, example_014.pdf,
> pdfbox-1772.pdf-1-good.png, screenshot.png
>
>
> As already stated in a TODO comment in PageDrawer, the call of
> Graphics2D#setClip() is time and memory consuming. The attached patch
> optimizes clipping by calling Graphics2D#setClip() only if the clipping path
> has changed. The effect depends on the document, e.g. the attached one
> renders in 10.5s without the optimization and in 5.5 seconds in the optimized
> version.
> The clipping has to be re-applied whenever the transform in Graphics2D
> changes. This is not explicitly checked for, the implementation rather
> depends on the cached value being reset manually. Currently this is only
> needed at one place when processing annotations (AcroForms). Also, the
> implementation relies upon the clipping path object stored in PDGraphicsState
> to never change so that a comparison using == can be used. This works fine,
> but needs a bit of awareness in future changes. To make the design more
> clean, the clipping path could be made private to PDGraphcisState and thus
> really "immutable" from outside.
--
This message was sent by Atlassian JIRA
(v6.2#6252)