Forráskód Böngészése

fix: Add maxPixelRatio to allow for a lower multiplier than current devicePixelRatio (#1282)

Co-authored-by: Sebastian Löfgren <[email protected]>
Sechgulo 2 hónapja
szülő
commit
e086966e4c
1 módosított fájl, 6 hozzáadás és 1 törlés
  1. 6 1
      hxd/Window.js.hx

+ 6 - 1
hxd/Window.js.hx

@@ -74,6 +74,11 @@ class Window {
 		(default : true)
 	**/
 	public var useScreenPixels : Bool = js.Browser.supported;
+	/**
+		Sets the maximum pixel ratio that will be used (only applicable with useScreenPixels enabled).
+		(default : Browser.window.devicePixelRatio)
+	**/
+	public var maxPixelRatio : Float = js.Browser.window.devicePixelRatio;
 	/**
 		When enabled, the user click event on the canvas that would trigger mouse capture to be enabled would be discarded.
 		(default : true)
@@ -306,7 +311,7 @@ class Window {
 	}
 
 	function getPixelRatio() {
-		return useScreenPixels ? js.Browser.window.devicePixelRatio : 1;
+		return useScreenPixels ? Math.min(js.Browser.window.devicePixelRatio, maxPixelRatio) : 1;
 	}
 
 	function get_width() {