Skip to content

Commit 438fece

Browse files
HeikoKlareakoch-yatta
authored andcommitted
[Win32] Refresh image created by GC when drawn onto another drawable
With the improvements to use/generate the best-fitting handle when drawing an image on some other drawable, the previous refresh of the image when being drawn by a GC was implicitly removed. In consequence, the image-to-be-drawn is not refreshed anymore for a zoom for which no handle exists yet, even though there is a GC that could recreate the image for that zoom. With this change, in case a GC for the image-to-be-drawn is still active, the image will be requested for the zoom to be drawn at, such that the GC recreates a proper handle for that zoom.
1 parent 9c4d0a9 commit 438fece

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,10 @@ private void draw(Image image, int srcX, int srcY, int srcWidth, int srcHeight,
12151215
Rectangle fullImageBounds = image.getBounds();
12161216
Rectangle requestedFullImageBoundsPixels = Win32DPIUtils.pointToPixel(drawable, fullImageBounds, scaledImageZoomWithTransform);
12171217

1218+
// In case there is a memGC for the image, a handle at proper zoom can be created by reapplying the GC operation
1219+
if (image.memGC != null) {
1220+
image.getHandle(getZoom(), data.nativeZoom);
1221+
}
12181222
image.executeOnImageHandleAtBestFittingSize((tempHandle) -> {
12191223
Rectangle srcPixels = computeSourceRectangle(tempHandle, fullImageBounds, src);
12201224
drawImage(image, srcPixels.x, srcPixels.y, srcPixels.width, srcPixels.height, destPixels.x, destPixels.y, destPixels.width,
@@ -1291,6 +1295,10 @@ private void draw(Image image, int destX, int destY, int destWidth, int destHeig
12911295
Rectangle destPixelsScaledWithTransform = Win32DPIUtils.pointToPixel(drawable, new Rectangle(destX , destY, destWidth , destHeight),
12921296
scaledImageZoomWithTransform);
12931297

1298+
// In case there is a memGC for the image, a handle at proper zoom can be created by reapplying the GC operation
1299+
if (image.memGC != null) {
1300+
image.getHandle(getZoom(), data.nativeZoom);
1301+
}
12941302
image.executeOnImageHandleAtBestFittingSize(tempHandle -> {
12951303
drawImage(image, 0, 0, tempHandle.width(), tempHandle.height(), destPixels.x, destPixels.y,
12961304
destPixels.width, destPixels.height, false, tempHandle);

0 commit comments

Comments
 (0)