Skip to content

[GTK] Restore the surface device scale after fillGradientRectangle - #3589

Merged
vogella merged 1 commit into
eclipse-platform:masterfrom
vogella:gtk-gradient-device-scale
Sep 15, 2026
Merged

vogella merged 1 commit into
eclipse-platform:masterfrom
vogella:gtk-gradient-device-scale

Conversation

@vogella

@vogella vogella commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

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.

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 🤖

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 with try/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 🤖
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

  212 files  ±0    212 suites  ±0   30m 14s ⏱️ + 2m 49s
4 954 tests +1  4 928 ✅ +1   26 💤 ±0  0 ❌ ±0 
7 157 runs  +6  6 977 ✅ +6  180 💤 ±0  0 ❌ ±0 

Results for commit 152dcba. ± Comparison against base commit af630a9.

@vogella
vogella merged commit 50449b7 into eclipse-platform:master Sep 15, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants