13464ebd5Sriastradh/**************************************************************************
23464ebd5Sriastradh *
3af69d88dSmrg * Copyright 2008 VMware, Inc.
43464ebd5Sriastradh * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
53464ebd5Sriastradh * Copyright 2010-2011 LunarG, Inc.
63464ebd5Sriastradh * All Rights Reserved.
73464ebd5Sriastradh *
83464ebd5Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a
93464ebd5Sriastradh * copy of this software and associated documentation files (the
103464ebd5Sriastradh * "Software"), to deal in the Software without restriction, including
113464ebd5Sriastradh * without limitation the rights to use, copy, modify, merge, publish,
123464ebd5Sriastradh * distribute, sub license, and/or sell copies of the Software, and to
133464ebd5Sriastradh * permit persons to whom the Software is furnished to do so, subject to
143464ebd5Sriastradh * the following conditions:
153464ebd5Sriastradh *
163464ebd5Sriastradh * The above copyright notice and this permission notice (including the
173464ebd5Sriastradh * next paragraph) shall be included in all copies or substantial portions
183464ebd5Sriastradh * of the Software.
193464ebd5Sriastradh *
203464ebd5Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
213464ebd5Sriastradh * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
223464ebd5Sriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
233464ebd5Sriastradh * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
243464ebd5Sriastradh * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
253464ebd5Sriastradh * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
263464ebd5Sriastradh * DEALINGS IN THE SOFTWARE.
273464ebd5Sriastradh *
283464ebd5Sriastradh **************************************************************************/
293464ebd5Sriastradh
303464ebd5Sriastradh
314a49301eSmrg#ifndef EGLGLOBALS_INCLUDED
324a49301eSmrg#define EGLGLOBALS_INCLUDED
334a49301eSmrg
34af69d88dSmrg#include <stdbool.h>
3501e04c3fSmrg#include "c11/threads.h"
36cdc920a0Smrg
374a49301eSmrg#include "egltypedefs.h"
384a49301eSmrg
3901e04c3fSmrgenum
4001e04c3fSmrg{
4101e04c3fSmrg    _EGL_DEBUG_BIT_CRITICAL = 0x1,
4201e04c3fSmrg    _EGL_DEBUG_BIT_ERROR = 0x2,
4301e04c3fSmrg    _EGL_DEBUG_BIT_WARN = 0x4,
4401e04c3fSmrg    _EGL_DEBUG_BIT_INFO = 0x8,
4501e04c3fSmrg};
464a49301eSmrg
474a49301eSmrg/**
484a49301eSmrg * Global library data
494a49301eSmrg */
504a49301eSmrgstruct _egl_global
514a49301eSmrg{
5201e04c3fSmrg   mtx_t *Mutex;
534a49301eSmrg
544a49301eSmrg   /* the list of all displays */
554a49301eSmrg   _EGLDisplay *DisplayList;
564a49301eSmrg
5701e04c3fSmrg   _EGLDevice *DeviceList;
5801e04c3fSmrg
594a49301eSmrg   EGLint NumAtExitCalls;
604a49301eSmrg   void (*AtExitCalls[10])(void);
61af69d88dSmrg
6201e04c3fSmrg   /*
6301e04c3fSmrg    * Under libglvnd, the client extension string has to be split into two
647ec681f3Smrg    * strings, one for platform extensions, and one for everything else.
657ec681f3Smrg    * For a non-glvnd build create a concatenated one.
6601e04c3fSmrg    */
677ec681f3Smrg#if USE_LIBGLVND
6801e04c3fSmrg   const char *ClientOnlyExtensionString;
6901e04c3fSmrg   const char *PlatformExtensionString;
707ec681f3Smrg#else
717ec681f3Smrg   const char *ClientExtensionString;
727ec681f3Smrg#endif
7301e04c3fSmrg
7401e04c3fSmrg   EGLDEBUGPROCKHR debugCallback;
7501e04c3fSmrg   unsigned int debugTypesEnabled;
764a49301eSmrg};
774a49301eSmrg
784a49301eSmrg
794a49301eSmrgextern struct _egl_global _eglGlobal;
804a49301eSmrg
814a49301eSmrg
824a49301eSmrgextern void
834a49301eSmrg_eglAddAtExitCall(void (*func)(void));
844a49301eSmrg
8501e04c3fSmrgstatic inline unsigned int DebugBitFromType(EGLenum type)
8601e04c3fSmrg{
8701e04c3fSmrg   assert(type >= EGL_DEBUG_MSG_CRITICAL_KHR && type <= EGL_DEBUG_MSG_INFO_KHR);
8801e04c3fSmrg   return (1 << (type - EGL_DEBUG_MSG_CRITICAL_KHR));
8901e04c3fSmrg}
9001e04c3fSmrg
9101e04c3fSmrg/**
9201e04c3fSmrg * Perform validity checks on a generic pointer.
9301e04c3fSmrg */
9401e04c3fSmrgextern EGLBoolean
9501e04c3fSmrg_eglPointerIsDereferencable(void *p);
964a49301eSmrg
974a49301eSmrg#endif /* EGLGLOBALS_INCLUDED */
98