[OpenJDK 2D-Dev] RFR JDK-8184429: Path clipper added in Marlin2D & MarlinFX 0.8.0
bourges.laurent at gmail.com
Thu Aug 31 20:34:06 UTC 2017
I am answering your first message:
Area is overkill for this as it tries to find exact intersection points of
arbitrary geometry. You simply need something that will trace accurately
around the outside of a clip to get from an exit point back to an entry
point. That is a much simpler operation.
OK, I started such approach but as it skips segments on the left side, it
will not preserve crossing counts for the even-odd winding rule, I suppose.
The key point is to reduce the edges / crossings processed by the Renderer
in the left and right sides of the clip at every scanlines.
For example, it will be worth when rendering a large text as a transformed
shapes as many letter (closed paths) will be out the L/R sides...
Top/Bottom clipping in Renderer already ignores such edges (except for
Moreover I agree Marlin does not need a proper path clipper (intersections)
but just needs skipping useless segments like a path simplifier as I did in
Another case: you provided a Test class using a path made with 10000 line
segments on the left side. If it is converted by createStrokedShape(), then
the Renderer will again deal with thousands crossings and it will be slow
Also, I thought that the Renderer already did basic clipping along the
lines that you indicate. It does that on a per-segment basis, but all it
would take is a simple test at the top of quadTo() and curveTo() to
completely reject all curves that lie outside the fill region (and simply
shadow any part that is entirely to the left so that we maintain the proper
Agreed but closed subpaths can also be ignored on either left or right
sides like circles, letters...
What do you mean by shadow any part on the left ?
For the Even-odd filling rule, I think it needs exact segment intersections
on the left side, so I am focused on the Non-zero filling rule for now.
Finally I tried two approach:
- basic subpath outside test (derived from the ClosedPathDetector) to
ignore closed sub-paths outside of the clip.
- more general clipper that follows the path, detect enter/exit the clip
but it needs to insert/remove corner points. I am improving this latter
Thanks for your advices,
More information about the openjfx-dev