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

Pekka Paalanen ppaalanen at gmail.com
Mon Mar 23 03:46:19 PDT 2015


On Fri, 20 Mar 2015 15:26:52 +0100
Jonny Lamb <jonny.lamb at collabora.co.uk> wrote:

> Reviewed-by: Derek Foreman <derekf at osg.samsung.com>
> Reviewed-by: Bryce Harrington <bryce at osg.samsung.com>
> ---
>  src/compositor-drm.c     |  3 ++-
>  src/compositor-fbdev.c   |  2 +-
>  src/compositor-wayland.c |  1 +
>  src/compositor-x11.c     |  5 +++++
>  src/gl-renderer.c        | 39 ++++++++++++++++++++++++++++++++++-----
>  src/gl-renderer.h        |  3 ++-
>  6 files changed, 45 insertions(+), 8 deletions(-)
> 

> diff --git a/src/gl-renderer.c b/src/gl-renderer.c
> index e598d1e..d4e8f1e 100644
> --- a/src/gl-renderer.c
> +++ b/src/gl-renderer.c
> @@ -140,6 +140,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;
> @@ -1974,7 +1978,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)
>  {
> @@ -2001,10 +2006,19 @@ 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);
>  
>  	if (go->egl_surface == EGL_NO_SURFACE) {
>  		weston_log("failed to create egl surface\n");
> @@ -2124,6 +2138,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");

Aah! So here is the runtime check for platform_base. Shouldn't this
have been done also in patches 1 and 2 when getting the
eglGetPlatformDisplayEXT pointer instead of just relying on
eglGetProcAddress returning NULL if it's not there?


Thanks,
pq

> +	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);
>  



More information about the wayland-devel mailing list