[mutter] clutter/rect: Clamp to pixel taking care of subpixel values
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] clutter/rect: Clamp to pixel taking care of subpixel values
- Date: Fri, 1 Mar 2019 18:52:04 +0000 (UTC)
commit 8bc8dc66f234c223e1fb3ab545a540cb6ccc73d1
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Fri Mar 1 02:49:19 2019 +0100
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
clutter/clutter/clutter-base-types.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/clutter/clutter/clutter-base-types.c b/clutter/clutter/clutter-base-types.c
index ba38d7e34..f7ad5261e 100644
--- a/clutter/clutter/clutter-base-types.c
+++ b/clutter/clutter/clutter-base-types.c
@@ -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;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]