diff options
author | Jonas Ådahl <jadahl@gmail.com> | 2017-08-29 21:38:18 +0800 |
---|---|---|
committer | Jonas Ådahl <jadahl@gmail.com> | 2017-08-30 13:07:11 +0800 |
commit | 8a32b421720b284225f216890897880934275eb1 (patch) | |
tree | 633e2bb0fa466f1297aa707dcc7cdbe38e1300cb | |
parent | 94a15404da290538e39968553fe4f278da48b6ec (diff) | |
download | mutter-8a32b421720b284225f216890897880934275eb1.tar.gz |
renderer/native: Round calculated framebuffer size before casting to int
Due to rounding issues, we can't assume a floating point calculation
will end up on an integer, even if we got the factor from the reverse
calculation. Thus, to avoid casting away values like N.999... to N,
when they should really be N+1, round the resulting floating point
calculation before casting it to int.
This fixes an issue where using the scale ~1.739 on a 1920x1080 mode
resulted in error when setting the mode, as the calculated size of the
framebuffer was only 1919x1080.
https://bugzilla.gnome.org/show_bug.cgi?id=786918
-rw-r--r-- | src/backends/native/meta-renderer-native.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index 90a029f36..869ede43f 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -1719,8 +1719,8 @@ meta_renderer_native_create_view (MetaRenderer *renderer, else scale = 1.0; - width = logical_monitor->rect.width * scale; - height = logical_monitor->rect.height * scale; + width = roundf (logical_monitor->rect.width * scale); + height = roundf (logical_monitor->rect.height * scale); onscreen = meta_renderer_native_create_onscreen (META_RENDERER_NATIVE (renderer), cogl_context, |