[PATCH weston v10 01/61] Clip co-ordinates in surface->buffer translation
Daniel Stone
daniels at collabora.com
Tue Apr 4 16:54:19 UTC 2017
Since performing the surface -> buffer translation may introduce
rounding error taking our desired co-ordinates out of bounds, introduce
a hard clip to the bounds specified by the client's viewport.
Signed-off-by: Daniel Stone <daniels at collabora.com>
---
libweston/compositor.c | 9 +++++++++
1 file changed, 9 insertions(+)
v10: New.
diff --git a/libweston/compositor.c b/libweston/compositor.c
index e8dd151d..b2f4c610 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -777,7 +777,16 @@ viewport_surface_to_buffer(struct weston_surface *surface,
}
*bx = sx * src_width / surface->width + src_x;
+ if (*bx < src_x)
+ *bx = src_x;
+ if (*bx > src_x + src_width)
+ *bx = src_x + src_width;
+
*by = sy * src_height / surface->height + src_y;
+ if (*by < src_y)
+ *by = src_y;
+ if (*by > src_y + src_height)
+ *by = src_y + src_height;
}
WL_EXPORT void
--
2.12.2
More information about the wayland-devel
mailing list