This PR adds a `getDrawingContext` method to `WritableImage`, which works 
similar to `Canvas::getGraphicsContext` and shares the same signatures. Key 
features include:

- **Shape rendering**: `strokeRect`, `fillRect`, `strokeOval`, `fillOval`, 
`strokeArc`, `fillArc`, `strokePolyline`, `fillPolygon`, etc.
- **Stroke and fill attributes**: `lineWidth`, `lineCap`, `lineJoin`, 
`miterLimit`, `fillRule`, `stroke` and `fill` paints.
- **Global graphics settings**: `globalAlpha` and `globalBlendMode`.
- **Image drawing**: draw other `Image` instances with scaling and 
source/destination rectangles.

This feature enables direct software rendering to `WritableImage` without 
requiring a `Canvas` + snapshot.

**Additional notes**:

- The implementation leverages the software `Pisces` renderer.
- This lays the groundwork for future support of text rendering and path 
operations.

**Example usage**:


WritableImage img = new WritableImage(400, 400);
DrawingContext ctx = img.getDrawingContext();
ctx.setFill(Color.RED);
ctx.fillRect(50, 50, 100, 100);


See the sample program `RandomShapesDemo` to see a `WritableImage` and `Canvas` 
side by side performing the same operations:

<img width="1249" height="741" alt="image" 
src="https://github.com/user-attachments/assets/4a0b9dcc-8f96-4faa-99cf-83c66d2c851e";
 />

Newer version:

<img width="1249" height="741" alt="image" 
src="https://github.com/user-attachments/assets/c0502620-3d02-4fbd-8c33-43bd5138b42c";
 />

---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

-------------

Commit messages:
 - Fix javadoc
 - Add support for line dashes and paths, and use DrawingContext interface
 - Add save/restore, text drawing, transforms, clips
 - Merge remote-tracking branch 'origin/master' into 
feature/writable-image-drawing
 - Proof of concept drawing context for WritableImage

Changes: https://git.openjdk.org/jfx/pull/1969/files
  Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1969&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8390915
  Stats: 6468 lines in 19 files changed: 5224 ins; 1131 del; 113 mod
  Patch: https://git.openjdk.org/jfx/pull/1969.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1969/head:pull/1969

PR: https://git.openjdk.org/jfx/pull/1969

Reply via email to