xref: /third_party/mesa3d/src/egl/main/eglcurrent.h (revision bf215546)
1/**************************************************************************
2 *
3 * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28
29#ifndef EGLCURRENT_INCLUDED
30#define EGLCURRENT_INCLUDED
31
32#include <stdbool.h>
33
34#include "egltypedefs.h"
35
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41#define _EGL_API_ALL_BITS \
42   (EGL_OPENGL_ES_BIT   | \
43    EGL_OPENVG_BIT      | \
44    EGL_OPENGL_ES2_BIT  | \
45    EGL_OPENGL_ES3_BIT_KHR | \
46    EGL_OPENGL_BIT)
47
48
49/**
50 * Per-thread info
51 */
52struct _egl_thread_info
53{
54   bool inited;
55   EGLint LastError;
56   _EGLContext *CurrentContext;
57   EGLenum CurrentAPI;
58   EGLLabelKHR Label;
59
60   /**
61    * The name of the EGL function that's being called at the moment. This is
62    * used to report the function name to the EGL_KHR_debug callback.
63    */
64   const char *CurrentFuncName;
65   EGLLabelKHR CurrentObjectLabel;
66};
67
68
69/**
70 * Return true if a client API enum is recognized.
71 */
72static inline EGLBoolean
73_eglIsApiValid(EGLenum api)
74{
75#ifdef ANDROID
76   /* OpenGL is not a valid/supported API on Android */
77   return api == EGL_OPENGL_ES_API;
78#else
79   return (api == EGL_OPENGL_ES_API || api == EGL_OPENGL_API);
80#endif
81}
82
83
84extern _EGLThreadInfo *
85_eglGetCurrentThread(void);
86
87
88extern void
89_eglDestroyCurrentThread(void);
90
91
92extern _EGLContext *
93_eglGetCurrentContext(void);
94
95
96extern EGLBoolean
97_eglError(EGLint errCode, const char *msg);
98
99extern void
100_eglDebugReport(EGLenum error, const char *funcName,
101      EGLint type, const char *message, ...);
102
103#define _eglReportCritical(error, funcName, ...) \
104    _eglDebugReport(error, funcName, EGL_DEBUG_MSG_CRITICAL_KHR, __VA_ARGS__)
105
106#define _eglReportError(error, funcName, ...) \
107    _eglDebugReport(error, funcName, EGL_DEBUG_MSG_ERROR_KHR, __VA_ARGS__)
108
109#define _eglReportWarn(funcName, ...) \
110    _eglDebugReport(EGL_SUCCESS, funcName, EGL_DEBUG_MSG_WARN_KHR, __VA_ARGS__)
111
112#define _eglReportInfo(funcName, ...) \
113    _eglDebugReport(EGL_SUCCESS, funcName, EGL_DEBUG_MSG_INFO_KHR, __VA_ARGS__)
114
115#ifdef __cplusplus
116}
117#endif
118
119#endif /* EGLCURRENT_INCLUDED */
120