Redefine output rotations

It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.

As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.

All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.

Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as

  c -s
  s  c

that is, it's column-major. This fooled me at first.

Fixing window.c fixes weston-terminal and weston-transformed.

In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical.  The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.

Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.

https://gitlab.freedesktop.org/wayland/weston/issues/99

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
Pekka Paalanen
2020-02-06 15:27:54 +02:00
committed by Daniel Stone
parent 0df4477924
commit 8060d826b7
8 changed files with 88 additions and 84 deletions
+16 -16
View File
@@ -461,32 +461,32 @@ window_get_transformed_ball(struct window *window, float *bx, float *by)
*by = wy;
break;
case WL_OUTPUT_TRANSFORM_90:
*bx = window->height - wy;
*by = wx;
*bx = wy;
*by = window->width - wx;
break;
case WL_OUTPUT_TRANSFORM_180:
*bx = window->width - wx;
*by = window->height - wy;
break;
case WL_OUTPUT_TRANSFORM_270:
*bx = wy;
*by = window->width - wx;
*bx = window->height - wy;
*by = wx;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED:
*bx = window->width - wx;
*by = wy;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
*bx = window->height - wy;
*by = window->width - wx;
*bx = wy;
*by = wx;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
*bx = wx;
*by = window->height - wy;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
*bx = wy;
*by = wx;
*bx = window->height - wy;
*by = window->width - wx;
break;
}
@@ -570,32 +570,32 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)
off_x = tx;
break;
case WL_OUTPUT_TRANSFORM_90:
off_y = tx;
off_x = bwidth - ty;
off_y = bheight - tx;
off_x = ty;
break;
case WL_OUTPUT_TRANSFORM_180:
off_y = bheight - ty;
off_x = bwidth - tx;
break;
case WL_OUTPUT_TRANSFORM_270:
off_y = bheight - tx;
off_x = ty;
off_y = tx;
off_x = bwidth - ty;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED:
off_y = ty;
off_x = bwidth - tx;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
off_y = bheight - tx;
off_x = bwidth - ty;
off_y = tx;
off_x = ty;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
off_y = bheight - ty;
off_x = tx;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
off_y = tx;
off_x = ty;
off_y = bheight - tx;
off_x = bwidth - ty;
break;
}
wp_viewport_set_source(window->viewport,
+3
View File
@@ -231,6 +231,9 @@ usage(int error_code)
" -h <height>\tSet window height to <height>\n"
" --help\tShow this help text\n\n");
fprintf(stderr, "This version has been fixed for "
"https://gitlab.freedesktop.org/wayland/weston/issues/99 .\n");
exit(error_code);
}
+12 -12
View File
@@ -1832,14 +1832,14 @@ widget_cairo_update_transform(struct widget *widget, cairo_t *cr)
translate_y = 0;
break;
case WL_OUTPUT_TRANSFORM_90:
angle = M_PI_2;
translate_x = surface_height;
translate_y = 0;
angle = M_PI + M_PI_2;
translate_x = 0;
translate_y = surface_width;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
angle = M_PI_2;
translate_x = surface_height;
translate_y = surface_width;
angle = M_PI + M_PI_2;
translate_x = 0;
translate_y = 0;
break;
case WL_OUTPUT_TRANSFORM_180:
angle = M_PI;
@@ -1852,14 +1852,14 @@ widget_cairo_update_transform(struct widget *widget, cairo_t *cr)
translate_y = surface_height;
break;
case WL_OUTPUT_TRANSFORM_270:
angle = M_PI + M_PI_2;
translate_x = 0;
translate_y = surface_width;
angle = M_PI_2;
translate_x = surface_height;
translate_y = 0;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
angle = M_PI + M_PI_2;
translate_x = 0;
translate_y = 0;
angle = M_PI_2;
translate_x = surface_height;
translate_y = surface_width;
break;
}