mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
clutter/rect: Clamp to pixel taking care of subpixel values
The clamped rectangle currently could not fully contain the original fractional rectangle because it doesn't take care of the fact that the new width should consider the fact that flooring we'd translate the rectangle, and thus to cover the same area we need to take care of it. So, to properly compute the width and height, calculate x2 and y2 first and then use this ceiled value to compute the actual width using the floored x1 and y1. https://gitlab.gnome.org/GNOME/mutter/merge_requests/3
This commit is contained in:
parent
ceb4fe2151
commit
8bc8dc66f2
@ -1160,15 +1160,20 @@ clutter_rect_inset (ClutterRect *rect,
|
||||
void
|
||||
clutter_rect_clamp_to_pixel (ClutterRect *rect)
|
||||
{
|
||||
float x2, y2;
|
||||
|
||||
g_return_if_fail (rect != NULL);
|
||||
|
||||
clutter_rect_normalize_internal (rect);
|
||||
|
||||
x2 = rect->origin.x + rect->size.width;
|
||||
y2 = rect->origin.y + rect->size.height;
|
||||
|
||||
rect->origin.x = floorf (rect->origin.x);
|
||||
rect->origin.y = floorf (rect->origin.y);
|
||||
|
||||
rect->size.width = ceilf (rect->size.width);
|
||||
rect->size.height = ceilf (rect->size.height);
|
||||
rect->size.width = ceilf (x2) - rect->origin.x;
|
||||
rect->size.height = ceilf (y2) - rect->origin.y;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user