Skip to content

Commit f10721a

Browse files
akoch-yattaHeikoKlare
authored andcommitted
[win32] Improve GC init for ImageGcDrawer
This commits wraps the GC initialization for the ImageGcDrawer to directly pass the zoom from the wrapper when the GC is initialized. In all other cases the GC will be initialized with 100 zoom.
1 parent cb6e7a6 commit f10721a

File tree

1 file changed

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

1 file changed

+27
-3
lines changed

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

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,10 @@ private ImageHandle init(ImageData i, int zoom) {
17191719
*/
17201720
@Override
17211721
public long internal_new_GC (GCData data) {
1722+
return configureGC(data, 100);
1723+
}
1724+
1725+
private long configureGC(GCData data, int zoom) {
17221726
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
17231727
/*
17241728
* Create a new GC that can draw into the image.
@@ -1743,9 +1747,9 @@ public long internal_new_GC (GCData data) {
17431747
data.style |= SWT.LEFT_TO_RIGHT;
17441748
}
17451749
data.device = device;
1746-
data.nativeZoom = initialNativeZoom;
1750+
data.nativeZoom = zoom;
17471751
data.image = this;
1748-
data.font = SWTFontProvider.getSystemFont(device, initialNativeZoom);
1752+
data.font = SWTFontProvider.getSystemFont(device, zoom);
17491753
}
17501754
return imageDC;
17511755
}
@@ -2530,7 +2534,7 @@ protected ImageHandle newImageHandle(int zoom) {
25302534
} else {
25312535
image = new Image(device, width, height, zoom);
25322536
}
2533-
GC gc = new GC(image, gcStyle);
2537+
GC gc = new GC(new DrawableWrapper(image, zoom), gcStyle);
25342538
try {
25352539
gc.data.nativeZoom = zoom;
25362540
drawer.drawOn(gc, width, height);
@@ -2544,6 +2548,26 @@ protected ImageHandle newImageHandle(int zoom) {
25442548
}
25452549
}
25462550

2551+
private class DrawableWrapper implements Drawable {
2552+
private final Image image;
2553+
private final int zoom;
2554+
2555+
public DrawableWrapper(Image image, int zoom) {
2556+
this.image = image;
2557+
this.zoom = zoom;
2558+
}
2559+
2560+
@Override
2561+
public long internal_new_GC(GCData data) {
2562+
return this.image.configureGC(data, zoom);
2563+
}
2564+
2565+
@Override
2566+
public void internal_dispose_GC(long handle, GCData data) {
2567+
this.image.internal_dispose_GC(handle, data);
2568+
}
2569+
}
2570+
25472571
@Override
25482572
Object getProvider() {
25492573
return drawer;

0 commit comments

Comments
 (0)