Commit 4baefe46 authored by Jonas Ådahl's avatar Jonas Ådahl

clutter/stage: Round viewport coordinates before setting

cogl_(fromebuffer)_set_viewport will implicitly cast away the fraction
of a floating point number, meaning if a coordinate calculation
resulted in just below the integer (which for example ~1.75 scaling on
a 1920x1080 did), we'd set a one pixel too narrow viewport. Fix this by
always rounding the floating point to the closest int before passing,
avoiding the precision loss.
parent c388a8fc
......@@ -3627,6 +3627,10 @@ _clutter_stage_maybe_setup_viewport (ClutterStage *stage,
float fb_scale;
float viewport_offset_x;
float viewport_offset_y;
float viewport_x;
float viewport_y;
float viewport_width;
float viewport_height;
float z_2d;
......@@ -3639,11 +3643,13 @@ _clutter_stage_maybe_setup_viewport (ClutterStage *stage,
viewport_offset_x = view_layout.x * fb_scale;
viewport_offset_y = view_layout.y * fb_scale;
viewport_x = roundf (priv->viewport[0] * fb_scale - viewport_offset_x);
viewport_y = roundf (priv->viewport[1] * fb_scale - viewport_offset_y);
viewport_width = roundf (priv->viewport[2] * fb_scale);
viewport_height = roundf (priv->viewport[3] * fb_scale);
cogl_framebuffer_set_viewport (fb,
priv->viewport[0] * fb_scale - viewport_offset_x,
priv->viewport[1] * fb_scale - viewport_offset_y,
priv->viewport[2] * fb_scale,
priv->viewport[3] * fb_scale);
viewport_x, viewport_y,
viewport_width, viewport_height);
perspective = priv->perspective;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment