Enhance javafx Canvas API
Laurent Bourgès
bourges.laurent at gmail.com
Fri Feb 3 22:31:03 UTC 2023
Hi,
While working with skia & jfree's skijaGraphics2D wrapper, I observed skia
offers nice methods in SkCanvas missing in javafx Canvas/GraphicsContext to
deal with save/restore state:
- int getSaveCount ()
Returns the number of saved states, each containing: SkMatrix and clip.
- void restoreToCount (int saveCount)
Restores state to SkMatrix and clip values when save(), returned
saveCount.
As javafx canvas also maintains s stack of saved states, such methods are
trivial to implement to allow resetting completely the canvas state by
restoreToCount(0).
Moreover, clip(shape) + save/restore are really tricky to allows ensure
clip is reset to previous state ...
Would you agree to add such methods to have more predictive behaviour than
counting all save() calls to ensure to call restore() the same number of
times to reset the canvas to its initial state ?
See SkijaGraphics2d implementation that saves / restore skCanvas clip using
such index property:
https://github.com/jfree/skijagraphics2d/blob/main/src/main/java/org/jfree/skija/SkijaGraphics2D.java
Cheers,
Laurent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20230203/be3757c1/attachment-0001.htm>
More information about the openjfx-dev
mailing list