From 9d84a922b86e371e53b44baeb49cabfff28f2bc1 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Tue, 5 Feb 2019 15:19:46 +0000 Subject: egl/dri: de-duplicate dri2_load_driver* The difference between the three functions is the list of mandatory driver extensions. Pass that as an argument to the common helper. Signed-off-by: Emil Velikov Reviewed-by: Frank Binns Reviewed-by: Eric Engestrom --- src/egl/drivers/dri2/egl_dri2.c | 45 ++++++++++------------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) (limited to 'src/egl') diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 0f417e571bb..8721e67afb3 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -513,8 +513,9 @@ dri2_open_driver(_EGLDisplay *disp) search_path_vars); } -EGLBoolean -dri2_load_driver_dri3(_EGLDisplay *disp) +static EGLBoolean +dri2_load_driver_common(_EGLDisplay *disp, + const struct dri2_extension_match *driver_extensions) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); const __DRIextension **extensions; @@ -523,7 +524,7 @@ dri2_load_driver_dri3(_EGLDisplay *disp) if (!extensions) return EGL_FALSE; - if (!dri2_bind_extensions(dri2_dpy, dri3_driver_extensions, extensions, false)) { + if (!dri2_bind_extensions(dri2_dpy, driver_extensions, extensions, false)) { dlclose(dri2_dpy->driver); return EGL_FALSE; } @@ -537,43 +538,19 @@ dri2_load_driver_dri3(_EGLDisplay *disp) EGLBoolean dri2_load_driver(_EGLDisplay *disp) { - struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - const __DRIextension **extensions; - - extensions = dri2_open_driver(disp); - if (!extensions) - return EGL_FALSE; - - if (!dri2_bind_extensions(dri2_dpy, dri2_driver_extensions, extensions, false)) { - dlclose(dri2_dpy->driver); - return EGL_FALSE; - } - dri2_dpy->driver_extensions = extensions; - - dri2_bind_extensions(dri2_dpy, optional_driver_extensions, extensions, true); + return dri2_load_driver_common(disp, dri2_driver_extensions); +} - return EGL_TRUE; +EGLBoolean +dri2_load_driver_dri3(_EGLDisplay *disp) +{ + return dri2_load_driver_common(disp, dri3_driver_extensions); } EGLBoolean dri2_load_driver_swrast(_EGLDisplay *disp) { - struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - const __DRIextension **extensions; - - extensions = dri2_open_driver(disp); - if (!extensions) - return EGL_FALSE; - - if (!dri2_bind_extensions(dri2_dpy, swrast_driver_extensions, extensions, false)) { - dlclose(dri2_dpy->driver); - return EGL_FALSE; - } - dri2_dpy->driver_extensions = extensions; - - dri2_bind_extensions(dri2_dpy, optional_driver_extensions, extensions, true); - - return EGL_TRUE; + return dri2_load_driver_common(disp, swrast_driver_extensions); } static unsigned -- cgit v1.2.3