<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<p dir="auto" style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin-top: 0px; margin-bottom: 16px;">
<span style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 14px; color: rgb(31, 35, 40);">This is interesting, similar to
</span><span style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 11.9px; color: rgb(31, 35, 40); background-color: rgba(129, 139, 152, 0.12);"><code style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif;">BufferedImage.createGraphics()</code></span><span style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 14px; color: rgb(31, 35, 40);"> in
 AWT.</span></p>
<p dir="auto" style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin-top: 0px; margin-bottom: 16px;">
<span style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 14px; color: rgb(31, 35, 40);">Questions:</span></p>
<ul dir="auto" style="text-align: left; margin-top: 0px; margin-bottom: 0px; padding-left: 0px; background-color: rgb(255, 255, 255);">
<li style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 14px; color: rgb(31, 35, 40); margin-left: 24px;">
so this will <span style="font-weight: 600;" role="presentation">aways</span> be slower than Canvas?</li><li style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 14px; color: rgb(31, 35, 40); margin-top: 0.25em; margin-left: 24px;">
<div role="presentation">are the results going to be exactly the same, or there will be platform-specific differences in anti-aliasing etc?</div>
</li></ul>
<div dir="ltr" style="margin-left: 24px; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 14px; color: rgb(31, 35, 40);">
<br>
</div>
<div dir="ltr" style="margin-left: 0px; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 14px; color: rgb(31, 35, 40);">
Thanks!</div>
<div dir="ltr" style="margin-left: 0px; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 14px; color: rgb(31, 35, 40);">
-andy</div>
<div dir="ltr" style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div dir="ltr" style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="mail-editor-reference-message-container">
<div class="ms-outlook-mobile-reference-message skipProofing">
<meta name="Generator" content="Microsoft Exchange Server">
</div>
<div class="ms-outlook-mobile-reference-message skipProofing" style="text-align: left; padding: 3pt 0in 0in; border-width: 1pt medium medium; border-style: solid none none; border-color: rgb(181, 196, 223) currentcolor currentcolor; font-family: Aptos; font-size: 12pt; color: black;">
<b>From: </b>openjfx-dev <openjfx-dev-retn@openjdk.org> on behalf of John Hendrikx <john.hendrikx@gmail.com><br>
<b>Date: </b>Monday, November 10, 2025 at 06:29<br>
<b>To: </b>openjfx-dev@openjdk.org <openjfx-dev@openjdk.org><br>
<b>Subject: </b>Feedback requested: Proof of concept PR for extending WritableImage with its own "graphics context" to draw higher level primitives directly :)<br>
<br>
</div>
<div class="PlainText" style="font-size: 11pt;">I've extended WritableImage with a new method `getDrawingContext`.<br>
<br>
This method gives you a similar interface as Canvas's<br>
`getGraphicsContext`, minus some methods that I didn't implement yet<br>
(save/restore, font rendering, path rendering, line dashes).<br>
<br>
The method signatures are compatible, and we could have Canvas's<br>
GraphicsContext extend the DrawingContext interface.<br>
<br>
Using it is trivial:<br>
<br>
    WritableImage img = new WritableImage(400, 400);<br>
    DrawingContext ctx = img.getDrawingContext();<br>
    ctx.setFill(Color.RED);<br>
    ctx.fillRect(50, 50, 100, 100);<br>
<br>
Internally, this leverages the software renderer Pisces which is part of<br>
JavaFX.  This means that FX can still be fully GPU accelerated, while<br>
for drawing into a heap based WritableImage can be done with the CPU.  A<br>
big advantage here is that this makes it possible to draw complex images<br>
without having to snapshot them later if you need them to be images or<br>
having to resort to drawing all primitives yourself with just a PixelWriter.<br>
<br>
See this PR <a href="https://github.com/openjdk/jfx/pull/1969" data-outlook-id="163b037b-eae0-45a3-a4ba-59cf1804974f">
https://github.com/openjdk/jfx/pull/1969</a><br>
<br>
A screenshot and demo program is included.<br>
<br>
Feedback on the implementation is much appreciated.<br>
<br>
--John<br>
<br>
</div>
</div>
</body>
</html>