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 <[email protected]>
---
 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

_______________________________________________
wayland-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to