<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
This seems like a good enhancement to me. I might suggest the
following naming for the restore method:<br>
<br>
void restore(int index)<br>
<br>
Would it be useful to other app developers?<br>
<br>
-- Kevin<br>
<br>
<br>
<div class="moz-cite-prefix">On 2/12/2023 1:21 AM, Laurent Bourgès
wrote:<br>
</div>
<blockquote type="cite" cite="mid:CAKjRUT7ttDb7bA1ejzxEAnxxGNXerGbWWYg-oPGohVCkX9NLTg@mail.gmail.com">
<div dir="auto">Hi,
<div dir="auto"><br>
</div>
<div dir="auto">For jfree.FXGraphics2D, I implemented the
proposed approach in the new GCHandler:</div>
<div dir="auto"><a href="https://github.com/jfree/fxgraphics2d/blob/1994b9cb3a9bff93bf95100d398756d7f9f626c2/src/main/java/org/jfree/fx/GCStateHandler.java" moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/jfree/fxgraphics2d/blob/1994b9cb3a9bff93bf95100d398756d7f9f626c2/src/main/java/org/jfree/fx/GCStateHandler.java</a><br>
</div>
<div dir="auto"><br>
</div>
<div dir="auto">It boosts fxG2D performance & correctness.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Ideally, such methods getSavePoint(),
restoreToCount() should be added to GraphicsContext API...</div>
<div dir="auto"><br>
</div>
<div dir="auto">Cheers,</div>
<div dir="auto">Laurent</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">Le ven. 3 févr. 2023, 23:31,
Laurent Bourgès <<a href="mailto:bourges.laurent@gmail.com" moz-do-not-send="true" class="moz-txt-link-freetext">bourges.laurent@gmail.com</a>>
a écrit :<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="auto">Hi,
<div dir="auto">
<div dir="auto"><br>
</div>
<div dir="auto">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"><br>
</div>
<div dir="auto">- int getSaveCount ()</div>
<div dir="auto"> Returns the number of saved states, each
containing: SkMatrix and clip. </div>
<div dir="auto"> </div>
<div dir="auto">- void restoreToCount (int saveCount)</div>
<div dir="auto"> Restores state to SkMatrix and clip
values when save(), returned saveCount. </div>
<div dir="auto"><br>
</div>
<div dir="auto">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"><br>
</div>
<div dir="auto">Moreover, clip(shape) + save/restore are
really tricky to allows ensure clip is reset to previous
state ...</div>
<div dir="auto"><br>
</div>
<div dir="auto">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"><br>
</div>
<div dir="auto">See SkijaGraphics2d implementation that
saves / restore skCanvas clip using such index property:</div>
<div dir="auto"><a href="https://github.com/jfree/skijagraphics2d/blob/main/src/main/java/org/jfree/skija/SkijaGraphics2D.java" target="_blank" rel="noreferrer" moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/jfree/skijagraphics2d/blob/main/src/main/java/org/jfree/skija/SkijaGraphics2D.java</a><br>
</div>
<div dir="auto"><br>
</div>
<div dir="auto">Cheers,</div>
<div dir="auto">Laurent</div>
</div>
</div>
</blockquote>
</div>
</blockquote>
<br>
</body>
</html>