egl: directly access static members instead of using _egl{Get,Set}ConfigKey()
authorEric Engestrom <eric@engestrom.ch>
Thu, 13 Feb 2020 15:53:03 +0000 (15:53 +0000)
committerEric Engestrom <eric@engestrom.ch>
Fri, 14 Feb 2020 18:03:07 +0000 (18:03 +0000)
This function is meant for when the attribute is unknown at compile-time
(eg. user-specified), but in all these cases it is much simpler to just
read/write the member directly.

Suggested-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3816>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3816>

src/egl/drivers/dri2/egl_dri2.c
src/egl/drivers/dri2/platform_x11.c
src/egl/drivers/haiku/egl_haiku.cpp

index 23d0e469427db25301ea3f0d45be00ede0de14b0..b418d81c56b36a567250d58822513febe6ea360e 100644 (file)
@@ -281,15 +281,14 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
       switch (attrib) {
       case __DRI_ATTRIB_RENDER_TYPE:
          if (value & __DRI_ATTRIB_FLOAT_BIT)
-            _eglSetConfigKey(&base, EGL_COLOR_COMPONENT_TYPE_EXT,
-                             EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT);
+            base.ComponentType = EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT;
          if (value & __DRI_ATTRIB_RGBA_BIT)
             value = EGL_RGB_BUFFER;
          else if (value & __DRI_ATTRIB_LUMINANCE_BIT)
             value = EGL_LUMINANCE_BUFFER;
          else
             return NULL;
-         _eglSetConfigKey(&base, EGL_COLOR_BUFFER_TYPE, value);
+         base.ColorBufferType = value;
          break;
 
       case __DRI_ATTRIB_CONFIG_CAVEAT:
@@ -299,7 +298,7 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
             value = EGL_SLOW_CONFIG;
          else
             value = EGL_NONE;
-         _eglSetConfigKey(&base, EGL_CONFIG_CAVEAT, value);
+         base.ConfigCaveat = value;
          break;
 
       case __DRI_ATTRIB_BIND_TO_TEXTURE_RGB:
@@ -316,7 +315,7 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
 
       case __DRI_ATTRIB_RED_SIZE:
          dri_sizes[0] = value;
-         _eglSetConfigKey(&base, EGL_RED_SIZE, value);
+         base.RedSize = value;
          break;
 
       case __DRI_ATTRIB_RED_MASK:
@@ -329,7 +328,7 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
 
       case __DRI_ATTRIB_GREEN_SIZE:
          dri_sizes[1] = value;
-         _eglSetConfigKey(&base, EGL_GREEN_SIZE, value);
+         base.GreenSize = value;
          break;
 
       case __DRI_ATTRIB_GREEN_MASK:
@@ -342,7 +341,7 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
 
       case __DRI_ATTRIB_BLUE_SIZE:
          dri_sizes[2] = value;
-         _eglSetConfigKey(&base, EGL_BLUE_SIZE, value);
+         base.BlueSize = value;
          break;
 
       case __DRI_ATTRIB_BLUE_MASK:
@@ -355,7 +354,7 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
 
      case __DRI_ATTRIB_ALPHA_SIZE:
          dri_sizes[3] = value;
-         _eglSetConfigKey(&base, EGL_ALPHA_SIZE, value);
+         base.AlphaSize = value;
          break;
 
       case __DRI_ATTRIB_ALPHA_MASK:
@@ -382,12 +381,10 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
          break;
 
       case __DRI_ATTRIB_MAX_PBUFFER_WIDTH:
-         _eglSetConfigKey(&base, EGL_MAX_PBUFFER_WIDTH,
-                          _EGL_MAX_PBUFFER_WIDTH);
+         base.MaxPbufferWidth = _EGL_MAX_PBUFFER_WIDTH;
          break;
       case __DRI_ATTRIB_MAX_PBUFFER_HEIGHT:
-         _eglSetConfigKey(&base, EGL_MAX_PBUFFER_HEIGHT,
-                          _EGL_MAX_PBUFFER_HEIGHT);
+         base.MaxPbufferHeight = _EGL_MAX_PBUFFER_HEIGHT;
          break;
       case __DRI_ATTRIB_MUTABLE_RENDER_BUFFER:
          if (disp->Extensions.KHR_mutable_render_buffer)
index 5a1e2f31890aaa24c606671516da47051a7d37c5..ff5dc32c03aa010e760bba8e363e9e968e9adc68 100644 (file)
@@ -339,7 +339,7 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
       }
    } else {
       if (type == EGL_PBUFFER_BIT) {
-         dri2_surf->depth = _eglGetConfigKey(conf, EGL_BUFFER_SIZE);
+         dri2_surf->depth = conf->BufferSize;
       }
       swrastCreateDrawable(dri2_dpy, dri2_surf);
    }
index 6edd551b53d27b7f4939594ba1d48ff82c017378..ee92abe2574ce93078583045141fef513ba12b09 100644 (file)
@@ -152,35 +152,34 @@ haiku_add_configs_for_visuals(_EGLDisplay *disp)
        _eglInitConfig(&conf->base, disp, 1);
        TRACE("Config inited\n");
 
