boxes: Swap 90 and 270 degree transforms in meta_rectangle_transform()

`meta_rectangle_transform()` is used in the stack to *compensate* for a
`MetaMonitorTransform` applied to a output, not to apply it again.
Change the function accordingly.

Context:
Experimenting with direct scanout on offscreen-rotated outputs revealed
that the 90/270 degree cases were actually interchanged.
Further digging revealed that we use `meta_rectangle_transform()` with
those values swapped in every single case, papering over the issue.

Either a unintuitive and unexplained `meta_monitor_transform_invert()`
was added, in which case "flipped" values would be wrong, or, in case
of Wayland buffer transforms, the values were swapped by interpreting
the Wayland enums accordingly, see commit 8d9bbe10.

Swapping the 90/270 degree values in `meta_rectangle_transform()`:
1. fixes hardware cursor positioning with flipped output transforms
2. fixes rendering issues with offscreen-rotated flipped output transforms
3. allows us to drop unexplained `meta_monitor_transform_invert()`s in
follow-up commits
4. allows us to make `META_MONITOR_TRANSFORM` and `WL_OUTPUT_TRANSFORM`
enums match again (reverting 8d9bbe10, as already done)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2459>
This commit is contained in:
Robert Mader 2022-06-14 17:23:46 +02:00 committed by Marge Bot
parent 29cafe6f6c
commit 2ade26ebf8

View File

@ -2068,6 +2068,19 @@ meta_rectangle_scale_double (const MetaRectangle *rect,
meta_rectangle_from_graphene_rect (&tmp, rounding_strategy, dest); meta_rectangle_from_graphene_rect (&tmp, rounding_strategy, dest);
} }
/**
* meta_rectangle_transform:
* @rect: the #MetaRectangle to be transformed
* @transform: the #MetaMonitorTransform
* @width: the width of the target space
* @height: the height of the target space
* @dest: the transformed #MetaRectangle
*
* This function transforms the values in @rect in order to compensate for
* @transform applied to a #MetaMonitor, making them match the viewport. Note
* that compensating implies that for a clockwise rotation of the #MetaMonitor
* an anti-clockwise rotation has to be applied to @rect.
*/
void void
meta_rectangle_transform (const MetaRectangle *rect, meta_rectangle_transform (const MetaRectangle *rect,
MetaMonitorTransform transform, MetaMonitorTransform transform,
@ -2082,8 +2095,8 @@ meta_rectangle_transform (const MetaRectangle *rect,
break; break;
case META_MONITOR_TRANSFORM_90: case META_MONITOR_TRANSFORM_90:
*dest = (MetaRectangle) { *dest = (MetaRectangle) {
.x = width - (rect->y + rect->height), .x = rect->y,
.y = rect->x, .y = height - (rect->x + rect->width),
.width = rect->height, .width = rect->height,
.height = rect->width, .height = rect->width,
}; };
@ -2098,8 +2111,8 @@ meta_rectangle_transform (const MetaRectangle *rect,
break; break;
case META_MONITOR_TRANSFORM_270: case META_MONITOR_TRANSFORM_270:
*dest = (MetaRectangle) { *dest = (MetaRectangle) {
.x = rect->y, .x = width - (rect->y + rect->height),
.y = height - (rect->x + rect->width), .y = rect->x,
.width = rect->height, .width = rect->height,
.height = rect->width, .height = rect->width,
}; };
@ -2114,8 +2127,8 @@ meta_rectangle_transform (const MetaRectangle *rect,
break; break;
case META_MONITOR_TRANSFORM_FLIPPED_90: case META_MONITOR_TRANSFORM_FLIPPED_90:
*dest = (MetaRectangle) { *dest = (MetaRectangle) {
.x = width - (rect->y + rect->height), .x = rect->y,
.y = height - (rect->x + rect->width), .y = rect->x,
.width = rect->height, .width = rect->height,
.height = rect->width, .height = rect->width,
}; };
@ -2130,8 +2143,8 @@ meta_rectangle_transform (const MetaRectangle *rect,
break; break;
case META_MONITOR_TRANSFORM_FLIPPED_270: case META_MONITOR_TRANSFORM_FLIPPED_270:
*dest = (MetaRectangle) { *dest = (MetaRectangle) {
.x = rect->y, .x = width - (rect->y + rect->height),
.y = rect->x, .y = height - (rect->x + rect->width),
.width = rect->height, .width = rect->height,
.height = rect->width, .height = rect->width,
}; };