Skip to content

Commit 4d45d2b

Browse files
committed
[win32] ImageDataProvider getBounds performance
This commit improves the performance of Image#getBounds if an ImageDataProvider is used and no matching handle exists yet. This only affects the windows implementation.
1 parent ce98326 commit 4d45d2b

File tree

1 file changed

+8
-2
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics

1 file changed

+8
-2
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2330,8 +2330,14 @@ private ImageHandle initializeHandleFromSource(int zoom) {
23302330

23312331
@Override
23322332
protected Rectangle getBounds(int zoom) {
2333-
ImageData imageData = getImageData(zoom);
2334-
return new Rectangle(0, 0, imageData.width, imageData.height);
2333+
if (cachedImageData.containsKey(zoom)) {
2334+
ImageData imageData = cachedImageData.get(zoom);
2335+
return new Rectangle(0, 0, imageData.width, imageData.height);
2336+
}
2337+
ElementAtZoom<ImageData> imageDataAtZoom = loadImageData(zoom);
2338+
ImageData imageData = imageDataAtZoom.element();
2339+
Rectangle currentSize = new Rectangle(0, 0, imageData.width, imageData.height);
2340+
return Win32DPIUtils.scaleBounds(currentSize, zoom, imageDataAtZoom.zoom());
23352341
}
23362342
}
23372343

0 commit comments

Comments
 (0)