Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ public ImageData getImageData (int zoom) {
if (zoomLevelToImageHandle.containsKey(zoom)) {
return zoomLevelToImageHandle.get(zoom).getImageData();
}
return this.imageProvider.newImageData(new ZoomContext(zoom));
return this.imageProvider.newImageData(zoom);
}


Expand Down Expand Up @@ -2007,7 +2007,7 @@ public Collection<Integer> getPreservedZoomLevels() {

protected abstract ElementAtZoom<ImageData> loadImageData(int zoom);

abstract ImageData newImageData(ZoomContext zoomContext);
abstract ImageData newImageData(int zoom);

abstract AbstractImageProviderWrapper createCopy(Image image);

Expand Down Expand Up @@ -2068,8 +2068,8 @@ protected Rectangle getBounds(int zoom) {
}

@Override
ImageData newImageData(ZoomContext zoomContext) {
return getScaledImageData(zoomContext.targetZoom());
ImageData newImageData(int zoom) {
return getScaledImageData(zoom);
}

@Override
Expand All @@ -2095,18 +2095,18 @@ private abstract class ImageFromImageDataProviderWrapper extends AbstractImagePr
void initImage() {
// As the init call configured some Image attributes (e.g. type)
// it must be called
newImageData(new ZoomContext(100));
newImageData(100);
}

@Override
ImageData newImageData(ZoomContext zoomContext) {
ImageData newImageData(int zoom) {
Function<Integer, ImageData> imageDataRetrieval = zoomToRetrieve -> {
ImageHandle handle = initializeHandleFromSource(zoomContext);
ImageHandle handle = initializeHandleFromSource(new ZoomContext(zoom));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of consistency, shouldn't this anyway be ... ?

Suggested change
ImageHandle handle = initializeHandleFromSource(new ZoomContext(zoom));
ImageHandle handle = initializeHandleFromSource(new ZoomContext(zoomToRetrieve));

ImageData data = handle.getImageData();
handle.destroy();
return data;
};
return (ImageData) cachedImageData.computeIfAbsent(zoomContext.targetZoom(), imageDataRetrieval).clone();
return (ImageData) cachedImageData.computeIfAbsent(zoom, imageDataRetrieval).clone();
}

@Override
Expand Down Expand Up @@ -2270,15 +2270,15 @@ protected Rectangle getBounds(int zoom) {
}

@Override
ImageData newImageData(ZoomContext zoomContext) {
int targetZoom = zoomContext.targetZoom();
ImageData newImageData(int zoom) {
int targetZoom = zoom;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

targetZoom could be completely removed here

if (zoomLevelToImageHandle.isEmpty()) {
return createBaseHandle(targetZoom).getImageData();
}
// if a GC is initialized with an Image (memGC != null), the image data must not be resized, because it would
// be a destructive operation. Therefor, a new handle is created for the requested zoom
if (memGC != null) {
return newImageHandle(zoomContext).getImageData();
return newImageHandle(new ZoomContext(zoom)).getImageData();
}
return getScaledImageData(targetZoom);
}
Expand Down Expand Up @@ -2392,14 +2392,14 @@ Object getProvider() {
}

@Override
ImageData newImageData(ZoomContext zoomContext) {
ImageData newImageData(int zoom) {
Function<Integer, ImageData> imageDataRetrival = zoomToRetrieve -> {
ImageHandle handle = initializeHandleFromSource(zoomToRetrieve);
ImageData data = handle.getImageData();
handle.destroy();
return data;
};
return (ImageData) cachedImageData.computeIfAbsent(zoomContext.targetZoom(), imageDataRetrival).clone();
return (ImageData) cachedImageData.computeIfAbsent(zoom, imageDataRetrival).clone();
}

@Override
Expand Down Expand Up @@ -2432,7 +2432,7 @@ private class ImageFileNameProviderWrapper extends BaseImageProviderWrapper<Imag
super(provider, ImageFileNameProvider.class);
// Checks for the contract of the passed provider require
// checking for valid image data creation
newImageData(new ZoomContext(DPIUtil.getDeviceZoom()));
newImageData(DPIUtil.getDeviceZoom());
}

@Override
Expand Down Expand Up @@ -2735,8 +2735,8 @@ protected long configureGCData(GCData data) {
}

@Override
ImageData newImageData(ZoomContext zoomContext) {
return loadImageData(zoomContext.targetZoom).element();
ImageData newImageData(int zoom) {
return loadImageData(zoom).element();
}

@Override
Expand Down
Loading