[PATCH v2] gl_renderer: Use EGL_WAYLAND_Y_INVERTED_WL to query wl_buffer's orientation
Kristian Høgsberg
hoegsberg at gmail.com
Wed Sep 11 11:12:30 PDT 2013
On Thu, Aug 29, 2013 at 11:36:44AM +0400, Stanislav Vorobiov wrote:
> ---
> src/compositor.c | 1 +
> src/compositor.h | 1 +
> src/gl-renderer.c | 14 +++++++++++++-
> src/weston-egl-ext.h | 4 ++++
> 4 files changed, 19 insertions(+), 1 deletion(-)
Yeah, I think this looks good now. We need to document the new token
in the spec in mesa at least, in particular that if querying for
EGL_WAYLAND_Y_INVERTED_WL returns false, fall back to y-inverted.
thanks,
Kristian
> diff --git a/src/compositor.c b/src/compositor.c
> index 74f0aab..8c9e0fe 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 6db3c61..cb15d69 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -605,6 +605,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..0eee09e 100644
> --- a/src/gl-renderer.c
> +++ b/src/gl-renderer.c
> @@ -77,6 +77,7 @@ struct gl_surface_state {
> enum buffer_type buffer_type;
> int pitch; /* in pixels */
> int height; /* in pixels */
> + int y_inverted;
> };
>
> struct gl_renderer {
> @@ -599,7 +600,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 (gs->y_inverted) {
> + *(v++) = by * inv_height;
> + } else {
> + *(v++) = (gs->height - by) * inv_height;
> + }
> }
>
> vtxcnt[nvtx++] = n;
> @@ -1260,6 +1265,7 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer,
> gs->target = GL_TEXTURE_2D;
> gs->buffer_type = BUFFER_TYPE_SHM;
> gs->needs_full_upload = 1;
> + gs->y_inverted = 1;
>
> ensure_textures(gs, 1);
> glBindTexture(GL_TEXTURE_2D, gs->textures[0]);
> @@ -1284,6 +1290,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]);
> @@ -1340,6 +1348,7 @@ gl_renderer_attach_egl(struct weston_surface *es, struct weston_buffer *buffer,
> gs->pitch = buffer->width;
> gs->height = buffer->height;
> gs->buffer_type = BUFFER_TYPE_EGL;
> + gs->y_inverted = buffer->y_inverted;
> }
>
> static void
> @@ -1363,6 +1372,7 @@ gl_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
> glDeleteTextures(gs->num_textures, gs->textures);
> gs->num_textures = 0;
> gs->buffer_type = BUFFER_TYPE_NULL;
> + gs->y_inverted = 1;
> return;
> }
>
> @@ -1377,6 +1387,7 @@ gl_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
> weston_log("unhandled buffer type!\n");
> weston_buffer_reference(&gs->buffer_ref, NULL);
> gs->buffer_type = BUFFER_TYPE_NULL;
> + gs->y_inverted = 1;
> }
> }
>
> @@ -1409,6 +1420,7 @@ gl_renderer_create_surface(struct weston_surface *surface)
> * by zero there.
> */
> gs->pitch = 1;
> + gs->y_inverted = 1;
>
> pixman_region32_init(&gs->texture_damage);
> surface->renderer_state = gs;
> diff --git a/src/weston-egl-ext.h b/src/weston-egl-ext.h
> index 6aa49fd..bab87be 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 0x31DB /* 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
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list