[PATCH weston] compositor-drm: calculate source rect using viewport top-left for sprite plane

Tomohito Esaki etom at igel.co.jp
Fri Sep 30 09:32:02 UTC 2016


Add the viewport offset position into the sprite plane cropping
calculation. Without this patch the sprite plane always outputs from the
top left corner of the source buffer.

Signed-off-by: Tomohito Esaki <etom at igel.co.jp>
---
 libweston/compositor-drm.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 8319d7c..31f9724 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -1105,6 +1105,19 @@ drm_output_prepare_overlay_view(struct drm_output *output,
 	if (sy2 > wl_fixed_from_int(ev->surface->height))
 		sy2 = wl_fixed_from_int(ev->surface->height);
 
+	/* Calculate source crop offset */
+	if (viewport->buffer.src_width != wl_fixed_from_int(-1) &&
+	    viewport->buffer.src_height != wl_fixed_from_int(-1)) {
+		if (sx1 < viewport->buffer.src_x) {
+			sx1 = viewport->buffer.src_x;
+			sx2 += sx1;
+		}
+		if (sy1 < viewport->buffer.src_y) {
+			sy1 = viewport->buffer.src_y;
+			sy2 += sy1;
+		}
+	}
+
 	tbox.x1 = sx1;
 	tbox.y1 = sy1;
 	tbox.x2 = sx2;
-- 
2.7.4



More information about the wayland-devel mailing list