[PATCH] gl_renderer: Use EGL_WAYLAND_Y_INVERTED_WL to query wl_buffer's orientation

Stanislav Vorobiov s.vorobiov at samsung.com
Mon Aug 26 02:37:07 PDT 2013


---
 src/compositor.c     |    1 +
 src/compositor.h     |    1 +
 src/gl-renderer.c    |   13 ++++++++++++-
 src/weston-egl-ext.h |    4 ++++
 4 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/compositor.c b/src/compositor.c
index 78351eb..b6a4c59 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1088,6 +1088,7 @@ weston_buffer_from_resource(struct wl_resource *resource)
 	buffer->resource = resource;
 	wl_signal_init(&buffer->destroy_signal);
 	buffer->destroy_listener.notify = weston_buffer_destroy_handler;
+	buffer->y_inverted = 1;
 	wl_resource_add_destroy_listener(resource, &buffer->destroy_listener);
 	
 	return buffer;
diff --git a/src/compositor.h b/src/compositor.h
index ee7853b..3048701 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -607,6 +607,7 @@ struct weston_buffer {
 	};
 	int32_t width, height;
 	uint32_t busy_count;
+	int y_inverted;
 };
 
 struct weston_buffer_reference {
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index e321211..3f74b84 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -550,6 +550,7 @@ texture_region(struct weston_surface *es, pixman_region32_t *region,
 	unsigned int *vtxcnt, nvtx = 0;
 	pixman_box32_t *rects, *surf_rects;
 	int i, j, k, nrects, nsurf;
+	int y_inverted = 1;
 
 	rects = pixman_region32_rectangles(region, &nrects);
 	surf_rects = pixman_region32_rectangles(surf_region, &nsurf);
@@ -563,6 +564,10 @@ texture_region(struct weston_surface *es, pixman_region32_t *region,
 	inv_width = 1.0 / gs->pitch;
         inv_height = 1.0 / gs->height;
 
+	if (gs->buffer_ref.buffer) {
+		y_inverted = gs->buffer_ref.buffer->y_inverted;
+	}
+
 	for (i = 0; i < nrects; i++) {
 		pixman_box32_t *rect = &rects[i];
 		for (j = 0; j < nsurf; j++) {
@@ -599,7 +604,11 @@ texture_region(struct weston_surface *es, pixman_region32_t *region,
 				weston_surface_to_buffer_float(es, sx, sy,
 							       &bx, &by);
 				*(v++) = bx * inv_width;
-				*(v++) = by * inv_height;
+				if (y_inverted) {
+					*(v++) = by * inv_height;
+				} else {
+					*(v++) = (gs->height - by) * inv_height;
+				}
 			}
 
 			vtxcnt[nvtx++] = n;
@@ -1284,6 +1293,8 @@ gl_renderer_attach_egl(struct weston_surface *es, struct weston_buffer *buffer,
 			 EGL_WIDTH, &buffer->width);
 	gr->query_buffer(gr->egl_display, buffer->legacy_buffer,
 			 EGL_HEIGHT, &buffer->height);
+	gr->query_buffer(gr->egl_display, buffer->legacy_buffer,
+			 EGL_WAYLAND_Y_INVERTED_WL, &buffer->y_inverted);
 
 	for (i = 0; i < gs->num_images; i++)
 		gr->destroy_image(gr->egl_display, gs->images[i]);
diff --git a/src/weston-egl-ext.h b/src/weston-egl-ext.h
index 6aa49fd..5283214 100644
--- a/src/weston-egl-ext.h
+++ b/src/weston-egl-ext.h
@@ -62,6 +62,10 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYWAYLANDBUFFERWL) (EGLDisplay dpy, st
 #define EGL_BUFFER_AGE_EXT              0x313D
 #endif
 
+#ifndef EGL_WAYLAND_Y_INVERTED_WL
+#define EGL_WAYLAND_Y_INVERTED_WL		0x31D7 /* eglQueryWaylandBufferWL attribute */
+#endif
+
 /* Mesas gl2ext.h and probably Khronos upstream defined
  * GL_EXT_unpack_subimage with non _EXT suffixed GL_UNPACK_* tokens.
  * In case we're using that mess, manually define the _EXT versions
-- 
1.7.9.5



More information about the wayland-devel mailing list