Home | History | Annotate | Download | only in libs
      1 /*
      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 
     24 #include <pthread.h>
     25 
     26 #include <EGL/egl.h>
     27 #include <EGL/eglext.h>
     28 #include <GLES/gl.h>
     29 #include <GLES/glext.h>
     30 #include <GLES2/gl2.h>
     31 #include <GLES2/gl2ext.h>
     32 #include <GLES3/gl3.h>
     33 #include <GLES3/gl3ext.h>
     34 
     35 #if !defined(__arm__) && !defined(__mips__)
     36 #define USE_SLOW_BINDING            1
     37 #else
     38 #define USE_SLOW_BINDING            0
     39 #endif
     40 #undef NELEM
     41 #define NELEM(x)                    (sizeof(x)/sizeof(*(x)))
     42 
     43 // maximum number of GL extensions that can be used simultaneously in
     44 // a given process. this limitation exists because we need to have
     45 // a static function for each extension and currently these static functions
     46 // are generated at compile time.
     47 #define MAX_NUMBER_OF_GL_EXTENSIONS 256
     48 
     49 
     50 #if defined(HAVE_ANDROID_OS) && !USE_SLOW_BINDING && __OPTIMIZE__
     51 #define USE_FAST_TLS_KEY            1
     52 #else
     53 #define USE_FAST_TLS_KEY            0
     54 #endif
     55 
     56 #if USE_FAST_TLS_KEY
     57 #   include <bionic_tls.h>  /* special private C library header */
     58 #endif
     59 
     60 // ----------------------------------------------------------------------------
     61 namespace android {
     62 // ----------------------------------------------------------------------------
     63 
     64 // GL / EGL hooks
     65 
     66 #undef GL_ENTRY
     67 #undef EGL_ENTRY
     68 #define GL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__);
     69 #define EGL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__);
     70 
     71 struct egl_t {
     72     #include "EGL/egl_entries.in"
     73 };
     74 
     75 struct gl_hooks_t {
     76     struct gl_t {
     77         #include "entries.in"
     78     } gl;
     79     struct gl_ext_t {
     80         __eglMustCastToProperFunctionPointerType extensions[MAX_NUMBER_OF_GL_EXTENSIONS];
     81     } ext;
     82 };
     83 #undef GL_ENTRY
     84 #undef EGL_ENTRY
     85 
     86 EGLAPI void setGlThreadSpecific(gl_hooks_t const *value);
     87 EGLAPI gl_hooks_t const* getGlThreadSpecific();
     88 
     89 // ----------------------------------------------------------------------------
     90 }; // namespace android
     91 // ----------------------------------------------------------------------------
     92 
     93 #endif /* ANDROID_GLES_CM_HOOKS_H */
     94