[PATCH weston v2 09/20] compositor: use matrix transforms for surface_to_buffer functions

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


Now that we have weston_matrix_transform and appropriate matrices we can
use that instead of weston_transformed_coord + scaler_surface_to_buffer.

scaler_surface_to_buffer no longer has users, so remove it.
---
 src/compositor.c | 41 ++++-------------------------------------
 1 file changed, 4 insertions(+), 37 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 7c0f050..b2b10dd 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -891,49 +891,16 @@ weston_transformed_region(int width, int height,
 	free(dest_rects);
 }
 
-static void
-scaler_surface_to_buffer(struct weston_surface *surface,
-			 float sx, float sy, float *bx, float *by)
-{
-	struct weston_buffer_viewport *vp = &surface->buffer_viewport;
-	double src_width, src_height;
-	double src_x, src_y;
-
-	if (vp->buffer.src_width == wl_fixed_from_int(-1)) {
-		if (vp->surface.width == -1) {
-			*bx = sx;
-			*by = sy;
-			return;
-		}
-
-		src_x = 0.0;
-		src_y = 0.0;
-		src_width = surface->width_from_buffer;
-		src_height = surface->height_from_buffer;
-	} else {
-		src_x = wl_fixed_to_double(vp->buffer.src_x);
-		src_y = wl_fixed_to_double(vp->buffer.src_y);
-		src_width = wl_fixed_to_double(vp->buffer.src_width);
-		src_height = wl_fixed_to_double(vp->buffer.src_height);
-	}
-
-	*bx = sx * src_width / surface->width + src_x;
-	*by = sy * src_height / surface->height + src_y;
-}
-
 WL_EXPORT void
 weston_surface_to_buffer_float(struct weston_surface *surface,
 			       float sx, float sy, float *bx, float *by)
 {
-	struct weston_buffer_viewport *vp = &surface->buffer_viewport;
+	struct weston_vector v = {{sx, sy, 0.0, 1.0}};
 
-	/* first transform coordinates if the scaler is set */
-	scaler_surface_to_buffer(surface, sx, sy, bx, by);
+	weston_matrix_transform(&surface->surface_to_buffer_matrix, &v);
 
-	weston_transformed_coord(surface->width_from_buffer,
-				 surface->height_from_buffer,
-				 vp->buffer.transform, vp->buffer.scale,
-				 *bx, *by, bx, by);
+	*bx = v.f[0] / v.f[3];
+	*by = v.f[1] / v.f[3];
 }
 
 WL_EXPORT void
-- 
2.1.1



More information about the wayland-devel mailing list