Skip to content

Commit d043be6

Browse files
committed
Merge pull request #105585 from marcosc90/fix-web-update-size
[Web] Prevent unnecessary canvas resizes by flooring scaled dimensions
2 parents ae68a21 + ed0690d commit d043be6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

platform/web/js/libs/library_godot_display.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,11 @@ const GodotDisplayScreen = {
306306
const scale = GodotDisplayScreen.getPixelRatio();
307307
if (isFullscreen || wantsFullWindow) {
308308
// We need to match screen size.
309-
width = window.innerWidth * scale;
310-
height = window.innerHeight * scale;
309+
width = Math.floor(window.innerWidth * scale);
310+
height = Math.floor(window.innerHeight * scale);
311311
}
312-
const csw = `${width / scale}px`;
313-
const csh = `${height / scale}px`;
312+
const csw = `${Math.floor(width / scale)}px`;
313+
const csh = `${Math.floor(height / scale)}px`;
314314
if (canvas.style.width !== csw || canvas.style.height !== csh || canvas.width !== width || canvas.height !== height) {
315315
// Size doesn't match.
316316
// Resize canvas, set correct CSS pixel size, update GL.

0 commit comments

Comments
 (0)