From a8d8084449517eae4bac681541abce16ad14b248 Mon Sep 17 00:00:00 2001 From: Andreas Koch Date: Fri, 24 Jan 2025 11:17:36 +0100 Subject: [PATCH] [win32] Scale up bounds as rectangle in canvas This commit adresses render artifacts visible in StyledText with monitor-specific scaling enabled e.g. on 175%. Reason is that scaling up all attributes of bounds separately can lead to rounding errors e.g. between y and height (one being scaled up, the other one not). Scaling them together as a rectangle solves this limitation. --- .../Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java index 21dee67cad3..b3b285151d0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java @@ -104,11 +104,8 @@ public Canvas (Composite parent, int style) { */ public void drawBackground (GC gc, int x, int y, int width, int height) { int zoom = getZoom(); - x = DPIUtil.scaleUp(x, zoom); - y = DPIUtil.scaleUp(y, zoom); - width = DPIUtil.scaleUp(width, zoom); - height = DPIUtil.scaleUp(height, zoom); - drawBackgroundInPixels(gc, x, y, width, height, 0, 0); + Rectangle rectangle = DPIUtil.scaleUp(new Rectangle(x, y, width, height), zoom); + drawBackgroundInPixels(gc, rectangle.x, rectangle.y, rectangle.width, rectangle.height, 0, 0); } /**