-
Notifications
You must be signed in to change notification settings - Fork 542
Proof of concept drawing context for WritableImage #1969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
👋 Welcome back jhendrikx! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
5660c3b to
9a50c68
Compare
|
@hjohn Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
| IntBuffer buf = IntBuffer.allocate(w * h); | ||
| return com.sun.prism.Image.fromIntArgbPreData(buf, w, h); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be no problem to change (an image heavy application still runs absolutely fine), but it is kind of a global change. If there are issues with this, we could make a specific method for writable images to use so we always get an int[] buffer that the software renderer expects.
As it is now, the renderer is writing directly into the underlying image storage, without any copies being made (which is nice and efficient).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious why the byte buffer was chosen initially.
Will IntBuffer be better on every platform?
Also, w * h might be negative if the product is greater than ~2B, though it will result in an IllegalArgumentException with a cryptic "capacity expected to be negative" message.
|
/csr |
|
@andy-goryachev-oracle has indicated that a compatibility and specification (CSR) request is needed for this pull request. @hjohn this pull request must refer to an issue in JBS to be able to link it to a CSR request. To refer this pull request to an issue in JBS, please update the title of this pull request to just the issue ID. |
|
@andy-goryachev-oracle |
|
This is interesting, similar to Questions:
|
See my mailinglist answer, but in short, there are cases where
I think I missed a nuance here in my mailinglist reply. I think the software renderer will always give the same results, regardless of platform (interesting for certain use cases I suppose, and perhaps for testing as well). It will almost certainly differ however from GPU renderings of the same operations, but for supported operations it may be hard to distinguish what was GPU and what was CPU rendered. |
https://mail.openjdk.org/pipermail/openjfx-dev/2025-November/057463.html (for reference, it's a good answer) |
This PR adds a
getDrawingContextmethod toWritableImage, which works similar toCanvas::getGraphicsContextand shares the same signatures. Key features include:strokeRect,fillRect,strokeOval,fillOval,strokeArc,fillArc,strokePolyline,fillPolygon, etc.lineWidth,lineCap,lineJoin,miterLimit,fillRule,strokeandfillpaints.globalAlphaandglobalBlendMode.Imageinstances with scaling and source/destination rectangles.This feature enables direct software rendering to
WritableImagewithout requiring aCanvas+ snapshot.Additional notes:
Piscesrenderer.Example usage:
See the sample program
RandomShapesDemoto see aWritableImageandCanvasside by side performing the same operations:Progress
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1969/head:pull/1969$ git checkout pull/1969Update a local copy of the PR:
$ git checkout pull/1969$ git pull https://git.openjdk.org/jfx.git pull/1969/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1969View PR using the GUI difftool:
$ git pr show -t 1969Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1969.diff