aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Stoeckl <code@mstoeckl.com>2020-02-09 10:24:44 -0500
committerDrew DeVault <sir@cmpwn.com>2020-02-17 21:43:05 +0100
commit2fddec56e8bac17c4c5b5e8ae396fe024fd76b40 (patch)
tree0f1f5877a9491a6bb58b82dbc6ad5cc2650e5f62
parentf22a5d17041e339b3ee7ab7975d40b353ab745c3 (diff)
output: fix output transform compositions
This change ensures that wlr_output_transform_compose correctly composes transforms when the first transform includes a rotation and the second transform includes a flip.
-rw-r--r--types/wlr_output.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/types/wlr_output.c b/types/wlr_output.c
index 2207c2e5..611309db 100644
--- a/types/wlr_output.c
+++ b/types/wlr_output.c
@@ -1118,7 +1118,15 @@ enum wl_output_transform wlr_output_transform_invert(
enum wl_output_transform wlr_output_transform_compose(
enum wl_output_transform tr_a, enum wl_output_transform tr_b) {
uint32_t flipped = (tr_a ^ tr_b) & WL_OUTPUT_TRANSFORM_FLIPPED;
- uint32_t rotated =
- (tr_a + tr_b) & (WL_OUTPUT_TRANSFORM_90 | WL_OUTPUT_TRANSFORM_180);
+ uint32_t rotation_mask = WL_OUTPUT_TRANSFORM_90 | WL_OUTPUT_TRANSFORM_180;
+ uint32_t rotated;
+ if (tr_b & WL_OUTPUT_TRANSFORM_FLIPPED) {
+ // When a rotation of k degrees is followed by a flip, the
+ // equivalent transform is a flip followed by a rotation of
+ // -k degrees.
+ rotated = (tr_b - tr_a) & rotation_mask;
+ } else {
+ rotated = (tr_a + tr_b) & rotation_mask;
+ }
return flipped | rotated;
}