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
This commit is contained in:
parent
9c2fdcdbb2
commit
68fba458b3
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user