libweston: always use the transform matrix for coordinate conversion

We always set it up correctly, even if transforms are disabled. The code
is simpler if we always use the matrix instead of having two cases.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2022-11-08 16:36:49 -06:00
parent 2dc8680d71
commit 8bf90010dd

View File

@ -649,11 +649,10 @@ WL_EXPORT void
weston_view_to_global_float(struct weston_view *view, weston_view_to_global_float(struct weston_view *view,
float sx, float sy, float *x, float *y) float sx, float sy, float *x, float *y)
{ {
assert(!view->transform.dirty);
if (view->transform.enabled) {
struct weston_vector v = { { sx, sy, 0.0f, 1.0f } }; struct weston_vector v = { { sx, sy, 0.0f, 1.0f } };
assert(!view->transform.dirty);
weston_matrix_transform(&view->transform.matrix, &v); weston_matrix_transform(&view->transform.matrix, &v);
if (fabsf(v.f[3]) < 1e-6) { if (fabsf(v.f[3]) < 1e-6) {
@ -667,10 +666,6 @@ weston_view_to_global_float(struct weston_view *view,
*x = v.f[0] / v.f[3]; *x = v.f[0] / v.f[3];
*y = v.f[1] / v.f[3]; *y = v.f[1] / v.f[3];
} else {
*x = sx + view->geometry.x;
*y = sy + view->geometry.y;
}
} }
WL_EXPORT pixman_box32_t WL_EXPORT pixman_box32_t
@ -1467,11 +1462,10 @@ WL_EXPORT void
weston_view_from_global_float(struct weston_view *view, weston_view_from_global_float(struct weston_view *view,
float x, float y, float *vx, float *vy) float x, float y, float *vx, float *vy)
{ {
assert(!view->transform.dirty);
if (view->transform.enabled) {
struct weston_vector v = { { x, y, 0.0f, 1.0f } }; struct weston_vector v = { { x, y, 0.0f, 1.0f } };
assert(!view->transform.dirty);
weston_matrix_transform(&view->transform.inverse, &v); weston_matrix_transform(&view->transform.inverse, &v);
if (fabsf(v.f[3]) < 1e-6) { if (fabsf(v.f[3]) < 1e-6) {
@ -1485,10 +1479,6 @@ weston_view_from_global_float(struct weston_view *view,
*vx = v.f[0] / v.f[3]; *vx = v.f[0] / v.f[3];
*vy = v.f[1] / v.f[3]; *vy = v.f[1] / v.f[3];
} else {
*vx = x - view->geometry.x;
*vy = y - view->geometry.y;
}
} }
WL_EXPORT void WL_EXPORT void