[GTK] Consider transformation scale in GC.drawImage(image, x, y) #2919#3201
[GTK] Consider transformation scale in GC.drawImage(image, x, y) #2919#3201ptziegler merged 1 commit intoeclipse-platform:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates GTK GC#drawImage(...) so that when a Transform with scaling is applied, SWT requests an image rendered at the effective (scaled) destination size, improving best-fit selection for multi-resolution/SVG images (parity with the earlier Windows change).
Changes:
- Add a helper to compute an effective transformation scale from the current GC transform.
- Delegate
drawImage(image, x, y)to the width/height overload when a non-identity transform is active. - Multiply destination dimensions by the transformation scale before calling
Image#executeOnImageAtSize(...).
There was a problem hiding this comment.
The change looks sound to me. The comment regarding tests made by Copilot seems valid. There are two test cases in Test...GC, one is even missing an @Test annotation, so we could take the chance of properly enabling it. The other is @EnabledOnOS(OS.WINDOWS), which we now may change to @DisabledOnOS(OS.MAC) until we have applied the same change to macOS.
f3ee03c to
84bb450
Compare
HeikoKlare
left a comment
There was a problem hiding this comment.
Looks great, thank you. I consider this ready to be merged.
…lipse-platform#2919 With e97143c, support was added on Windows to take the Transform scaling into consideration when calling drawImage(image, x, y). Especially when used in combination with an SVG-based image, this leads to better results as the best-fitting image representation is used for painting, rather than relying on interpolation. This change follows the same logic for Cocoa/macOS, equivalent to what has already been done for Windows and is being done for GTK in eclipse-platform#3201. When a Transform is active on the GC, the call to drawImage(image, x, y) is delegated to drawImage(image, x, y, w, h), using the image's natural bounds as the destination size. Within that method, the destination dimensions are multiplied by the effective transformation scale before being passed to executeOnImageAtSizeBestFittingSize(), so that the higher-resolution image representation is selected and rendered at its full quality rather than being upscaled from a lower-resolution variant. The effective scale is derived from the active NSAffineTransform via Math.hypot() on the matrix columns, which correctly handles transforms that combine scaling with rotation. The existing test test_drawImageLorg_eclipse_swt_graphics_ImageIIII_withTransform, which was previously restricted to Windows only, is now enabled on all platforms (the @EnabledOnOs(OS.WINDOWS) guard and its now-unused imports are removed). The previously un-annotated companion test test_drawImageLorg_eclipse_swt_graphics_ImageIIII_withTransform_zeroTargetSize receives the missing @test annotation so it is actually executed. Contributes to eclipse-platform#2919
…pse-platform#2919 With e97143c, support was added on Windows to take the `Transform` scaling into consideration when calling `drawImage(image,x,y)`. Especially when used in combination with an SVG-based image, this leads to better results as the best-fitting image is used for painting, rather than relying on interpolation. This change follows a similar logic to what has been done for Windows; The call to `drawImage(image,x,y)` is delegated to `drawImage(x,y,w,h)` when a `Transform` has been set. Within this method, the width and height of the image are used as size after being multiplied by the transformation scale. Contributes to eclipse-platform#2919

With e97143c, support was added on Windows to take the
Transformscaling into consideration when callingdrawImage(image,x,y). Especially when used in combination with an SVG-based image, this leads to better results as the best-fitting image is used for painting, rather than relying on interpolation.This change follows a similar logic to what has been done for Windows; The call to
drawImage(image,x,y)is delegated todrawImage(x,y,w,h)when aTransformhas been set. Within this method, the width and height of the image are used as size after being multiplied by the transformation scale.Contributes to
#2919