gl_renderer: Use EGL_WAYLAND_Y_INVERTED_WL to query wl_buffer's orientation

dev
Stanislav Vorobiov 11 years ago committed by Kristian Høgsberg
parent 9a6f02a6b1
commit bfbb8e59fa
  1. 1
      src/compositor.c
  2. 1
      src/compositor.h
  3. 14
      src/gl-renderer.c
  4. 4
      src/weston-egl-ext.h

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

@ -611,6 +611,7 @@ struct weston_buffer {
};
int32_t width, height;
uint32_t busy_count;
int y_inverted;
};
struct weston_buffer_reference {

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

@ -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

Loading…
Cancel
Save