Skip to content

Commit cb53cbc

Browse files
committed
[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 48a2524 commit cb53cbc

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
@@ -1707,6 +1707,10 @@ private ImageHandle init(ImageData i, int zoom) {
17071707
*/
17081708
@Override
17091709
public long internal_new_GC (GCData data) {
1710+
return configureGC(data, 100);
1711+
}
1712+
1713+
private long configureGC(GCData data, int zoom) {
17101714
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
17111715
/*
17121716
* Create a new GC that can draw into the image.
@@ -1731,9 +1735,9 @@ public long internal_new_GC (GCData data) {
17311735
data.style |= SWT.LEFT_TO_RIGHT;
17321736
}
17331737
data.device = device;
1734-
data.nativeZoom = initialNativeZoom;
1738+
data.nativeZoom = zoom;
17351739
data.image = this;
1736-
data.font = SWTFontProvider.getSystemFont(device, initialNativeZoom);
1740+
data.font = SWTFontProvider.getSystemFont(device, zoom);
17371741
}
17381742
return imageDC;
17391743
}
@@ -2506,7 +2510,7 @@ protected ImageHandle newImageHandle(int zoom) {
25062510
} else {
25072511
image = new Image(device, width, height, zoom);
25082512
}
2509-
GC gc = new GC(image, gcStyle);
2513+
GC gc = new GC(new DrawableWrapper(image, zoom), gcStyle);
25102514
try {
25112515
gc.data.nativeZoom = zoom;
25122516
drawer.drawOn(gc, width, height);
@@ -2520,6 +2524,26 @@ protected ImageHandle newImageHandle(int zoom) {
25202524
}
25212525
}
25222526

2527+
private class DrawableWrapper implements Drawable {
2528+
private final Image image;
2529+
private final int zoom;
2530+
2531+
public DrawableWrapper(Image image, int zoom) {
2532+
this.image = image;
2533+
this.zoom = zoom;
2534+
}
2535+
2536+
@Override
2537+
public long internal_new_GC(GCData data) {
2538+
return this.image.configureGC(data, zoom);
2539+
}
2540+
2541+
@Override
2542+
public void internal_dispose_GC(long handle, GCData data) {
2543+
this.image.internal_dispose_GC(handle, data);
2544+
}
2545+
}
2546+
25232547
@Override
25242548
Object getProvider() {
25252549
return drawer;

0 commit comments

Comments
 (0)