glx: Implement GLX_EXT_get_drawable_type

Trivial extension to let the client query whether this is a window
pixmap or pbuffer. Mostly for Mesa's convenience when setting up
drawable state, but plausibly useful for apps and middleware as well.

Upstream OpenGL Registry merge request:

https://github.com/KhronosGroup/OpenGL-Registry/pull/425
This commit is contained in:
Adam Jackson 2020-09-24 17:08:27 -04:00 committed by Adam Jackson
parent c15dd0ba48
commit 96d19e898a
3 changed files with 11 additions and 1 deletions

View File

@ -86,6 +86,7 @@ static const struct extension_info known_glx_extensions[] = {
{ GLX(EXT_create_context_es2_profile), VER(0,0), N, },
{ GLX(EXT_fbconfig_packed_float), VER(0,0), N, },
{ GLX(EXT_framebuffer_sRGB), VER(0,0), N, },
{ GLX(EXT_get_drawable_type), VER(0,0), Y, },
{ GLX(EXT_import_context), VER(0,0), N, },
{ GLX(EXT_libglvnd), VER(0,0), N, },
{ GLX(EXT_no_config_context), VER(0,0), N, },

View File

@ -47,6 +47,7 @@ enum {
EXT_create_context_es_profile_bit,
EXT_create_context_es2_profile_bit,
EXT_fbconfig_packed_float_bit,
EXT_get_drawable_type_bit,
EXT_import_context_bit,
EXT_libglvnd_bit,
EXT_no_config_context_bit,

View File

@ -1860,7 +1860,7 @@ DoGetDrawableAttributes(__GLXclientState * cl, XID drawId)
xGLXGetDrawableAttributesReply reply;
__GLXdrawable *pGlxDraw = NULL;
DrawablePtr pDraw;
CARD32 attributes[18];
CARD32 attributes[20];
int num = 0, error;
if (!validGlxDrawable(client, drawId, GLX_DRAWABLE_ANY,
@ -1897,6 +1897,14 @@ DoGetDrawableAttributes(__GLXclientState * cl, XID drawId)
ATTRIB(GLX_STEREO_TREE_EXT, 0);
}
}
/* GLX_EXT_get_drawable_type */
if (!pGlxDraw || pGlxDraw->type == GLX_DRAWABLE_WINDOW)
ATTRIB(GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT);
else if (pGlxDraw->type == GLX_DRAWABLE_PIXMAP)
ATTRIB(GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT);
else if (pGlxDraw->type == GLX_DRAWABLE_PBUFFER)
ATTRIB(GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT);
#undef ATTRIB
reply = (xGLXGetDrawableAttributesReply) {