[GTK] Restore the surface device scale after fillGradientRectangle - #3589
Merged
vogella merged 1 commit intoSep 15, 2026
Merged
Conversation
fillGradientRectangle() set the device scale of the target surface to the device zoom and left it there. For a surface that has another scale, like a 1:1 image at 200% zoom, everything drawn onto it afterwards came out scaled, for example a widget print into an image showed its content at twice the size once a gradient had been painted. The previous device scale is now restored when the gradient is done. Assisted-by: multiple AI agents and layers of automated tooling 🤖
There was a problem hiding this comment.
🟡 Changes recommended
The new test helpers can leak native GC resources when drawing operations fail.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Restores GTK Cairo surface scaling after gradient fills and adds regression coverage.
Changes:
- Saves and restores the target surface’s device scale.
- Tests drawing before and after a gradient at 200% zoom.
File summaries
| File | Description |
|---|---|
GC.java |
Restores Cairo surface scale after gradient rendering. |
Test_org_eclipse_swt_graphics_GC.java |
Adds scale-restoration regression coverage. |
Review details
Suppressed comments (1)
tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java:732
- If any gradient setup or drawing call throws,
gradientGC.dispose()is skipped, leaving a native GC attached to the image. Guarantee cleanup withtry/finally, as this helper is exercised precisely on rendering failures.
GC gradientGC = new GC(image);
gradientGC.setForeground(display.getSystemColor(SWT.COLOR_BLUE));
gradientGC.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
gradientGC.fillGradientRectangle(0, 0, 2, 2, false);
gradientGC.dispose();
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
vogella
added a commit
to vogellacompany/eclipse-mcp-server
that referenced
this pull request
Sep 14, 2026
On GTK, GC.fillGradientRectangle sets the device scale of its target surface and never restores it. A widget print into a 1:1 image scaled by a Transform therefore came out doubled from the first gradient on, so shell and includeToolbar captures in the Light theme, whose tabs draw gradients, showed every part stack at twice its size. Printing into an image built from ImageData, whose surface already has the device scale, makes that write a no-op on IDEs without the upstream fix (eclipse-platform/eclipse.platform.swt#3589). Assisted-by: multiple AI agents and layers of automated tooling 🤖
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On GTK,
GC.fillGradientRectangle()set the device scale of the target surface to the device zoom and never restored it. On screen that is harmless, but on a surface with a different scale, such as a 1:1 image at 200% zoom, everything drawn afterwards came out scaled; a widget print into an image showed its content at twice the size once a CTabFolder had painted a gradient. The previous device scale is now restored after the gradient is filled. The new GC test draws a gradient and a rectangle in both orders at 200% zoom and fails without the fix; the full GC test class passes headless on Linux, while Windows and macOS are unaffected by the change.