From 4d45d2b6558dc561c9ba5fa0fd5e929a49307dc7 Mon Sep 17 00:00:00 2001 From: Andreas Koch Date: Tue, 30 Sep 2025 14:17:11 +0200 Subject: [PATCH] [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. --- .../win32/org/eclipse/swt/graphics/Image.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java index 200dd55911d..e62df7904ab 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java @@ -2330,8 +2330,14 @@ private ImageHandle initializeHandleFromSource(int zoom) { @Override protected Rectangle getBounds(int zoom) { - ImageData imageData = getImageData(zoom); - return new Rectangle(0, 0, imageData.width, imageData.height); + if (cachedImageData.containsKey(zoom)) { + ImageData imageData = cachedImageData.get(zoom); + return new Rectangle(0, 0, imageData.width, imageData.height); + } + ElementAtZoom imageDataAtZoom = loadImageData(zoom); + ImageData imageData = imageDataAtZoom.element(); + Rectangle currentSize = new Rectangle(0, 0, imageData.width, imageData.height); + return Win32DPIUtils.scaleBounds(currentSize, zoom, imageDataAtZoom.zoom()); } }