---
 src/gles2-renderer.c | 48 +++++++++++++++++++++++++++++-------------------
 1 file changed, 29 insertions(+), 19 deletions(-)

diff --git a/src/gles2-renderer.c b/src/gles2-renderer.c
index 37e9b76..d4a4fc8 100644
--- a/src/gles2-renderer.c
+++ b/src/gles2-renderer.c
@@ -605,6 +605,29 @@ repaint_region(struct weston_surface *es, 
pixman_region32_t *region,
        ec->vtxcnt.size = 0;
 }
 
+static int
+use_output(struct weston_output *output)
+{
+       static int errored;
+       struct gles2_output_state *state = get_output_state(output);
+       struct weston_compositor *ec = output->compositor;
+       EGLBoolean ret;
+
+       ret = eglMakeCurrent(ec->egl_display, state->egl_surface,
+                            state->egl_surface, ec->egl_context);
+
+       if (ret == EGL_FALSE) {
+               if(errored)
+                       return -1;
+               errored = 1;
+               weston_log("Failed to make EGL context current.\n");
+               print_egl_error_state();
+               return -1;
+       }
+
+       return 0;
+}
+
 static void
 weston_compositor_use_shader(struct weston_compositor *compositor,
                             struct weston_shader *shader)
@@ -742,16 +765,8 @@ gles2_renderer_repaint_output(struct weston_output *output,
 
        glViewport(0, 0, width, height);
 
-       ret = eglMakeCurrent(compositor->egl_display, output_state->egl_surface,
-                            output_state->egl_surface, 
compositor->egl_context);
-       if (ret == EGL_FALSE) {
-               if (errored)
-                       return;
-               errored = 1;
-               weston_log("Failed to make EGL context current.\n");
-               print_egl_error_state();
+       if(use_output(output) < 0)
                return;
-       }
 
        /* if debugging, redraw everything outside the damage to clean up
         * debug lines from the previous draw on this buffer:
@@ -1356,8 +1371,7 @@ gles2_renderer_outputs_ready(struct weston_compositor *ec)
 {
        const char *extensions;
        int has_egl_image_external = 0;
-       struct gles2_output_state *output;
-       EGLBoolean ret;
+       struct weston_output *output;
 
        static const EGLint context_attribs[] = {
                EGL_CONTEXT_CLIENT_VERSION, 2,
@@ -1377,15 +1391,11 @@ gles2_renderer_outputs_ready(struct weston_compositor 
*ec)
                return -1;
        }
 
-       output = get_output_state(container_of(ec->output_list.next,
-                             struct weston_output, link));
-       ret = eglMakeCurrent(ec->egl_display, output->egl_surface,
-                            output->egl_surface, ec->egl_context);
-       if (ret == EGL_FALSE) {
-               weston_log("Failed to make EGL context current.\n");
-               print_egl_error_state();
+       output = container_of(ec->output_list.next,
+                             struct weston_output, link);
+
+       if(use_output(output) < 0)
                return -1;
-       }
 
        log_egl_gl_info(ec->egl_display);
 
-- 
1.7.12

_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to