From 2f9dd4170113b47e2628f2bd4c2be35f2edda9d0 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 25 Mar 2021 13:51:51 -0400 Subject: [PATCH] glx: Clean up fbconfig attribute handling Move the macros defining the expected number of attributes into the same file as their consumer, remove a pointless maximum, and allocate more space for attribs on the stack to avoid malloc in the common case. glxext.c knows about 46 config attribs, 46 - 18 = 28, round up to 32 to future proof a bit. Reviewed-by: Eric Engestrom Part-of: --- src/glx/glxconfig.h | 14 -------------- src/glx/glxext.c | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/glx/glxconfig.h b/src/glx/glxconfig.h index 75704737ef5..132c5b28d45 100644 --- a/src/glx/glxconfig.h +++ b/src/glx/glxconfig.h @@ -101,20 +101,6 @@ struct glx_config { GLint sRGBCapable; }; -#define __GLX_MIN_CONFIG_PROPS 18 -#define __GLX_MAX_CONFIG_PROPS 500 -#define __GLX_EXT_CONFIG_PROPS 10 - -/* -** Since we send all non-core visual properties as token, value pairs, -** we require 2 words across the wire. In order to maintain backwards -** compatibility, we need to send the total number of words that the -** VisualConfigs are sent back in so old libraries can simply "ignore" -** the new properties. -*/ -#define __GLX_TOTAL_CONFIG \ - (__GLX_MIN_CONFIG_PROPS + 2 * __GLX_EXT_CONFIG_PROPS) - extern GLint _gl_convert_from_x_visual_type(int visualType); extern int diff --git a/src/glx/glxext.c b/src/glx/glxext.c index 818946def91..903a5441dd1 100644 --- a/src/glx/glxext.c +++ b/src/glx/glxext.c @@ -58,6 +58,18 @@ #include #include +#define __GLX_MIN_CONFIG_PROPS 18 +#define __GLX_EXT_CONFIG_PROPS 32 + +/* +** Since we send all non-core visual properties as token, value pairs, +** we require 2 words across the wire. In order to maintain backwards +** compatibility, we need to send the total number of words that the +** VisualConfigs are sent back in so old libraries can simply "ignore" +** the new properties. +*/ +#define __GLX_TOTAL_CONFIG \ + (__GLX_MIN_CONFIG_PROPS + 2 * __GLX_EXT_CONFIG_PROPS) #ifdef DEBUG void __glXDumpDrawBuffer(struct glx_context * ctx); @@ -619,10 +631,8 @@ createConfigsFromProperties(Display * dpy, int nvisuals, int nprops, if (nprops == 0) return NULL; - /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for FBconfigs? */ - /* Check number of properties */ - if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS) + if (nprops < __GLX_MIN_CONFIG_PROPS) return NULL; /* Allocate memory for our config structure */