---
 src/compositor-android.c |  9 +++++++--
 src/compositor-drm.c     | 13 ++++++++-----
 src/compositor-wayland.c | 11 +++++++----
 src/compositor-x11.c     | 10 ++++++----
 src/compositor.h         |  4 ++++
 src/gles2-renderer.c     | 12 ++++++++++++
 6 files changed, 44 insertions(+), 15 deletions(-)

diff --git a/src/compositor-android.c b/src/compositor-android.c
index 50c66e6..669c456 100644
--- a/src/compositor-android.c
+++ b/src/compositor-android.c
@@ -145,6 +145,8 @@ android_output_destroy(struct weston_output *base)
        wl_list_remove(&output->base.link);
        weston_output_destroy(&output->base);
 
+       gles2_renderer_surface_destroy(base);
+
        android_framebuffer_destroy(output->fb);
 
        free(output);
@@ -373,6 +375,7 @@ android_init_egl(struct android_compositor *compositor,
                 struct android_output *output)
 {
        EGLint eglmajor, eglminor;
+       EGLSurface egl_surface;
        int ret;
 
        static const EGLint config_attrs[] = {
@@ -406,17 +409,19 @@ android_init_egl(struct android_compositor *compositor,
                return -1;
        }
 
-       output->base.egl_surface =
+       egl_surface =
                eglCreateWindowSurface(compositor->base.egl_display,
                                       compositor->base.egl_config,
                                       output->fb->native_window,
                                       NULL);
-       if (output->base.egl_surface == EGL_NO_SURFACE) {
+       if (egl_surface == EGL_NO_SURFACE) {
                weston_log("Failed to create FB EGLSurface.\n");
                print_egl_error_state();
                return -1;
        }
 
+       gles2_renderer_surface_create(&output->base, egl_surface);
+
        return 0;
 }
 
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 0faf45c..2f117c6 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -862,7 +862,7 @@ drm_output_destroy(struct weston_output *output_base)
        c->crtc_allocator &= ~(1 << output->crtc_id);
        c->connector_allocator &= ~(1 << output->connector_id);
 
-       eglDestroySurface(c->base.egl_display, output->base.egl_surface);
+       gles2_renderer_surface_destroy(output_base);
        gbm_surface_destroy(output->surface);
 
        weston_plane_release(&output->fb_plane);
@@ -1006,10 +1006,10 @@ drm_output_switch_mode(struct weston_output 
*output_base, struct weston_mode *mo
        }
        output->next = NULL;
 
-       eglDestroySurface(ec->base.egl_display, output->base.egl_surface);
+       gles2_renderer_surface_destroy(output_base);
        gbm_surface_destroy(output->surface);
-       output->base.egl_surface = egl_surface;
        output->surface = surface;
+       gles2_renderer_surface_create(&output->base, egl_surface);
 
        /*update output*/
        output->base.current = &drm_mode->base;
@@ -1318,6 +1318,7 @@ create_output_for_connector(struct drm_compositor *ec,
        int i;
        char name[32];
        const char *type_name;
+       EGLSurface egl_surface;
 
        i = find_crtc_for_connector(ec, resources, connector);
        if (i < 0) {
@@ -1446,16 +1447,18 @@ create_output_for_connector(struct drm_compositor *ec,
                goto err_free;
        }
 
-       output->base.egl_surface =
+       egl_surface =
                eglCreateWindowSurface(ec->base.egl_display,
                                       ec->base.egl_config,
                                       output->surface,
                                       NULL);
-       if (output->base.egl_surface == EGL_NO_SURFACE) {
+       if (egl_surface == EGL_NO_SURFACE) {
                weston_log("failed to create egl surface\n");
                goto err_surface;
        }
 
+       gles2_renderer_surface_create(&output->base, egl_surface);
+
        output->cursor_bo[0] =
                gbm_bo_create(ec->gbm, 64, 64, GBM_FORMAT_ARGB8888,
                              GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_WRITE);
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index d665641..948d870 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -323,9 +323,9 @@ static void
 wayland_output_destroy(struct weston_output *output_base)
 {
        struct wayland_output *output = (struct wayland_output *) output_base;
-       struct weston_compositor *ec = output->base.compositor;
 
-       eglDestroySurface(ec->egl_display, output->base.egl_surface);
+       gles2_renderer_surface_destroy(output_base);
+
        wl_egl_window_destroy(output->parent.egl_window);
        free(output);
 
@@ -339,6 +339,7 @@ wayland_compositor_create_output(struct wayland_compositor 
*c,
                                 int width, int height)
 {
        struct wayland_output *output;
+       EGLSurface egl_surface;
 
        output = malloc(sizeof *output);
        if (output == NULL)
@@ -379,14 +380,16 @@ wayland_compositor_create_output(struct 
wayland_compositor *c,
                goto cleanup_output;
        }
 
-       output->base.egl_surface =
+       egl_surface =
                eglCreateWindowSurface(c->base.egl_display, c->base.egl_config,
                                       output->parent.egl_window, NULL);
-       if (!output->base.egl_surface) {
+       if (!egl_surface) {
                weston_log("failed to create window surface\n");
                goto cleanup_window;
        }
 
+       gles2_renderer_surface_create(&output->base, egl_surface);
+
        output->parent.shell_surface =
                wl_shell_get_shell_surface(c->parent.shell,
                                           output->parent.surface);
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 7ec56ff..ee1b519 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -319,8 +319,7 @@ x11_output_destroy(struct weston_output *output_base)
        wl_list_remove(&output->base.link);
        wl_event_source_remove(output->finish_frame_timer);
 
-       eglDestroySurface(compositor->base.egl_display,
-                         output->base.egl_surface);
+       gles2_renderer_surface_destroy(output_base);
 
        xcb_destroy_window(compositor->conn, output->window);
 
@@ -436,6 +435,7 @@ x11_compositor_create_output(struct x11_compositor *c, int 
x, int y,
        xcb_screen_iterator_t iter;
        struct wm_normal_hints normal_hints;
        struct wl_event_loop *loop;
+       EGLSurface egl_surface;
        uint32_t mask = XCB_CW_EVENT_MASK | XCB_CW_CURSOR;
        uint32_t values[2] = {
                XCB_EVENT_MASK_EXPOSURE |
@@ -526,14 +526,16 @@ x11_compositor_create_output(struct x11_compositor *c, 
int x, int y,
                x11_output_change_state(output, 1,
                                        c->atom.net_wm_state_fullscreen);
 
-       output->base.egl_surface = 
+       egl_surface =
                eglCreateWindowSurface(c->base.egl_display, c->base.egl_config,
                                       output->window, NULL);
-       if (!output->base.egl_surface) {
+       if (!egl_surface) {
                weston_log("failed to create window surface\n");
                return NULL;
        }
 
+       gles2_renderer_surface_create(&output->base, egl_surface);
+
        loop = wl_display_get_event_loop(c->base.wl_display);
        output->finish_frame_timer =
                wl_event_loop_add_timer(loop, finish_frame_handler, output);
diff --git a/src/compositor.h b/src/compositor.h
index 0d1699f..733f423 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -796,6 +796,10 @@ weston_output_switch_mode(struct weston_output *output, 
struct weston_mode *mode
 int
 gles2_renderer_init(struct weston_compositor *ec);
 void
+gles2_renderer_surface_create(struct weston_output *output, EGLSurface 
egl_surface);
+void
+gles2_renderer_surface_destroy(struct weston_output *output);
+void
 gles2_renderer_destroy(struct weston_compositor *ec);
 
 struct weston_compositor *
diff --git a/src/gles2-renderer.c b/src/gles2-renderer.c
index 0e8b8ce..54d380a 100644
--- a/src/gles2-renderer.c
+++ b/src/gles2-renderer.c
@@ -1127,6 +1127,18 @@ struct gles2_renderer {
 };
 
 WL_EXPORT void
+gles2_renderer_surface_create(struct weston_output *output, EGLSurface 
egl_surface)
+{
+       output->egl_surface = egl_surface;
+}
+
+WL_EXPORT void
+gles2_renderer_surface_destroy(struct weston_output *output)
+{
+       eglDestroySurface(output->compositor->egl_display, output->egl_surface);
+}
+
+WL_EXPORT void
 gles2_renderer_destroy(struct weston_compositor *ec)
 {
        if (ec->has_bind_display)
-- 
1.7.12

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to