[PATCH weston v3 6/8] Add 24.8 versions of weston_surface_{to, from}_global

Daniel Stone daniel at fooishbar.org
Fri May 4 03:21:58 PDT 2012


To be used by input code, paralleling the existing integer versions.

Enlarge the surface_{to,from}_global_float input types to double to
avoid losing precision.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
 src/compositor.c |   38 +++++++++++++++++++++++++++++++++++---
 src/compositor.h |   10 +++++++++-
 2 files changed, 44 insertions(+), 4 deletions(-)

v3: New.

diff --git a/src/compositor.c b/src/compositor.c
index 935675a..484f9b6 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -266,7 +266,7 @@ weston_surface_set_color(struct weston_surface *surface,
 
 static void
 surface_to_global_float(struct weston_surface *surface,
-			int32_t sx, int32_t sy, GLfloat *x, GLfloat *y)
+			double sx, double sy, GLfloat *x, GLfloat *y)
 {
 	if (surface->transform.enabled) {
 		struct weston_vector v = { { sx, sy, 0.0f, 1.0f } };
@@ -436,7 +436,7 @@ weston_surface_update_transform(struct weston_surface *surface)
 
 WL_EXPORT void
 weston_surface_to_global_float(struct weston_surface *surface,
-			       int32_t sx, int32_t sy, GLfloat *x, GLfloat *y)
+			       double sx, double sy, GLfloat *x, GLfloat *y)
 {
 	weston_surface_update_transform(surface);
 
@@ -444,6 +444,21 @@ weston_surface_to_global_float(struct weston_surface *surface,
 }
 
 WL_EXPORT void
+weston_surface_to_global_248(struct weston_surface *surface,
+			     wl_signed_24_8_t sx, wl_signed_24_8_t sy,
+			     wl_signed_24_8_t *x, wl_signed_24_8_t *y)
+{
+	GLfloat xf, yf;
+
+	weston_surface_to_global_float(surface,
+	                               wl_signed_24_8_to_double(sx),
+				       wl_signed_24_8_to_double(sy),
+				       &xf, &yf);
+	*x = wl_signed_24_8_from_double(xf);
+	*y = wl_signed_24_8_from_double(yf);
+}
+
+WL_EXPORT void
 weston_surface_to_global(struct weston_surface *surface,
 			 int32_t sx, int32_t sy, int32_t *x, int32_t *y)
 {
@@ -456,7 +471,7 @@ weston_surface_to_global(struct weston_surface *surface,
 
 static void
 surface_from_global_float(struct weston_surface *surface,
-			  int32_t x, int32_t y, GLfloat *sx, GLfloat *sy)
+			  double x, double y, GLfloat *sx, GLfloat *sy)
 {
 	if (surface->transform.enabled) {
 		struct weston_vector v = { { x, y, 0.0f, 1.0f } };
@@ -481,6 +496,23 @@ surface_from_global_float(struct weston_surface *surface,
 }
 
 WL_EXPORT void
+weston_surface_from_global_248(struct weston_surface *surface,
+			       wl_signed_24_8_t x, wl_signed_24_8_t y,
+			       wl_signed_24_8_t *sx, wl_signed_24_8_t *sy)
+{
+	GLfloat sxf, syf;
+
+	weston_surface_update_transform(surface);
+
+	surface_from_global_float(surface,
+	                          wl_signed_24_8_to_double(x),
+				  wl_signed_24_8_to_double(y),
+				  &sxf, &syf);
+	*sx = wl_signed_24_8_from_double(sxf);
+	*sy = wl_signed_24_8_from_double(syf);
+}
+
+WL_EXPORT void
 weston_surface_from_global(struct weston_surface *surface,
 			   int32_t x, int32_t y, int32_t *sx, int32_t *sy)
 {
diff --git a/src/compositor.h b/src/compositor.h
index bc0b862..d03b471 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -389,12 +389,20 @@ void
 weston_surface_to_global(struct weston_surface *surface,
 			 int32_t sx, int32_t sy, int32_t *x, int32_t *y);
 void
+weston_surface_to_global_248(struct weston_surface *surface,
+			     wl_signed_24_8_t sx, wl_signed_24_8_t sy,
+			     wl_signed_24_8_t *x, wl_signed_24_8_t *y);
+void
 weston_surface_to_global_float(struct weston_surface *surface,
-			       int32_t sx, int32_t sy, GLfloat *x, GLfloat *y);
+			       double sx, double sy, GLfloat *x, GLfloat *y);
 
 void
 weston_surface_from_global(struct weston_surface *surface,
 			   int32_t x, int32_t y, int32_t *sx, int32_t *sy);
+void
+weston_surface_from_global_248(struct weston_surface *surface,
+			       wl_signed_24_8_t x, wl_signed_24_8_t y,
+			       wl_signed_24_8_t *sx, wl_signed_24_8_t *sy);
 
 void
 weston_spring_init(struct weston_spring *spring,
-- 
1.7.10



More information about the wayland-devel mailing list