mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-11 18:19:58 +00:00
tab: support hidpi device (#106)
This commit make canvas in full device pixel size and set proper scale on it, so that drawWindow draws all pixels instead of scaling down to normal dpi.
This commit is contained in:
@@ -81,13 +81,16 @@ async function onRequestSessionSuccess (newSession: cast.Session) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set initial size
|
// Set initial size
|
||||||
canvas.width = window.innerWidth;
|
canvas.width = window.innerWidth * window.devicePixelRatio;
|
||||||
canvas.height = window.innerHeight;
|
canvas.height = window.innerHeight * window.devicePixelRatio;
|
||||||
|
ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
|
||||||
|
|
||||||
// Resize canvas whenever the window resizes
|
// Resize canvas whenever the window resizes
|
||||||
window.addEventListener("resize", () => {
|
window.addEventListener("resize", () => {
|
||||||
canvas.width = window.innerWidth;
|
canvas.width = window.innerWidth * window.devicePixelRatio;
|
||||||
canvas.height = window.innerHeight;
|
canvas.height = window.innerHeight * window.devicePixelRatio;
|
||||||
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
||||||
|
ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Test performance
|
// TODO: Test performance
|
||||||
|
|||||||
Reference in New Issue
Block a user