Skip to content

Commit 1fe5903

Browse files
committed
[Win32] Inline getImageMetadata method in Image
The method getImageMetadata() has a misleading name. It only has two callers of which one even leads to a cyclic call between a concrete provider class, the outer image class and the provider class again. That caller also just needs to gets an image handle and not create it at all. This change thus inlines the method and simplified the according calls.
1 parent dc9ed48 commit 1fe5903

File tree

1 file changed

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

1 file changed

+3
-8
lines changed

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -911,12 +911,6 @@ private ImageData applyGrayImageData(ImageData data, int pHeight, int pWidth) {
911911
return newData;
912912
}
913913

914-
private InternalImageHandle getImageMetadata(ZoomContext zoomContext) {
915-
int targetZoom = zoomContext.targetZoom();
916-
return imageHandleManager.getOrCreate(targetZoom, () -> imageProvider.newImageHandle(zoomContext));
917-
}
918-
919-
920914
/**
921915
* <b>IMPORTANT:</b> This method is not part of the public
922916
* API for Image. It is marked public only so that it
@@ -942,7 +936,7 @@ ImageHandle getHandle (int targetZoom, int nativeZoom) {
942936
return null;
943937
}
944938
ZoomContext zoomContext = imageProvider.getFittingZoomContext(targetZoom, nativeZoom);
945-
return getImageMetadata(zoomContext);
939+
return imageHandleManager.getOrCreate(targetZoom, () -> imageProvider.newImageHandle(zoomContext));
946940
}
947941

948942
void executeOnImageHandleAtBestFittingSize(Consumer<ImageHandle> handleAtSizeConsumer, int widthHint, int heightHint) {
@@ -2073,7 +2067,8 @@ protected boolean isPersistentImageHandleRequriedForImageData() {
20732067
ElementAtZoom<ImageData> getClosestAvailableImageData(int zoom) {
20742068
TreeSet<Integer> availableZooms = new TreeSet<>(imageHandleManager.getAllZooms());
20752069
int closestZoom = Optional.ofNullable(availableZooms.higher(zoom)).orElse(availableZooms.lower(zoom));
2076-
return new ElementAtZoom<>(getImageMetadata(new ZoomContext(closestZoom)).getImageData(), closestZoom);
2070+
ImageData imageData = imageHandleManager.get(closestZoom).getImageData();
2071+
return new ElementAtZoom<>(imageData, closestZoom);
20772072
}
20782073

20792074
protected Optional<ImageData> loadImageDataAtExactSize(int width, int height) {

0 commit comments

Comments
 (0)