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
This commit is contained in:
Jonas Ådahl 2017-08-29 21:38:18 +08:00
parent 94a15404da
commit 8a32b42172

View File

@ -1719,8 +1719,8 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
else else
scale = 1.0; scale = 1.0;
width = logical_monitor->rect.width * scale; width = roundf (logical_monitor->rect.width * scale);
height = logical_monitor->rect.height * scale; height = roundf (logical_monitor->rect.height * scale);
onscreen = meta_renderer_native_create_onscreen (META_RENDERER_NATIVE (renderer), onscreen = meta_renderer_native_create_onscreen (META_RENDERER_NATIVE (renderer),
cogl_context, cogl_context,