mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
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,
|
MetaRoundingStrategy rounding_strategy,
|
||||||
MetaRectangle *dest)
|
MetaRectangle *dest)
|
||||||
{
|
{
|
||||||
switch (rounding_strategy)
|
ClutterRect tmp = CLUTTER_RECT_INIT (rect->x, rect->y,
|
||||||
{
|
rect->width, rect->height);
|
||||||
case META_ROUNDING_STRATEGY_SHRINK:
|
|
||||||
*dest = (MetaRectangle) {
|
clutter_rect_scale (&tmp, scale, scale);
|
||||||
.x = (int) ceil (rect->x * scale),
|
meta_rectangle_from_clutter_rect (&tmp, rounding_strategy, dest);
|
||||||
.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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user