Skip to content

Commit 8d65ddc

Browse files
akoch-yattaHeikoKlare
authored andcommitted
[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.
1 parent 413426e commit 8d65ddc

File tree

1 file changed

+2
-5
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets

1 file changed

+2
-5
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,8 @@ public Canvas (Composite parent, int style) {
104104
*/
105105
public void drawBackground (GC gc, int x, int y, int width, int height) {
106106
int zoom = getZoom();
107-
x = DPIUtil.scaleUp(x, zoom);
108-
y = DPIUtil.scaleUp(y, zoom);
109-
width = DPIUtil.scaleUp(width, zoom);
110-
height = DPIUtil.scaleUp(height, zoom);
111-
drawBackgroundInPixels(gc, x, y, width, height, 0, 0);
107+
Rectangle rectangle = DPIUtil.scaleUp(new Rectangle(x, y, width, height), zoom);
108+
drawBackgroundInPixels(gc, rectangle.x, rectangle.y, rectangle.width, rectangle.height, 0, 0);
112109
}
113110

114111
/**

0 commit comments

Comments
 (0)