Skip to content

Commit 1f6ea6f

Browse files
Fix 2D GUI jitter on high DPI screens (#17461)
On high DPI screens, we can see fractional pixels in the logical (CSS) pixel space. For example, consider a 150x150 pixel screen at 150% scaling - the logical pixel space will be 100x100. Note that pointer events happen at the granularity of the physical display, but the position is in the logical space, so the mouse moves by 2/3 of a unit at a time. If we continue truncating fractional values, we lose information which leads to intermittent off-by-one issues and jitter. In this playground, you can see the jitter when dragging from a point on the screen up and left before the fix, with no jitter after the fix: https://playground.babylonjs.com/#9V23FW#3 --------- Co-authored-by: AmoebaChant <kevbrown@microsoft.com>
1 parent e10ee9b commit 1f6ea6f

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

packages/dev/gui/src/2D/controls/control.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,12 +1974,6 @@ export class Control implements IAnimatable, IFocusableControl {
19741974

19751975
this._computeAlignment(this._tempPaddingMeasure, context);
19761976

1977-
// Convert to int values
1978-
this._currentMeasure.left = this._currentMeasure.left | 0;
1979-
this._currentMeasure.top = this._currentMeasure.top | 0;
1980-
this._currentMeasure.width = this._currentMeasure.width | 0;
1981-
this._currentMeasure.height = this._currentMeasure.height | 0;
1982-
19831977
// Let children add more features
19841978
this._additionalProcessing(this._tempPaddingMeasure, context);
19851979

0 commit comments

Comments
 (0)