blob: 8b1b3898f678cac6b7ac4de5d17e8911790c3c8e [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
2 ** Copyright 2007, The Android Open Source Project
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 ** http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16
17#ifndef ANDROID_GLES_CM_HOOKS_H
18#define ANDROID_GLES_CM_HOOKS_H
19
20#include <ctype.h>
21#include <string.h>
22#include <errno.h>
23
Mathias Agopiande586972009-05-28 17:39:03 -070024#include <pthread.h>
25
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080026#include <EGL/egl.h>
Mathias Agopian53238bd2009-04-22 18:24:18 -070027#include <EGL/eglext.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080028#include <GLES/gl.h>
Mathias Agopian53238bd2009-04-22 18:24:18 -070029#include <GLES/glext.h>
Mathias Agopianb1a39d62009-05-27 20:38:06 -070030#include <GLES2/gl2.h>
31#include <GLES2/gl2ext.h>
32
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080033#if !defined(__arm__)
34#define USE_SLOW_BINDING 1
35#else
36#define USE_SLOW_BINDING 0
37#endif
38#undef NELEM
39#define NELEM(x) (sizeof(x)/sizeof(*(x)))
Mathias Agopian31272602012-01-28 14:20:59 -080040
41// maximum number of GL extensions that can be used simultaneously in
42// a given process. this limitation exists because we need to have
43// a static function for each extension and currently these static functions
44// are generated at compile time.
45#define MAX_NUMBER_OF_GL_EXTENSIONS 256
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080046
47
Mathias Agopian53238bd2009-04-22 18:24:18 -070048#if defined(HAVE_ANDROID_OS) && !USE_SLOW_BINDING && __OPTIMIZE__
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080049#define USE_FAST_TLS_KEY 1
50#else
51#define USE_FAST_TLS_KEY 0
52#endif
53
54#if USE_FAST_TLS_KEY
55# include <bionic_tls.h> /* special private C library header */
56#endif
57
58// ----------------------------------------------------------------------------
59namespace android {
60// ----------------------------------------------------------------------------
61
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080062// GL / EGL hooks
63
64#undef GL_ENTRY
65#undef EGL_ENTRY
66#define GL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__);
67#define EGL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__);
68
Mathias Agopian618fa102009-10-14 02:06:37 -070069struct egl_t {
70 #include "EGL/egl_entries.in"
71};
72
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080073struct gl_hooks_t {
74 struct gl_t {
Mathias Agopian618fa102009-10-14 02:06:37 -070075 #include "entries.in"
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080076 } gl;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080077 struct gl_ext_t {
Mathias Agopian24035332010-08-02 17:34:32 -070078 __eglMustCastToProperFunctionPointerType extensions[MAX_NUMBER_OF_GL_EXTENSIONS];
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080079 } ext;
80};
81#undef GL_ENTRY
82#undef EGL_ENTRY
83
Mathias Agopian1cadb252011-05-23 17:26:14 -070084EGLAPI void setGlThreadSpecific(gl_hooks_t const *value);
85EGLAPI gl_hooks_t const* getGlThreadSpecific();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080086
87// ----------------------------------------------------------------------------
88}; // namespace android
89// ----------------------------------------------------------------------------
90
91#endif /* ANDROID_GLES_CM_HOOKS_H */