[PATCH v4 09/10] Move weston_compositor GL and EGL state into gles2-renderer.
John Kåre Alsaker
john.kare.alsaker at gmail.com
Mon Oct 29 14:17:17 PDT 2012
---
src/compositor.h | 12 -----------
src/gles2-renderer.c | 61 ++++++++++++++++++++++++++++++----------------------
2 files changed, 35 insertions(+), 38 deletions(-)
diff --git a/src/compositor.h b/src/compositor.h
index 76f9aa8..1f6a38f 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -331,20 +331,8 @@ struct weston_compositor {
struct weston_renderer *renderer;
- PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC
- image_target_renderbuffer_storage;
- PFNGLEGLIMAGETARGETTEXTURE2DOESPROC image_target_texture_2d;
- PFNEGLCREATEIMAGEKHRPROC create_image;
- PFNEGLDESTROYIMAGEKHRPROC destroy_image;
-
- int has_unpack_subimage;
pixman_format_code_t read_format;
- PFNEGLBINDWAYLANDDISPLAYWL bind_display;
- PFNEGLUNBINDWAYLANDDISPLAYWL unbind_display;
- PFNEGLQUERYWAYLANDBUFFERWL query_buffer;
- int has_bind_display;
-
void (*destroy)(struct weston_compositor *ec);
void (*restore)(struct weston_compositor *ec);
int (*authenticate)(struct weston_compositor *c, uint32_t id);
diff --git a/src/gles2-renderer.c b/src/gles2-renderer.c
index ae4d550..f389b11 100644
--- a/src/gles2-renderer.c
+++ b/src/gles2-renderer.c
@@ -68,6 +68,17 @@ struct gles2_renderer {
int32_t width, height;
} border;
+ PFNGLEGLIMAGETARGETTEXTURE2DOESPROC image_target_texture_2d;
+ PFNEGLCREATEIMAGEKHRPROC create_image;
+ PFNEGLDESTROYIMAGEKHRPROC destroy_image;
+
+ int has_unpack_subimage;
+
+ PFNEGLBINDWAYLANDDISPLAYWL bind_display;
+ PFNEGLUNBINDWAYLANDDISPLAYWL unbind_display;
+ PFNEGLQUERYWAYLANDBUFFERWL query_buffer;
+ int has_bind_display;
+
struct gles2_shader texture_shader_rgba;
struct gles2_shader texture_shader_rgbx;
struct gles2_shader texture_shader_egl_external;
@@ -999,6 +1010,7 @@ gles2_renderer_read_pixels(struct weston_output *output,
static void
gles2_renderer_flush_damage(struct weston_surface *surface)
{
+ struct gles2_renderer *gr = get_renderer(surface->compositor);
struct gles2_surface_state *gs = get_surface_state(surface);
#ifdef GL_UNPACK_ROW_LENGTH
@@ -1009,7 +1021,7 @@ gles2_renderer_flush_damage(struct weston_surface *surface)
glBindTexture(GL_TEXTURE_2D, gs->textures[0]);
- if (!surface->compositor->has_unpack_subimage) {
+ if (!gr->has_unpack_subimage) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
surface->pitch, surface->buffer->height, 0,
GL_BGRA_EXT, GL_UNSIGNED_BYTE,
@@ -1066,7 +1078,7 @@ gles2_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)
if (!buffer) {
for (i = 0; i < gs->num_images; i++) {
- ec->destroy_image(gr->egl_display, gs->images[i]);
+ gr->destroy_image(gr->egl_display, gs->images[i]);
gs->images[i] = NULL;
}
gs->num_images = 0;
@@ -1088,10 +1100,10 @@ gles2_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)
gs->shader = &gr->texture_shader_rgbx;
else
gs->shader = &gr->texture_shader_rgba;
- } else if (ec->query_buffer(gr->egl_display, buffer,
+ } else if (gr->query_buffer(gr->egl_display, buffer,
EGL_TEXTURE_FORMAT, &format)) {
for (i = 0; i < gs->num_images; i++)
- ec->destroy_image(gr->egl_display, gs->images[i]);
+ gr->destroy_image(gr->egl_display, gs->images[i]);
gs->num_images = 0;
gs->target = GL_TEXTURE_2D;
switch (format) {
@@ -1125,7 +1137,7 @@ gles2_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)
attribs[0] = EGL_WAYLAND_PLANE_WL;
attribs[1] = i;
attribs[2] = EGL_NONE;
- gs->images[i] = ec->create_image(gr->egl_display,
+ gs->images[i] = gr->create_image(gr->egl_display,
NULL,
EGL_WAYLAND_BUFFER_WL,
buffer, attribs);
@@ -1137,7 +1149,7 @@ gles2_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)
glActiveTexture(GL_TEXTURE0 + i);
glBindTexture(gs->target, gs->textures[i]);
- ec->image_target_texture_2d(gs->target,
+ gr->image_target_texture_2d(gs->target,
gs->images[i]);
}
@@ -1181,14 +1193,13 @@ static void
gles2_renderer_destroy_surface(struct weston_surface *surface)
{
struct gles2_surface_state *gs = get_surface_state(surface);
- struct weston_compositor *ec = surface->compositor;
- struct gles2_renderer *gr = get_renderer(ec);
+ struct gles2_renderer *gr = get_renderer(surface->compositor);
int i;
glDeleteTextures(gs->num_textures, gs->textures);
for (i = 0; i < gs->num_images; i++)
- ec->destroy_image(gr->egl_display, gs->images[i]);
+ gr->destroy_image(gr->egl_display, gs->images[i]);
free(gs);
}
@@ -1532,8 +1543,8 @@ gles2_renderer_destroy(struct weston_compositor *ec)
{
struct gles2_renderer *gr = get_renderer(ec);
- if (ec->has_bind_display)
- ec->unbind_display(gr->egl_display, ec->wl_display);
+ if (gr->has_bind_display)
+ gr->unbind_display(gr->egl_display, ec->wl_display);
/* Work around crash in egl_dri2.c's dri2_make_current() - when does this apply? */
eglMakeCurrent(gr->egl_display,
@@ -1646,17 +1657,15 @@ gles2_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
log_egl_gl_info(gr->egl_display);
- ec->image_target_texture_2d =
+ gr->image_target_texture_2d =
(void *) eglGetProcAddress("glEGLImageTargetTexture2DOES");
- ec->image_target_renderbuffer_storage = (void *)
- eglGetProcAddress("glEGLImageTargetRenderbufferStorageOES");
- ec->create_image = (void *) eglGetProcAddress("eglCreateImageKHR");
- ec->destroy_image = (void *) eglGetProcAddress("eglDestroyImageKHR");
- ec->bind_display =
+ gr->create_image = (void *) eglGetProcAddress("eglCreateImageKHR");
+ gr->destroy_image = (void *) eglGetProcAddress("eglDestroyImageKHR");
+ gr->bind_display =
(void *) eglGetProcAddress("eglBindWaylandDisplayWL");
- ec->unbind_display =
+ gr->unbind_display =
(void *) eglGetProcAddress("eglUnbindWaylandDisplayWL");
- ec->query_buffer =
+ gr->query_buffer =
(void *) eglGetProcAddress("eglQueryWaylandBufferWL");
extensions = (const char *) glGetString(GL_EXTENSIONS);
@@ -1676,7 +1685,7 @@ gles2_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
ec->read_format = PIXMAN_a8b8g8r8;
if (strstr(extensions, "GL_EXT_unpack_subimage"))
- ec->has_unpack_subimage = 1;
+ gr->has_unpack_subimage = 1;
if (strstr(extensions, "GL_OES_EGL_image_external"))
has_egl_image_external = 1;
@@ -1689,11 +1698,11 @@ gles2_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
}
if (strstr(extensions, "EGL_WL_bind_wayland_display"))
- ec->has_bind_display = 1;
- if (ec->has_bind_display) {
- ret = ec->bind_display(gr->egl_display, ec->wl_display);
+ gr->has_bind_display = 1;
+ if (gr->has_bind_display) {
+ ret = gr->bind_display(gr->egl_display, ec->wl_display);
if (!ret)
- ec->has_bind_display = 0;
+ gr->has_bind_display = 0;
}
glActiveTexture(GL_TEXTURE0);
@@ -1725,9 +1734,9 @@ gles2_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
weston_log_continue(STAMP_SPACE "read-back format: %s\n",
ec->read_format == GL_BGRA_EXT ? "BGRA" : "RGBA");
weston_log_continue(STAMP_SPACE "wl_shm sub-image to texture: %s\n",
- ec->has_unpack_subimage ? "yes" : "no");
+ gr->has_unpack_subimage ? "yes" : "no");
weston_log_continue(STAMP_SPACE "EGL Wayland extension: %s\n",
- ec->has_bind_display ? "yes" : "no");
+ gr->has_bind_display ? "yes" : "no");
return 0;
--
1.7.12.4
More information about the wayland-devel
mailing list