[PATCH weston v2 18/20] compositor: add weston_view_to_output_matrix()

Derek Foreman derekf at osg.samsung.com
Thu Oct 16 08:55:36 PDT 2014


New function that creates a matrix that can transform buffer co-ordinates
to output co-ordinates (or the inverse of that matrix).
---
 src/compositor.c | 19 +++++++++++++++++++
 src/compositor.h |  6 +++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/compositor.c b/src/compositor.c
index d629bd7..36fd7cc 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -845,6 +845,25 @@ weston_surface_to_buffer_rect(struct weston_surface *surface,
 }
 
 WL_EXPORT void
+weston_view_to_output_matrix(struct weston_view *view,
+			     struct weston_output *op,
+			     bool inverse,
+			     struct weston_matrix *matrix)
+{
+	*matrix = view->surface->buffer_to_surface_matrix;
+	if (view->transform.enabled)
+		weston_matrix_multiply(matrix, &view->transform.matrix);
+	else
+		weston_matrix_translate(matrix,
+					view->geometry.x,
+					view->geometry.y, 0);
+	weston_matrix_multiply(matrix, &op->matrix);
+
+	if (inverse)
+		weston_matrix_invert(matrix, matrix);
+}
+
+WL_EXPORT void
 weston_view_move_to_plane(struct weston_view *view,
 			     struct weston_plane *plane)
 {
diff --git a/src/compositor.h b/src/compositor.h
index 8e2cf47..b375262 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -1005,7 +1005,11 @@ weston_surface_to_buffer(struct weston_surface *surface,
 pixman_box32_t
 weston_surface_to_buffer_rect(struct weston_surface *surface,
 			      pixman_box32_t rect);
-
+void
+weston_view_to_output_matrix(struct weston_view *view,
+			     struct weston_output *op,
+			     bool inverse,
+			     struct weston_matrix *matrix);
 void
 weston_spring_init(struct weston_spring *spring,
 		   double k, double current, double target);
-- 
2.1.1



More information about the wayland-devel mailing list