|
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_EGL_TLS)
|
|
Packit Service |
9e77c8 |
#define __LIB_EGL_TLS
|
|
Packit Service |
9e77c8 |
|
|
Packit Service |
9e77c8 |
#include <pthread.h>
|
|
Packit Service |
9e77c8 |
|
|
Packit Service |
9e77c8 |
#include "glvnd_pthread.h"
|
|
Packit Service |
9e77c8 |
#include "libeglabipriv.h"
|
|
Packit Service |
9e77c8 |
#include "libeglmapping.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 |
/*!
|
|
Packit Service |
9e77c8 |
* Defines the state to keep track of a current OpenGL or GLES context.
|
|
Packit Service |
9e77c8 |
*
|
|
Packit Service |
9e77c8 |
* Each thread will have an \c __EGLdispatchThreadState structure if and only if it has a
|
|
Packit Service |
9e77c8 |
* current EGL context. As with GLX, the pointer to the current
|
|
Packit Service |
9e77c8 |
* \c __EGLdispatchThreadState structure is maintained by libGLdispatch.
|
|
Packit Service |
9e77c8 |
*/
|
|
Packit Service |
9e77c8 |
typedef struct __EGLdispatchThreadStateRec {
|
|
Packit Service |
9e77c8 |
__GLdispatchThreadState glas; /* Must be the first entry! */
|
|
Packit Service |
9e77c8 |
|
|
Packit Service |
9e77c8 |
// The current display, context, and drawable for GL or GLES.
|
|
Packit Service |
9e77c8 |
// Note that OpenVG will need a separate current context.
|
|
Packit Service |
9e77c8 |
__EGLdisplayInfo *currentDisplay;
|
|
Packit Service |
9e77c8 |
EGLSurface currentDraw;
|
|
Packit Service |
9e77c8 |
EGLSurface currentRead;
|
|
Packit Service |
9e77c8 |
EGLContext currentContext;
|
|
Packit Service |
9e77c8 |
__EGLvendorInfo *currentVendor;
|
|
Packit Service |
9e77c8 |
|
|
Packit Service |
9e77c8 |
struct glvnd_list entry;
|
|
Packit Service |
9e77c8 |
} __EGLdispatchThreadState;
|
|
Packit Service |
9e77c8 |
|
|
Packit Service |
9e77c8 |
/*!
|
|
Packit Service |
9e77c8 |
* Defines per-thread state in libEGL that is not specific to any client API or
|
|
Packit Service |
9e77c8 |
* context.
|
|
Packit Service |
9e77c8 |
*/
|
|
Packit Service |
9e77c8 |
typedef struct __EGLThreadAPIStateRec {
|
|
Packit Service |
9e77c8 |
/*!
|
|
Packit Service |
9e77c8 |
* The last EGL error code. This is returned from eglGetError().
|
|
Packit Service |
9e77c8 |
*/
|
|
Packit Service |
9e77c8 |
EGLint lastError;
|
|
Packit Service |
9e77c8 |
__EGLvendorInfo *lastVendor;
|
|
Packit Service |
9e77c8 |
|
|
Packit Service |
9e77c8 |
/*!
|
|
Packit Service |
9e77c8 |
* The current client API, as specified by eglBindAPI.
|
|
Packit Service |
9e77c8 |
*/
|
|
Packit Service |
9e77c8 |
EGLenum currentClientApi;
|
|
Packit Service |
9e77c8 |
|
|
Packit Service |
9e77c8 |
EGLLabelKHR label;
|
|
Packit Service |
9e77c8 |
|
|
Packit Service |
9e77c8 |
struct glvnd_list entry;
|
|
Packit Service |
9e77c8 |
} __EGLThreadAPIState;
|
|
Packit Service |
9e77c8 |
|
|
Packit Service |
9e77c8 |
void __eglCurrentInit(void);
|
|
Packit Service |
9e77c8 |
void __eglCurrentTeardown(EGLBoolean doReset);
|
|
Packit Service |
9e77c8 |
|
|
Packit Service |
9e77c8 |
/*!
|
|
Packit Service |
9e77c8 |
* Returns the \c __EGLThreadAPIState structure for the current thread.
|
|
Packit Service |
9e77c8 |
*
|
|
Packit Service |
9e77c8 |
* \param create If \p create is true, then a new \c __EGLThreadAPIState struct
|
|
Packit Service |
9e77c8 |
* will be allocated if the current thread doesn't already have one.
|
|
Packit Service |
9e77c8 |
*
|
|
Packit Service |
9e77c8 |
* \return A pointer to the current thread's \c __EGLThreadAPIState, or NULL if
|
|
Packit Service |
9e77c8 |
* the current thread doesn't have one yet.
|
|
Packit Service |
9e77c8 |
*/
|
|
Packit Service |
9e77c8 |
__EGLThreadAPIState *__eglGetCurrentThreadAPIState(EGLBoolean create);
|
|
Packit Service |
9e77c8 |
|
|
Packit Service |
9e77c8 |
/*!
|
|
Packit Service |
9e77c8 |
* Frees the \c __EGLThreadAPIState struct for the current thread.
|
|
Packit Service |
9e77c8 |
*/
|
|
Packit Service |
9e77c8 |
void __eglDestroyCurrentThreadAPIState(void);
|
|
Packit Service |
9e77c8 |
|
|
Packit Service |
9e77c8 |
/*!
|
|
Packit Service |
9e77c8 |
* Returns the current thread's \c __EGLdispatchThreadState structure, if it has one.
|
|
Packit Service |
9e77c8 |
*/
|
|
Packit Service |
9e77c8 |
static inline __EGLdispatchThreadState *__eglGetCurrentAPIState(void)
|
|
Packit Service |
9e77c8 |
{
|
|
Packit Service |
9e77c8 |
__GLdispatchThreadState *glas = __glDispatchGetCurrentThreadState();
|
|
Packit Service |
9e77c8 |
if (unlikely(!glas ||
|
|
Packit Service |
9e77c8 |
(glas->tag != GLDISPATCH_API_EGL))) {
|
|
Packit Service |
9e77c8 |
return NULL;
|
|
Packit Service |
9e77c8 |
} else {
|
|
Packit Service |
9e77c8 |
return (__EGLdispatchThreadState *)(glas);
|
|
Packit Service |
9e77c8 |
}
|
|
Packit Service |
9e77c8 |
}
|
|
Packit Service |
9e77c8 |
|
|
Packit Service |
9e77c8 |
__EGLdispatchThreadState *__eglCreateAPIState(void);
|
|
Packit Service |
9e77c8 |
void __eglDestroyAPIState(__EGLdispatchThreadState *state);
|
|
Packit Service |
9e77c8 |
|
|
Packit Service |
9e77c8 |
EGLenum __eglQueryAPI(void);
|
|
Packit Service |
9e77c8 |
__EGLvendorInfo *__eglGetCurrentVendor(void);
|
|
Packit Service |
9e77c8 |
EGLContext __eglGetCurrentContext(void);
|
|
Packit Service |
9e77c8 |
EGLDisplay __eglGetCurrentDisplay(void);
|
|
Packit Service |
9e77c8 |
EGLSurface __eglGetCurrentSurface(EGLint readDraw);
|
|
Packit Service |
9e77c8 |
|
|
Packit Service |
9e77c8 |
#endif // !defined(__LIB_EGL_TLS)
|