#ifndef LIBGLESV2_GLOBALSTATE_H_
#define LIBGLESV2_GLOBALSTATE_H_
#include "libANGLE/Context.h"
#include "libANGLE/Debug.h"
#include "libANGLE/Display.h"
#include "libANGLE/GlobalMutex.h"
#include "libANGLE/Thread.h"
#include "libANGLE/features.h"
#include "libANGLE/validationEGL.h"
#if defined(ANGLE_PLATFORM_APPLE) || (ANGLE_PLATFORM_ANDROID) || defined(ANGLE_USE_ANDROID_TLS_SLOT)
# include "common/tls.h"
#endif
#include <mutex>
namespace egl
{
class Debug;
class Thread;
#if defined(ANGLE_PLATFORM_APPLE) || defined(ANGLE_USE_STATIC_THREAD_LOCAL_VARIABLES)
extern Thread *GetCurrentThreadTLS();
extern void SetCurrentThreadTLS(Thread *thread);
#else
extern thread_local Thread *gCurrentThread;
#endif
gl::Context *GetGlobalLastContext();
void SetGlobalLastContext(gl::Context *context);
Thread *GetCurrentThread();
Debug *GetDebug();
void SetEGLValidationEnabled(bool enabled);
bool IsEGLValidationEnabled();
class [[nodiscard]] ScopedSyncCurrentContextFromThread
{ … };
ANGLE_INLINE ScopedContextMutexLock TryLockCurrentContext(Thread *thread)
{ … }
ANGLE_INLINE ScopedContextMutexLock TryLockContext(Display *display, gl::ContextID contextID)
{ … }
ANGLE_INLINE ScopedContextMutexLock LockAndTryMergeContextMutexes(gl::Context *context,
ImageID imageID)
{ … }
#if !defined(ANGLE_ENABLE_CONTEXT_MUTEX)
#define ANGLE_EGL_SCOPED_CONTEXT_LOCK(EP, THREAD, ...) …
#else
#define ANGLE_EGL_SCOPED_CONTEXT_LOCK …
#endif
}
#define ANGLE_SCOPED_GLOBAL_LOCK() …
namespace gl
{
ANGLE_INLINE Context *GetGlobalContext()
{ … }
ANGLE_INLINE Context *GetValidGlobalContext()
{ … }
void GenerateContextLostErrorOnContext(Context *context);
void GenerateContextLostErrorOnCurrentGlobalContext();
#if defined(ANGLE_FORCE_CONTEXT_CHECK_EVERY_CALL)
static ANGLE_INLINE void DirtyContextIfNeeded(Context *context)
{
if (context && context != egl::GetGlobalLastContext())
{
context->dirtyAllState();
SetGlobalLastContext(context);
}
}
#endif
#if !defined(ANGLE_ENABLE_SHARE_CONTEXT_LOCK)
#define SCOPED_SHARE_CONTEXT_LOCK(context) …
#define SCOPED_EGL_IMAGE_SHARE_CONTEXT_LOCK(context, imageID) …
#else
# if defined(ANGLE_FORCE_CONTEXT_CHECK_EVERY_CALL)
#define SCOPED_SHARE_CONTEXT_LOCK …
#define SCOPED_EGL_IMAGE_SHARE_CONTEXT_LOCK …
# elif !defined(ANGLE_ENABLE_CONTEXT_MUTEX)
#define SCOPED_SHARE_CONTEXT_LOCK …
#define SCOPED_EGL_IMAGE_SHARE_CONTEXT_LOCK …
# else
#define SCOPED_SHARE_CONTEXT_LOCK …
#define SCOPED_EGL_IMAGE_SHARE_CONTEXT_LOCK …
# endif
#endif
}
#endif