mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
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. https://bugzilla.gnome.org/show_bug.cgi?id=765011
This commit is contained in:
parent
c388a8fc9d
commit
4baefe46b3
@ -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;
|
||||
|
||||
CLUTTER_NOTE (PAINT,
|
||||
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user