[mutter] renderer/native: Round calculated framebuffer size before casting to int



commit 8a32b421720b284225f216890897880934275eb1
Author: Jonas Ådahl <jadahl gmail com>
Date:   Tue Aug 29 21:38:18 2017 +0800

    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

 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 90a029f..869ede4 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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]