egl: drop an indentation level in _eglFindDisplay() by replacing break/if with a...
[mesa.git] / src / egl / drivers / dri2 / platform_surfaceless.c
index 212b5c1434303b4cd2d23f2a3cea9e689a1a2d80..dd283673a8374a506cfee80871916ffe8190fa7e 100644 (file)
@@ -34,7 +34,6 @@
 #include <unistd.h>
 
 #include "egl_dri2.h"
-#include "egl_dri2_fallbacks.h"
 #include "loader.h"
 
 static __DRIimage*
@@ -109,8 +108,8 @@ surfaceless_image_get_buffers(__DRIdrawable *driDrawable,
 }
 
 static _EGLSurface *
-dri2_surfaceless_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
-                        _EGLConfig *conf, const EGLint *attrib_list)
+dri2_surfaceless_create_surface(_EGLDisplay *disp, EGLint type,
+                                _EGLConfig *conf, const EGLint *attrib_list)
 {
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
    struct dri2_egl_config *dri2_conf = dri2_egl_config(conf);
@@ -154,7 +153,7 @@ dri2_surfaceless_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
 }
 
 static EGLBoolean
-surfaceless_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
+surfaceless_destroy_surface(_EGLDisplay *disp, _EGLSurface *surf)
 {
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
    struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
@@ -169,70 +168,17 @@ surfaceless_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *sur
 }
 
 static _EGLSurface *
-dri2_surfaceless_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp,
-                                _EGLConfig *conf, const EGLint *attrib_list)
+dri2_surfaceless_create_pbuffer_surface(_EGLDisplay *disp, _EGLConfig *conf,
+                                        const EGLint *attrib_list)
 {
-   return dri2_surfaceless_create_surface(drv, disp, EGL_PBUFFER_BIT, conf,
+   return dri2_surfaceless_create_surface(disp, EGL_PBUFFER_BIT, conf,
                                   attrib_list);
 }
 
-static EGLBoolean
-surfaceless_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp)
-{
-   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
-   static const struct {
-      const char *format_name;
-      int rgba_shifts[4];
-      unsigned int rgba_sizes[4];
-   } visuals[] = {
-      { "ABGR16F",  { 0, 16, 32, 48 }, { 16, 16, 16, 16 } },
-      { "XBGR16F",  { 0, 16, 32, -1 }, { 16, 16, 16, 0 } },
-      { "A2RGB10",  { 20, 10, 0, 30 }, { 10, 10, 10, 2 } },
-      { "X2RGB10",  { 20, 10, 0, -1 }, { 10, 10, 10, 0 } },
-      { "ARGB8888", { 16, 8, 0, 24 }, { 8, 8, 8, 8 } },
-      { "RGB888",   { 16, 8, 0, -1 }, { 8, 8, 8, 0 } },
-      { "RGB565",   { 11, 5, 0, -1 }, { 5, 6, 5, 0 } },
-   };
-   unsigned int format_count[ARRAY_SIZE(visuals)] = { 0 };
-   unsigned int config_count = 0;
-
-   for (unsigned i = 0; dri2_dpy->driver_configs[i] != NULL; i++) {
-      for (unsigned j = 0; j < ARRAY_SIZE(visuals); j++) {
-         struct dri2_egl_config *dri2_conf;
-
-         dri2_conf = dri2_add_config(disp, dri2_dpy->driver_configs[i],
-               config_count + 1, EGL_PBUFFER_BIT, NULL,
-               visuals[j].rgba_shifts, visuals[j].rgba_sizes);
-
-         if (dri2_conf) {
-            if (dri2_conf->base.ConfigID == config_count + 1)
-               config_count++;
-            format_count[j]++;
-         }
-      }
-   }
-
-   for (unsigned i = 0; i < ARRAY_SIZE(format_count); i++) {
-      if (!format_count[i]) {
-         _eglLog(_EGL_DEBUG, "No DRI config supports native format %s",
-               visuals[i].format_name);
-      }
-   }
-
-   return (config_count != 0);
-}
-
 static const struct dri2_egl_display_vtbl dri2_surfaceless_display_vtbl = {
-   .create_pixmap_surface = dri2_fallback_create_pixmap_surface,
    .create_pbuffer_surface = dri2_surfaceless_create_pbuffer_surface,
    .destroy_surface = surfaceless_destroy_surface,
    .create_image = dri2_create_image_khr,
-   .swap_buffers_region = dri2_fallback_swap_buffers_region,
-   .post_sub_buffer = dri2_fallback_post_sub_buffer,
-   .copy_buffers = dri2_fallback_copy_buffers,
-   .query_buffer_age = dri2_fallback_query_buffer_age,
-   .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image,
-   .get_sync_values = dri2_fallback_get_sync_values,
    .get_dri_drawable = dri2_surface_get_dri_drawable,
 };
 
@@ -280,7 +226,7 @@ surfaceless_probe_device(_EGLDisplay *disp, bool swrast)
 {
 #define MAX_DRM_DEVICES 64
    const unsigned node_type = swrast ? DRM_NODE_PRIMARY : DRM_NODE_RENDER;
-   struct dri2_egl_display *dri2_dpy = disp->DriverData;
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
    drmDevicePtr device, devices[MAX_DRM_DEVICES] = { NULL };
    int i, num_devices;
 
@@ -346,7 +292,7 @@ surfaceless_probe_device(_EGLDisplay *disp, bool swrast)
 static bool
 surfaceless_probe_device_sw(_EGLDisplay *disp)
 {
-   struct dri2_egl_display *dri2_dpy = disp->DriverData;
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
 
    dri2_dpy->fd = -1;
    disp->Device = _eglAddDevice(dri2_dpy->fd, true);
@@ -367,7 +313,7 @@ surfaceless_probe_device_sw(_EGLDisplay *disp)
 }
 
 EGLBoolean
-dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp)
+dri2_initialize_surfaceless(_EGLDisplay *disp)
 {
    struct dri2_egl_display *dri2_dpy;
    const char* err;
@@ -412,9 +358,9 @@ dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp)
 #ifdef HAVE_WAYLAND_PLATFORM
    dri2_dpy->device_name = loader_get_device_name_for_fd(dri2_dpy->fd);
 #endif
-   dri2_set_WL_bind_wayland_display(drv, disp);
+   dri2_set_WL_bind_wayland_display(disp);
 
-   if (!surfaceless_add_configs_for_visuals(drv, disp)) {
+   if (!dri2_add_pbuffer_configs_for_visuals(disp)) {
       err = "DRI2: failed to add configs";
       goto cleanup;
    }