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

Submitted by Derek Foreman on Oct. 16, 2014, 3:55 p.m.

Details

Message ID 1413474938-2407-19-git-send-email-derekf@osg.samsung.com
State Changes Requested
Headers show

Not browsing as part of any series.

Commit Message

Derek Foreman Oct. 16, 2014, 3:55 p.m.
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(-)

Patch hide | download patch | download mbox

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);