[mutter] boxes: Ensure we scale to a fully rounded rectangle
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] boxes: Ensure we scale to a fully rounded rectangle
- Date: Tue, 21 May 2019 09:34:15 +0000 (UTC)
commit 68fba458b33d423f45be936fd99b9f100c379c1f
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date: Fri Mar 1 20:47:07 2019 +0100
boxes: Ensure we scale to a fully rounded rectangle
In order to scale a rectangle by a double value, we can reuse a ClutterRect
to do the scale computations in floating point math and then to convert it back
using the proper strategy that will take in account the subpixel compensation.
In this way we can be sure that the resulting rectangle can fully contain the
original scaled one.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/469
src/core/boxes.c | 24 +++++-------------------
1 file changed, 5 insertions(+), 19 deletions(-)
---
diff --git a/src/core/boxes.c b/src/core/boxes.c
index 400febea1..0e9affec4 100644
--- a/src/core/boxes.c
+++ b/src/core/boxes.c
@@ -2051,25 +2051,11 @@ meta_rectangle_scale_double (const MetaRectangle *rect,
MetaRoundingStrategy rounding_strategy,
MetaRectangle *dest)
{
- switch (rounding_strategy)
- {
- case META_ROUNDING_STRATEGY_SHRINK:
- *dest = (MetaRectangle) {
- .x = (int) ceil (rect->x * scale),
- .y = (int) ceil (rect->y * scale),
- .width = (int) floor (rect->width * scale),
- .height = (int) floor (rect->height * scale),
- };
- break;
- case META_ROUNDING_STRATEGY_GROW:
- *dest = (MetaRectangle) {
- .x = (int) floor (rect->x * scale),
- .y = (int) floor (rect->y * scale),
- .width = (int) ceil (rect->width * scale),
- .height = (int) ceil (rect->height * scale),
- };
- break;
- }
+ ClutterRect tmp = CLUTTER_RECT_INIT (rect->x, rect->y,
+ rect->width, rect->height);
+
+ clutter_rect_scale (&tmp, scale, scale);
+ meta_rectangle_from_clutter_rect (&tmp, rounding_strategy, dest);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]