[PATCH xserver 1/4] glx: Macroize building the attribute list in DoGetDrawableAttributes
Julien Cristau
jcristau at debian.org
Thu Mar 10 20:01:27 UTC 2016
On Thu, Mar 10, 2016 at 13:25:03 -0500, Adam Jackson wrote:
> No functional change, just a little easier to read and harder to get
> wrong.
>
> Signed-off-by: Adam Jackson <ajax at redhat.com>
> ---
> glx/glxcmds.c | 38 +++++++++++++++-----------------------
> 1 file changed, 15 insertions(+), 23 deletions(-)
>
> diff --git a/glx/glxcmds.c b/glx/glxcmds.c
> index 6eb3541..65d0739 100644
> --- a/glx/glxcmds.c
> +++ b/glx/glxcmds.c
> @@ -1945,31 +1945,23 @@ DoGetDrawableAttributes(__GLXclientState * cl, XID drawId)
> if (pGlxDraw)
> pDraw = pGlxDraw->pDraw;
>
> - attributes[2*num] = GLX_Y_INVERTED_EXT;
> - attributes[2*num+1] = GL_FALSE;
> - num++;
> - attributes[2*num] = GLX_WIDTH;
> - attributes[2*num+1] = pDraw->width;
> - num++;
> - attributes[2*num] = GLX_HEIGHT;
> - attributes[2*num+1] = pDraw->height;
> - num++;
> +#define ATTRIB(a, v) { \
> + attributes[2*num] = (a); \
> + attributes[2*num+1] = (v); \
> + num++; \
> + }
> +
> + ATTRIB(GLX_Y_INVERTED_EXT, GL_FALSE);
> + ATTRIB(GLX_WIDTH, pDraw->width);
> + ATTRIB(GLX_HEIGHT, pDraw->height);
> if (pGlxDraw) {
> - attributes[2*num] = GLX_TEXTURE_TARGET_EXT;
> - attributes[2*num+1] = pGlxDraw->target == GL_TEXTURE_2D ?
> - GLX_TEXTURE_2D_EXT :
> - GLX_TEXTURE_RECTANGLE_EXT;
> - num++;
> - attributes[2*num] = GLX_EVENT_MASK;
> - attributes[2*num+1] = pGlxDraw->eventMask;
> - num++;
> - attributes[2*num] = GLX_FBCONFIG_ID;
> - attributes[2*num+1] = pGlxDraw->config->fbconfigID;
> - num++;
> + ATTRIB(GLX_TEXTURE_TARGET_EXT,
> + pGlxDraw->target == GL_TEXTURE_2D ?
> + GLX_TEXTURE_2D_EXT : GLX_TEXTURE_RECTANGLE_EXT);
> + ATTRIB(GLX_EVENT_MASK, pGlxDraw->eventMask);
> + ATTRIB(GLX_FBCONFIG_ID, pGlxDraw->config->fbconfigID);
> if (pGlxDraw->type == GLX_DRAWABLE_PBUFFER) {
> - attributes[2*num] = GLX_PRESERVED_CONTENTS;
> - attributes[2*num+1] = GL_TRUE;
> - num++;
> + ATTRIB(GLX_PRESERVED_CONTENTS, GL_TRUE);
> }
> }
>
maybe #undef ATTRIB when you're done?
Cheers,
Julien
More information about the xorg-devel
mailing list