From e45cd43aaab7af014607b2578ec68a5bbec1b609 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Mon, 7 Nov 2022 21:42:38 +0000 Subject: Teach the mid-end about device pixel ratios The device pixel ratio indicates how many physical pixels there are in the platonic ideal of a pixel, at least approximately. In Web browsers, the device pixel ratio is used to represent "retina" displays with particularly high pixel densities, and also to reflect user-driven zooming of the page to different text sizes. The mid-end uses the device pixel ratio to adjust the tile size at startup, and can also respond to changes in device pixel ratio by adjusting the time size later. This is accomplished through a new argument to midend_size() which can simply be passed as 1.0 in any front end that doesn't care about this. --- emcc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'emcc.c') diff --git a/emcc.c b/emcc.c index 651fc5a..b7af686 100644 --- a/emcc.c +++ b/emcc.c @@ -195,7 +195,7 @@ static void resize(bool initial) int w, h; double dpr; w = h = INT_MAX; - midend_size(me, &w, &h, false); + midend_size(me, &w, &h, false, 1.0); if (initial) { dpr = js_get_device_pixel_ratio(); if (dpr != 1.0) { @@ -207,7 +207,7 @@ static void resize(bool initial) */ w *= dpr; h *= dpr; - midend_size(me, &w, &h, true); + midend_size(me, &w, &h, true, 1.0); } } js_canvas_set_size(w, h); @@ -219,7 +219,7 @@ static void resize(bool initial) /* Called from JS when the device pixel ratio changes */ void rescale_puzzle(int w, int h) { - midend_size(me, &w, &h, true); + midend_size(me, &w, &h, true, 1.0); if (canvas_w != w || canvas_h != h) { js_canvas_set_size(w, h); canvas_w = w; -- cgit v1.1