vectorgraphics2d icon indicating copy to clipboard operation
vectorgraphics2d copied to clipboard

Partial fix for issue #68: Managing GraphicsState with a Stack is unsafe

Open davideby opened this issue 7 years ago • 0 comments

This is a partial fix. The idea here is similar to what was discussed in that Issue thread. We associate every Command with a "parent" CreateCommand linking to the VectorGraphics2D in which that command was emitted. Then, during rendering we can link to a clean GraphicsState to track the modifications made by those Commands only so rendering "within" each CreateCommand can happen independently.

Arguably it would be better for every Command to accept its parent via a constructor arg, but that would have made this PR big and unwieldy and harder to review. So this was kind of a way to introduce the concept in a more controlled way since it affects fewer call sites.

Also, this only fixes SVG and PDF but not EPS as that doesn't use the Stack concept directly. I'm not quite sure how to fix this for EPS, so hopefully someone else can pick it up from there.

Unfortunately, we're still seeing further bugs and their cause is not clear. Our project team has decided to stick with Batik after all since their latest release works with Java 9+ so I can't pursue this any more for now. It was really close but we just didn't have the resources to go further.

We may have to pick this up again for a different project, though, so I may be back with more fixes.

Thanks, hope this helps!

davideby avatar Jun 08 '18 00:06 davideby