Przeglądaj źródła

Merge pull request #105585 from marcosc90/fix-web-update-size

[Web] Prevent unnecessary canvas resizes by flooring scaled dimensions
Thaddeus Crews 3 miesięcy temu
rodzic
commit
d043be6031
1 zmienionych plików z 4 dodań i 4 usunięć
  1. 4 4
      platform/web/js/libs/library_godot_display.js

+ 4 - 4
platform/web/js/libs/library_godot_display.js

@@ -306,11 +306,11 @@ const GodotDisplayScreen = {
 			const scale = GodotDisplayScreen.getPixelRatio();
 			if (isFullscreen || wantsFullWindow) {
 				// We need to match screen size.
-				width = window.innerWidth * scale;
-				height = window.innerHeight * scale;
+				width = Math.floor(window.innerWidth * scale);
+				height = Math.floor(window.innerHeight * scale);
 			}
-			const csw = `${width / scale}px`;
-			const csh = `${height / scale}px`;
+			const csw = `${Math.floor(width / scale)}px`;
+			const csh = `${Math.floor(height / scale)}px`;
 			if (canvas.style.width !== csw || canvas.style.height !== csh || canvas.width !== width || canvas.height !== height) {
 				// Size doesn't match.
 				// Resize canvas, set correct CSS pixel size, update GL.