[Mesa-dev] [PATCH 10/12] egl/drm: remove unreachable code in dri2_drm_create_surface()

Eric Engestrom eric.engestrom at imgtec.com
Fri Aug 4 10:03:26 UTC 2017


On Thursday, 2017-08-03 19:29:36 +0100, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
> 
> The function can be called only when the type is EGL_WINDOW_BIT.
> Remove the unneeded switch statement.

I take it we plan on never supporting pbuffers or pixmaps in platform_drm?

If so, I'd rather fold dri2_drm_create_surface() into
dri2_drm_create_window_surface(), as `type` is meaningless now and should
be dropped, and without it the latter is an empty pass-through function.
(can/should be a separate commit, but please send both as a single series)

Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>

> 
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
>  src/egl/drivers/dri2/platform_drm.c | 20 +++++++-------------
>  1 file changed, 7 insertions(+), 13 deletions(-)
> 
> diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
> index 7ea43e62010..8d56fcb7698 100644
> --- a/src/egl/drivers/dri2/platform_drm.c
> +++ b/src/egl/drivers/dri2/platform_drm.c
> @@ -92,13 +92,13 @@ has_free_buffers(struct gbm_surface *_surf)
>  
>  static _EGLSurface *
>  dri2_drm_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
> -                        _EGLConfig *conf, void *native_window,
> +                        _EGLConfig *conf, void *native_surface,
>                          const EGLint *attrib_list)
>  {
>     struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
>     struct dri2_egl_config *dri2_conf = dri2_egl_config(conf);
>     struct dri2_egl_surface *dri2_surf;
> -   struct gbm_surface *window = native_window;
> +   struct gbm_surface *window = native_surface;
>     struct gbm_dri_surface *surf;
>     const __DRIconfig *config;
>  
> @@ -113,17 +113,11 @@ dri2_drm_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
>     if (!_eglInitSurface(&dri2_surf->base, disp, type, conf, attrib_list))
>        goto cleanup_surf;
>  
> -   switch (type) {
> -   case EGL_WINDOW_BIT:
> -      surf = gbm_dri_surface(window);
> -      dri2_surf->gbm_surf = surf;
> -      dri2_surf->base.Width =  surf->base.width;
> -      dri2_surf->base.Height = surf->base.height;
> -      surf->dri_private = dri2_surf;
> -      break;
> -   default:
> -      goto cleanup_surf;
> -   }
> +   surf = gbm_dri_surface(window);
> +   dri2_surf->gbm_surf = surf;
> +   dri2_surf->base.Width =  surf->base.width;
> +   dri2_surf->base.Height = surf->base.height;
> +   surf->dri_private = dri2_surf;
>  
>     config = dri2_get_dri_config(dri2_conf, EGL_WINDOW_BIT,
>                                  dri2_surf->base.GLColorspace);
> -- 
> 2.13.3
> 


More information about the mesa-dev mailing list