-       _eglSetConfigKey(&conf->base, EGL_RED_SIZE, 8);
-       _eglSetConfigKey(&conf->base, EGL_BLUE_SIZE, 8);
-       _eglSetConfigKey(&conf->base, EGL_GREEN_SIZE, 8);
-       _eglSetConfigKey(&conf->base, EGL_LUMINANCE_SIZE, 0);
-       _eglSetConfigKey(&conf->base, EGL_ALPHA_SIZE, 8);
-       _eglSetConfigKey(&conf->base, EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER);
-       EGLint r = (_eglGetConfigKey(&conf->base, EGL_RED_SIZE)
-               + _eglGetConfigKey(&conf->base, EGL_GREEN_SIZE)
-               + _eglGetConfigKey(&conf->base, EGL_BLUE_SIZE)
-               + _eglGetConfigKey(&conf->base, EGL_ALPHA_SIZE));
-       _eglSetConfigKey(&conf->base, EGL_BUFFER_SIZE, r);
-       _eglSetConfigKey(&conf->base, EGL_CONFIG_CAVEAT, EGL_NONE);
-       _eglSetConfigKey(&conf->base, EGL_CONFIG_ID, 1);
-       _eglSetConfigKey(&conf->base, EGL_BIND_TO_TEXTURE_RGB, EGL_FALSE);
-       _eglSetConfigKey(&conf->base, EGL_BIND_TO_TEXTURE_RGBA, EGL_FALSE);
-       _eglSetConfigKey(&conf->base, EGL_STENCIL_SIZE, 0);
-       _eglSetConfigKey(&conf->base, EGL_TRANSPARENT_TYPE, EGL_NONE);
-       _eglSetConfigKey(&conf->base, EGL_NATIVE_RENDERABLE, EGL_TRUE); // Let's say yes
-       _eglSetConfigKey(&conf->base, EGL_NATIVE_VISUAL_ID, 0); // No visual
-       _eglSetConfigKey(&conf->base, EGL_NATIVE_VISUAL_TYPE, EGL_NONE); // No visual
-       _eglSetConfigKey(&conf->base, EGL_RENDERABLE_TYPE, 0x8);
-       _eglSetConfigKey(&conf->base, EGL_SAMPLE_BUFFERS, 0); // TODO: How to get the right value ?
-       _eglSetConfigKey(&conf->base, EGL_SAMPLES, _eglGetConfigKey(&conf->base, EGL_SAMPLE_BUFFERS) == 0 ? 0 : 0);
-       _eglSetConfigKey(&conf->base, EGL_DEPTH_SIZE, 24); // TODO: How to get the right value ?
-       _eglSetConfigKey(&conf->base, EGL_LEVEL, 0);
-       _eglSetConfigKey(&conf->base, EGL_MAX_PBUFFER_WIDTH, 0); // TODO: How to get the right value ?
-       _eglSetConfigKey(&conf->base, EGL_MAX_PBUFFER_HEIGHT, 0); // TODO: How to get the right value ?
-       _eglSetConfigKey(&conf->base, EGL_MAX_PBUFFER_PIXELS, 0); // TODO: How to get the right value ?
-       _eglSetConfigKey(&conf->base, EGL_SURFACE_TYPE, EGL_WINDOW_BIT /*| EGL_PIXMAP_BIT | EGL_PBUFFER_BIT*/);
+       conf->base.RedSize = 8;
+       conf->base.BlueSize = 8;
+       conf->base.GreenSize = 8;
+       conf->base.LuminanceSize = 0;
+       conf->base.AlphaSize = 8;
+       conf->base.ColorBufferType = EGL_RGB_BUFFER;
+       conf->base.BufferSize = conf->base.RedSize
+                             + conf->base.GreenSize
+                             + conf->base.BlueSize
+                             + conf->base.AlphaSize;
+       conf->base.ConfigCaveat = EGL_NONE;
+       conf->base.ConfigId = 1;
+       conf->base.BindToTextureRGB = EGL_FALSE;
+       conf->base.BindToTextureRGBA = EGL_FALSE;
+       conf->base.StencilSize = 0;
+       conf->base.TransparentType = EGL_NONE;
+       conf->base.NativeRenderable = EGL_TRUE; // Let's say yes
+       conf->base.NativeVisualID = 0; // No visual
+       conf->base.NativeVisualType = EGL_NONE; // No visual
+       conf->base.RenderableType = 0x8;
+       conf->base.SampleBuffers = 0; // TODO: How to get the right value ?
+       conf->base.Samples = conf->base.SampleBuffers == 0 ? 0 : 0;
+       conf->base.DepthSize = 24; // TODO: How to get the right value ?
+       conf->base.Level = 0;
+       conf->base.MaxPbufferWidth = 0; // TODO: How to get the right value ?
+       conf->base.MaxPbufferHeight = 0; // TODO: How to get the right value ?
+       conf->base.MaxPbufferPixels = 0; // TODO: How to get the right value ?
+       conf->base.SurfaceType = EGL_WINDOW_BIT /*| EGL_PIXMAP_BIT | EGL_PBUFFER_BIT*/;
 
        TRACE("Config configuated\n");
        if (!_eglValidateConfig(&conf->base, EGL_FALSE)) {