mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-08 08:39:59 +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
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
canvas.width = window.innerWidth * window.devicePixelRatio;
|
||||
canvas.height = window.innerHeight * window.devicePixelRatio;
|
||||
ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
|
||||
|
||||
// Resize canvas whenever the window resizes
|
||||
window.addEventListener("resize", () => {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
canvas.width = window.innerWidth * window.devicePixelRatio;
|
||||
canvas.height = window.innerHeight * window.devicePixelRatio;
|
||||
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
||||
ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
|
||||
});
|
||||
|
||||
// TODO: Test performance
|
||||
|
||||
Reference in New Issue
Block a user