Skip to content

Commit 812289e

Browse files
HeikoKlareakoch-yatta
authored andcommitted
[Win32] Remove obsolete zoom parameter for refreshing GC handle
When refreshing a GC with another zoom, that zoom is unnecessarily duplicated in the DrawableWrapper of the Image and as a parameter of the refresh method of the GC. This refresh method than unnecessarily uses that zoom to initialize the GCData's native zoom with it, even though that's overwritten with the proper zoom by initializing the GC with the DrawableWrapper afterwards. This change removes the zoom duplication by removing the parameter in the refresh method of the GC. It removes the unnecessary assignment of the GCData's native zoom and moves the check for whether a refresh is necessary because of a zoom change from the GC to the image. In addition, it ensures that the memGC of an image is not accidentally set to null in case the memGC's zoom does already fit to the requested zoom.
1 parent 97855ad commit 812289e

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5833,15 +5833,12 @@ Point textExtentInPixels(String string, int flags) {
58335833
return new Point(rect.right, rect.bottom);
58345834
}
58355835

5836-
void refreshFor(Drawable drawable, int zoom) {
5836+
void refreshFor(Drawable drawable) {
58375837
if (drawable == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
5838-
if (zoom == getZoom()) {
5839-
return;
5840-
}
58415838
destroy();
58425839
GCData newData = new GCData();
58435840
originalData.copyTo(newData);
5844-
createGcHandle(drawable, newData, zoom);
5841+
createGcHandle(drawable, newData);
58455842
}
58465843

58475844
/**
@@ -5947,8 +5944,7 @@ private void storeAndApplyOperationForExistingHandle(Operation operation) {
59475944
operation.apply();
59485945
}
59495946

5950-
private void createGcHandle(Drawable drawable, GCData newData, int nativeZoom) {
5951-
newData.nativeZoom = nativeZoom;
5947+
private void createGcHandle(Drawable drawable, GCData newData) {
59525948
long newHandle = drawable.internal_new_GC(newData);
59535949
if (newHandle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
59545950
init(drawable, newData, newHandle);

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,10 +2177,12 @@ protected ImageHandle newImageHandle(int zoom) {
21772177
return createBaseHandle(zoom);
21782178
}
21792179
if (memGC != null) {
2180-
GC currentGC = memGC;
2181-
memGC = null;
2182-
createHandle(zoom);
2183-
currentGC.refreshFor(new DrawableWrapper(Image.this, zoom), zoom);
2180+
if (memGC.getZoom() != zoom) {
2181+
GC currentGC = memGC;
2182+
memGC = null;
2183+
createHandle(zoom);
2184+
currentGC.refreshFor(new DrawableWrapper(Image.this, zoom));
2185+
}
21842186
return zoomLevelToImageHandle.get(zoom);
21852187
}
21862188
return super.newImageHandle(zoom);

0 commit comments

Comments
 (0)