Blame src/GLX/libglxcurrent.h

Packit Service 9e77c8
/*
Packit Service 9e77c8
 * Copyright (c) 2013, NVIDIA CORPORATION.
Packit Service 9e77c8
 *
Packit Service 9e77c8
 * Permission is hereby granted, free of charge, to any person obtaining a
Packit Service 9e77c8
 * copy of this software and/or associated documentation files (the
Packit Service 9e77c8
 * "Materials"), to deal in the Materials without restriction, including
Packit Service 9e77c8
 * without limitation the rights to use, copy, modify, merge, publish,
Packit Service 9e77c8
 * distribute, sublicense, and/or sell copies of the Materials, and to
Packit Service 9e77c8
 * permit persons to whom the Materials are furnished to do so, subject to
Packit Service 9e77c8
 * the following conditions:
Packit Service 9e77c8
 *
Packit Service 9e77c8
 * The above copyright notice and this permission notice shall be included
Packit Service 9e77c8
 * unaltered in all copies or substantial portions of the Materials.
Packit Service 9e77c8
 * Any additions, deletions, or changes to the original source files
Packit Service 9e77c8
 * must be clearly indicated in accompanying documentation.
Packit Service 9e77c8
 *
Packit Service 9e77c8
 * If only executable code is distributed, then the accompanying
Packit Service 9e77c8
 * documentation must state that "this software is based in part on the
Packit Service 9e77c8
 * work of the Khronos Group."
Packit Service 9e77c8
 *
Packit Service 9e77c8
 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Packit Service 9e77c8
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Packit Service 9e77c8
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Packit Service 9e77c8
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
Packit Service 9e77c8
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
Packit Service 9e77c8
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
Packit Service 9e77c8
 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
Packit Service 9e77c8
 */
Packit Service 9e77c8
Packit Service 9e77c8
#if !defined(__LIB_GLX_TLS)
Packit Service 9e77c8
#define __LIB_GLX_TLS
Packit Service 9e77c8
Packit Service 9e77c8
#include <pthread.h>
Packit Service 9e77c8
Packit Service 9e77c8
#include "libglxthread.h"
Packit Service 9e77c8
#include "libglxabipriv.h"
Packit Service 9e77c8
#include "libglxmapping.h"
Packit Service 9e77c8
#include "GLdispatch.h"
Packit Service 9e77c8
#include "lkdhash.h"
Packit Service 9e77c8
#include "glvnd_list.h"
Packit Service 9e77c8
Packit Service 9e77c8
typedef struct __GLXcontextInfoRec __GLXcontextInfo;
Packit Service 9e77c8
Packit Service 9e77c8
/*!
Packit Service 9e77c8
 * Define current API library state here.
Packit Service 9e77c8
 *
Packit Service 9e77c8
 * A thread will have a __GLXThreadState struct if and only if it has a current
Packit Service 9e77c8
 * GLX context. If we don't have a current context, then there's nothing useful
Packit Service 9e77c8
 * to store in it.
Packit Service 9e77c8
 *
Packit Service 9e77c8
 * The pointer to the current __GLXThreadState is stored in libGLdispatch, since
Packit Service 9e77c8
 * it's also the current __GLdispatchThreadState struct.
Packit Service 9e77c8
 */
Packit Service 9e77c8
typedef struct __GLXThreadStateRec {
Packit Service 9e77c8
    __GLdispatchThreadState glas; /* Must be the first entry! */
Packit Service 9e77c8
Packit Service 9e77c8
    __GLXvendorInfo *currentVendor;
Packit Service 9e77c8
Packit Service 9e77c8
    Display *currentDisplay;
Packit Service 9e77c8
    GLXDrawable currentDraw;
Packit Service 9e77c8
    GLXDrawable currentRead;
Packit Service 9e77c8
    __GLXcontextInfo *currentContext;
Packit Service 9e77c8
Packit Service 9e77c8
    struct glvnd_list entry;
Packit Service 9e77c8
} __GLXThreadState;
Packit Service 9e77c8
Packit Service 9e77c8
/*!
Packit Service 9e77c8
 * Looks up the current thread state.
Packit Service 9e77c8
 *
Packit Service 9e77c8
 * If there isn't a current context, or if the current context was set by
Packit Service 9e77c8
 * another library like EGL, then this will return \c NULL.
Packit Service 9e77c8
 */
Packit Service 9e77c8
static inline __GLXThreadState *__glXGetCurrentThreadState(void)
Packit Service 9e77c8
{
Packit Service 9e77c8
    __GLdispatchThreadState *glas = __glDispatchGetCurrentThreadState();
Packit Service 9e77c8
    if (unlikely(!glas ||
Packit Service 9e77c8
                 (glas->tag != GLDISPATCH_API_GLX))) {
Packit Service 9e77c8
        return NULL;
Packit Service 9e77c8
    } else {
Packit Service 9e77c8
        return (__GLXThreadState *)(glas);
Packit Service 9e77c8
    }
Packit Service 9e77c8
}
Packit Service 9e77c8
Packit Service 9e77c8
/*!
Packit Service 9e77c8
 * This gets the current GLX dynamic dispatch table, which is stored in the
Packit Service 9e77c8
 * thread state.
Packit Service 9e77c8
 */
Packit Service 9e77c8
__GLXvendorInfo *__glXGetCurrentDynDispatch(void);
Packit Service 9e77c8
Packit Service 9e77c8
#endif // !defined(__LIB_GLX_TLS)