[PATCH weston 6/7] Split gl_renderer_setup into two functions

Neil Roberts neil at linux.intel.com
Fri Mar 7 10:05:49 PST 2014


Part of the gl_renderer_setup function only deals with checking EGL
extensions and doesn't need to have a current context. This patch
moves these checks so that they are done during gl_renderer_create
instead of waiting until we have an output. We will need this in a
later patch because some of the EGL extensions will affect how we
create the EGLSurface.
---
 src/gl-renderer.c | 90 ++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 52 insertions(+), 38 deletions(-)

diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index 76325f4..868fdb7 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -1818,6 +1818,55 @@ out:
 	return -1;
 }
 
+static int
+gl_renderer_setup_egl_extensions(struct weston_compositor *ec)
+{
+	struct gl_renderer *gr = get_renderer(ec);
+	const char *extensions;
+	EGLBoolean ret;
+
+	gr->create_image = (void *) eglGetProcAddress("eglCreateImageKHR");
+	gr->destroy_image = (void *) eglGetProcAddress("eglDestroyImageKHR");
+	gr->bind_display =
+		(void *) eglGetProcAddress("eglBindWaylandDisplayWL");
+	gr->unbind_display =
+		(void *) eglGetProcAddress("eglUnbindWaylandDisplayWL");
+	gr->query_buffer =
+		(void *) eglGetProcAddress("eglQueryWaylandBufferWL");
+
+	extensions =
+		(const char *) eglQueryString(gr->egl_display, EGL_EXTENSIONS);
+	if (!extensions) {
+		weston_log("Retrieving EGL extension string failed.\n");
+		return -1;
+	}
+
+	if (strstr(extensions, "EGL_WL_bind_wayland_display"))
+		gr->has_bind_display = 1;
+	if (gr->has_bind_display) {
+		ret = gr->bind_display(gr->egl_display, ec->wl_display);
+		if (!ret)
+			gr->has_bind_display = 0;
+	}
+
+	if (strstr(extensions, "EGL_EXT_buffer_age"))
+		gr->has_egl_buffer_age = 1;
+	else
+		weston_log("warning: EGL_EXT_buffer_age not supported. "
+			   "Performance could be affected.\n");
+
+#ifdef EGL_EXT_swap_buffers_with_damage
+	if (strstr(extensions, "EGL_EXT_swap_buffers_with_damage"))
+		gr->swap_buffers_with_damage =
+			(void *) eglGetProcAddress("eglSwapBuffersWithDamageEXT");
+	else
+		weston_log("warning: EGL_EXT_swap_buffers_with_damage not "
+			   "supported. Performance could be affected.\n");
+#endif
+
+	return 0;
+}
+
 static const EGLint gl_renderer_opaque_attribs[] = {
 	EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
 	EGL_RED_SIZE, 1,
@@ -1877,6 +1926,9 @@ gl_renderer_create(struct weston_compositor *ec, EGLNativeDisplayType display,
 	ec->capabilities |= WESTON_CAP_ROTATION_ANY;
 	ec->capabilities |= WESTON_CAP_CAPTURE_YFLIP;
 
+	if (gl_renderer_setup_egl_extensions(ec) < 0)
+		goto err_egl;
+
 	wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_RGB565);
 
 	wl_signal_init(&gr->destroy_signal);
@@ -2004,14 +2056,6 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
 
 	gr->image_target_texture_2d =
 		(void *) eglGetProcAddress("glEGLImageTargetTexture2DOES");
-	gr->create_image = (void *) eglGetProcAddress("eglCreateImageKHR");
-	gr->destroy_image = (void *) eglGetProcAddress("eglDestroyImageKHR");
-	gr->bind_display =
-		(void *) eglGetProcAddress("eglBindWaylandDisplayWL");
-	gr->unbind_display =
-		(void *) eglGetProcAddress("eglUnbindWaylandDisplayWL");
-	gr->query_buffer =
-		(void *) eglGetProcAddress("eglQueryWaylandBufferWL");
 
 	extensions = (const char *) glGetString(GL_EXTENSIONS);
 	if (!extensions) {
@@ -2037,36 +2081,6 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
 	if (strstr(extensions, "GL_OES_EGL_image_external"))
 		gr->has_egl_image_external = 1;
 
-	extensions =
-		(const char *) eglQueryString(gr->egl_display, EGL_EXTENSIONS);
-	if (!extensions) {
-		weston_log("Retrieving EGL extension string failed.\n");
-		return -1;
-	}
-
-	if (strstr(extensions, "EGL_WL_bind_wayland_display"))
-		gr->has_bind_display = 1;
-	if (gr->has_bind_display) {
-		ret = gr->bind_display(gr->egl_display, ec->wl_display);
-		if (!ret)
-			gr->has_bind_display = 0;
-	}
-
-	if (strstr(extensions, "EGL_EXT_buffer_age"))
-		gr->has_egl_buffer_age = 1;
-	else
-		weston_log("warning: EGL_EXT_buffer_age not supported. "
-			   "Performance could be affected.\n");
-
-#ifdef EGL_EXT_swap_buffers_with_damage
-	if (strstr(extensions, "EGL_EXT_swap_buffers_with_damage"))
-		gr->swap_buffers_with_damage =
-			(void *) eglGetProcAddress("eglSwapBuffersWithDamageEXT");
-	else
-		weston_log("warning: EGL_EXT_swap_buffers_with_damage not "
-			   "supported. Performance could be affected.\n");
-#endif
-
 	glActiveTexture(GL_TEXTURE0);
 
 	if (compile_shaders(ec))
-- 
1.8.5.3



More information about the wayland-devel mailing list