[PATCH weston 3/4] gl-renderer: use eglCreatePlatformWindowSurfaceEXT to get EGLSurfaces

Bryce Harrington bryce at osg.samsung.com
Mon Mar 16 13:34:00 PDT 2015


On Wed, Feb 25, 2015 at 01:42:12PM +0100, Jonny Lamb wrote:
> ---
>  src/compositor-drm.c     |  3 ++-
>  src/compositor-fbdev.c   |  2 +-
>  src/compositor-wayland.c |  1 +
>  src/compositor-x11.c     |  5 +++++
>  src/gl-renderer.c        | 42 +++++++++++++++++++++++++++++++++++++-----
>  src/gl-renderer.h        |  3 ++-
>  6 files changed, 48 insertions(+), 8 deletions(-)
> 
> diff --git a/src/compositor-drm.c b/src/compositor-drm.c
> index e1fe958..892c93a 100644
> --- a/src/compositor-drm.c
> +++ b/src/compositor-drm.c
> @@ -1622,7 +1622,8 @@ drm_output_init_egl(struct drm_output *output, struct drm_compositor *ec)
>  		return -1;
>  	}
>  
> -	if (gl_renderer->output_create(&output->base, output->surface,
> +	if (gl_renderer->output_create(&output->base,
> +				       output->surface, output->surface,
>  				       gl_renderer->opaque_attribs,
>  				       &format) < 0) {
>  		weston_log("failed to create gl renderer output state\n");
> diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
> index 41b43f1..411adf3 100644
> --- a/src/compositor-fbdev.c
> +++ b/src/compositor-fbdev.c
> @@ -625,7 +625,7 @@ fbdev_output_create(struct fbdev_compositor *compositor,
>  	} else {
>  		setenv("HYBRIS_EGLPLATFORM", "wayland", 1);
>  		if (gl_renderer->output_create(&output->base,
> -					       (EGLNativeWindowType)NULL,
> +					       (EGLNativeWindowType)NULL, NULL,
>  					       gl_renderer->opaque_attribs,
>  					       NULL) < 0) {
>  			weston_log("gl_renderer_output_create failed.\n");
> diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
> index b6fd37d..4f792b1 100644
> --- a/src/compositor-wayland.c
> +++ b/src/compositor-wayland.c
> @@ -645,6 +645,7 @@ wayland_output_init_gl_renderer(struct wayland_output *output)
>  
>  	if (gl_renderer->output_create(&output->base,
>  				       output->gl.egl_window,
> +				       output->gl.egl_window,
>  				       gl_renderer->alpha_attribs,
>  				       NULL) < 0)
>  		goto cleanup_window;
> diff --git a/src/compositor-x11.c b/src/compositor-x11.c
> index fb8c08c..39dc88e 100644
> --- a/src/compositor-x11.c
> +++ b/src/compositor-x11.c
> @@ -904,8 +904,13 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y,
>  			return NULL;
>  		}
>  	} else {
> +		/* eglCreatePlatformWindowSurfaceEXT takes a Window*
> +		 * but eglCreateWindowSurface takes a Window. */
> +		Window xid = (Window) output->window;
> +
>  		ret = gl_renderer->output_create(&output->base,
>  						 (EGLNativeWindowType) output->window,
> +						 &xid,
>  						 gl_renderer->opaque_attribs,
>  						 NULL);
>  		if (ret < 0)
> diff --git a/src/gl-renderer.c b/src/gl-renderer.c
> index 3b74b89..3b96e39 100644
> --- a/src/gl-renderer.c
> +++ b/src/gl-renderer.c
> @@ -136,6 +136,10 @@ struct gl_renderer {
>  	PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC swap_buffers_with_damage;
>  #endif
>  
> +#ifdef EGL_EXT_platform_base
> +	PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC create_platform_window;
> +#endif
> +
>  	int has_unpack_subimage;
>  
>  	PFNEGLBINDWAYLANDDISPLAYWL bind_display;
> @@ -1797,7 +1801,8 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface);
>  
>  static int
>  gl_renderer_output_create(struct weston_output *output,
> -			  EGLNativeWindowType window,
> +			  EGLNativeWindowType window_for_legacy,
> +			  void *window_for_platform,
>  			  const EGLint *attribs,
>  			  const EGLint *visual_id)
>  {
> @@ -1824,10 +1829,22 @@ gl_renderer_output_create(struct weston_output *output,
>  	if (go == NULL)
>  		return -1;
>  
> -	go->egl_surface =
> -		eglCreateWindowSurface(gr->egl_display,
> -				       egl_config,
> -				       window, NULL);
> +#ifdef EGL_EXT_platform_base
> +	if (gr->create_platform_window) {
> +		go->egl_surface =
> +			gr->create_platform_window(gr->egl_display,
> +						   egl_config,
> +						   window_for_platform,
> +						   NULL);
> +	} else {
> +#endif
> +		go->egl_surface =
> +			eglCreateWindowSurface(gr->egl_display,
> +					       egl_config,
> +					       window_for_legacy, NULL);
> +#ifdef EGL_EXT_platform_base
> +	}
> +#endif

Since the else branch only has one call you can dispense with the
brackets to avoid the second #ifdef.


>  	if (go->egl_surface == EGL_NO_SURFACE) {
>  		weston_log("failed to create egl surface\n");
> @@ -1947,6 +1964,21 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec)
>  			   "supported. Performance could be affected.\n");
>  #endif
>  
> +#ifdef EGL_EXT_platform_base
> +	extensions =
> +		(const char *) eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
> +	if (!extensions) {
> +		weston_log("Retrieving EGL client extension string failed.\n");
> +		return -1;
> +	}
> +
> +	if (strstr(extensions, "EGL_EXT_platform_base"))
> +		gr->create_platform_window =
> +			(void *) eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
> +	else
> +		weston_log("warning: EGL_EXT_platform_base not supported.\n");
> +#endif
> +
>  #ifdef EGL_MESA_configless_context
>  	if (strstr(extensions, "EGL_MESA_configless_context"))
>  		gr->has_configless_context = 1;
> diff --git a/src/gl-renderer.h b/src/gl-renderer.h
> index bbf0ac6..c5550d1 100644
> --- a/src/gl-renderer.h
> +++ b/src/gl-renderer.h
> @@ -62,7 +62,8 @@ struct gl_renderer_interface {
>  	EGLDisplay (*display)(struct weston_compositor *ec);
>  
>  	int (*output_create)(struct weston_output *output,
> -			     EGLNativeWindowType window,
> +			     EGLNativeWindowType window_for_legacy,
> +			     void *window_for_platform,
>  			     const EGLint *attribs,
>  			     const EGLint *visual_id);
>  
> -- 
> 2.1.4
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list