<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Feb 3, 2023, at 5:31 PM, Laurent Bourgès <<a href="mailto:bourges.laurent@gmail.com" class="">bourges.laurent@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="auto" class="">Hi,<div dir="auto" class=""><div dir="auto" class=""><br class=""></div><div dir="auto" class="">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:</div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">- int  getSaveCount ()</div><div dir="auto" class="">  Returns the number of saved states, each containing: SkMatrix and clip. </div><div dir="auto" class=""> </div><div dir="auto" class="">- void    restoreToCount (int saveCount)</div><div dir="auto" class="">  Restores state to SkMatrix and clip values when save(), returned saveCount. </div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">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).</div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">Moreover, clip(shape) + save/restore are really tricky to allows ensure clip is reset to previous state ...</div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">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 ?</div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">See SkijaGraphics2d implementation that saves / restore skCanvas clip using such index property:</div><div dir="auto" class=""><a href="https://github.com/jfree/skijagraphics2d/blob/main/src/main/java/org/jfree/skija/SkijaGraphics2D.java" class="">https://github.com/jfree/skijagraphics2d/blob/main/src/main/java/org/jfree/skija/SkijaGraphics2D.java</a><br class=""></div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">Cheers,</div><div dir="auto" class="">Laurent</div></div></div>
</div></blockquote></div><br class=""><div class=""><div class="">I’d love to see this.  I find keeping track of the state of clipping and getting it restored to a specific state can be painful. Swing let you clear the clip with setClip(null) which was definitely useful and I was somewhat surprised to see that I couldn’t do that in JavaFX.</div><div class=""><br class=""></div><div class="">Bruce</div></div></body></html>