Commit 12dc3a1
committed
[macOS] Consider transformation scale in GC.drawImage(image, x, y) eclipse-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#29191 parent 0c0c064 commit 12dc3a1
2 files changed
Lines changed: 23 additions & 5 deletions
File tree
- bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics
- tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit
Lines changed: 23 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
284 | 297 | | |
285 | 298 | | |
286 | 299 | | |
| |||
1143 | 1156 | | |
1144 | 1157 | | |
1145 | 1158 | | |
1146 | | - | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
1147 | 1165 | | |
1148 | 1166 | | |
1149 | 1167 | | |
| |||
1238 | 1256 | | |
1239 | 1257 | | |
1240 | 1258 | | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
1241 | 1262 | | |
1242 | 1263 | | |
1243 | | - | |
| 1264 | + | |
1244 | 1265 | | |
1245 | 1266 | | |
1246 | 1267 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
63 | 61 | | |
64 | 62 | | |
65 | 63 | | |
| |||
395 | 393 | | |
396 | 394 | | |
397 | 395 | | |
398 | | - | |
399 | 396 | | |
400 | 397 | | |
401 | 398 | | |
| |||
0 commit comments