Skip to content
Merged
Show file tree
Hide file tree
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 @@ -1253,7 +1253,7 @@ private void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int src
}
return;
}
long imageHandle = Image.win32_getHandle(srcImage, imageZoom);
long imageHandle = srcImage.getHandle(imageZoom, data.nativeZoom);
switch (srcImage.type) {
case SWT.BITMAP:
drawBitmap(srcImage, imageHandle, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple);
Expand Down Expand Up @@ -4384,7 +4384,7 @@ private void init(Drawable drawable, GCData data, long hDC) {
}
Image image = data.image;
if (image != null) {
data.hNullBitmap = OS.SelectObject(hDC, Image.win32_getHandle(image, data.nativeZoom));
data.hNullBitmap = OS.SelectObject(hDC, image.getHandle(data.imageZoom, data.nativeZoom));
image.memGC = this;
}
int layout = data.layout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public final class GCData {
public float lineMiterLimit = 10;
public int alpha = 0xFF;
public int nativeZoom;
int imageZoom;

public Image image;
public PAINTSTRUCT ps;
Expand All @@ -67,6 +68,7 @@ void copyTo(GCData originalData) {
originalData.font = font;
originalData.nativeZoom = nativeZoom;
originalData.image = image;
originalData.imageZoom = imageZoom;
originalData.ps = ps;
originalData.layout = layout;
originalData.hwnd = hwnd;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -809,10 +809,15 @@ private ImageHandle getImageMetadata(ZoomContext zoomContext) {
* @noreference This method is not intended to be referenced by clients.
*/
public static long win32_getHandle (Image image, int zoom) {
if (image.isDisposed()) {
return image.getHandle(zoom, zoom);
}

long getHandle (int targetZoom, int nativeZoom) {
if (isDisposed()) {
return 0L;
}
return image.getImageMetadata(new ZoomContext(zoom)).handle;
ZoomContext zoomContext = imageProvider.getFittingZoomContext(targetZoom, nativeZoom);
return getImageMetadata(zoomContext).handle;
}

/**
Expand Down Expand Up @@ -1752,6 +1757,7 @@ private long configureGC(GCData data, ZoomContext zoomContext) {
}
data.device = device;
data.nativeZoom = zoomContext.nativeZoom();
data.imageZoom = zoomContext.targetZoom();
data.image = this;
data.font = SWTFontProvider.getSystemFont(device, zoomContext.nativeZoom());
}
Expand Down Expand Up @@ -1913,6 +1919,10 @@ private abstract class AbstractImageProviderWrapper {

protected abstract Rectangle getBounds(int zoom);

protected ZoomContext getFittingZoomContext(int targetZoom, int nativeZoom) {
return new ZoomContext(targetZoom);
}

protected long configureGCData(GCData data) {
return configureGC(data, new ZoomContext(100));
}
Expand Down Expand Up @@ -2138,14 +2148,22 @@ private class PlainImageProviderWrapper extends AbstractImageProviderWrapper {
type = SWT.BITMAP;
}

@Override
protected ZoomContext getFittingZoomContext(int targetZoom, int nativeZoom) {
if (memGC != null) {
return new ZoomContext(targetZoom, nativeZoom);
}
return super.getFittingZoomContext(targetZoom, nativeZoom);
}

@Override
public Collection<Integer> getPreservedZoomLevels() {
return Collections.singleton(baseZoom);
}

@Override
protected long configureGCData(GCData data) {
return configureGC(data, new ZoomContext(DPIUtil.getDeviceZoom()));
return configureGC(data, new ZoomContext(DPIUtil.getDeviceZoom(), DPIUtil.getNativeDeviceZoom()));
}

@Override
Expand Down Expand Up @@ -2577,6 +2595,11 @@ private class ImageGcDrawerWrapper extends DynamicImageProviderWrapper {
this.height = height;
}

@Override
protected ZoomContext getFittingZoomContext(int targetZoom, int nativeZoom) {
return new ZoomContext(targetZoom, nativeZoom);
}

@Override
protected Rectangle getBounds(int zoom) {
Rectangle rectangle = new Rectangle(0, 0, width, height);
Expand Down
Loading