| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | #define LOG_TAG "GLES_CM" | 
|  | 18 |  | 
|  | 19 | #include <ctype.h> | 
|  | 20 | #include <string.h> | 
|  | 21 | #include <errno.h> | 
|  | 22 |  | 
|  | 23 | #include <sys/ioctl.h> | 
|  | 24 |  | 
|  | 25 | #include <GLES/gl.h> | 
|  | 26 | #include <GLES/glext.h> | 
|  | 27 |  | 
|  | 28 | #include <cutils/log.h> | 
|  | 29 | #include <cutils/properties.h> | 
|  | 30 |  | 
|  | 31 | #include "hooks.h" | 
| Mathias Agopian | 53238bd | 2009-04-22 18:24:18 -0700 | [diff] [blame] | 32 | #include "egl_impl.h" | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 |  | 
|  | 34 | using namespace android; | 
|  | 35 |  | 
|  | 36 | // ---------------------------------------------------------------------------- | 
|  | 37 | // extensions for the framework | 
|  | 38 | // ---------------------------------------------------------------------------- | 
|  | 39 |  | 
| Mathias Agopian | d373c63 | 2009-05-08 15:35:17 -0700 | [diff] [blame] | 40 | extern "C" { | 
|  | 41 | GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride, | 
|  | 42 | const GLvoid *ptr, GLsizei count); | 
|  | 43 | GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride, | 
|  | 44 | const GLvoid *pointer, GLsizei count); | 
|  | 45 | GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type, | 
|  | 46 | GLsizei stride, const GLvoid *pointer, GLsizei count); | 
|  | 47 | GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type, | 
|  | 48 | GLsizei stride, const GLvoid *pointer, GLsizei count); | 
|  | 49 | } | 
|  | 50 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | void glColorPointerBounds(GLint size, GLenum type, GLsizei stride, | 
|  | 52 | const GLvoid *ptr, GLsizei count) { | 
|  | 53 | glColorPointer(size, type, stride, ptr); | 
|  | 54 | } | 
|  | 55 | void glNormalPointerBounds(GLenum type, GLsizei stride, | 
|  | 56 | const GLvoid *pointer, GLsizei count) { | 
|  | 57 | glNormalPointer(type, stride, pointer); | 
|  | 58 | } | 
|  | 59 | void glTexCoordPointerBounds(GLint size, GLenum type, | 
|  | 60 | GLsizei stride, const GLvoid *pointer, GLsizei count) { | 
|  | 61 | glTexCoordPointer(size, type, stride, pointer); | 
|  | 62 | } | 
|  | 63 | void glVertexPointerBounds(GLint size, GLenum type, | 
|  | 64 | GLsizei stride, const GLvoid *pointer, GLsizei count) { | 
|  | 65 | glVertexPointer(size, type, stride, pointer); | 
|  | 66 | } | 
|  | 67 |  | 
|  | 68 | // ---------------------------------------------------------------------------- | 
|  | 69 | // Actual GL entry-points | 
|  | 70 | // ---------------------------------------------------------------------------- | 
|  | 71 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 72 | #undef API_ENTRY | 
|  | 73 | #undef CALL_GL_API | 
|  | 74 | #undef CALL_GL_API_RETURN | 
|  | 75 |  | 
|  | 76 | #if USE_FAST_TLS_KEY | 
|  | 77 |  | 
|  | 78 | #define API_ENTRY(_api) __attribute__((naked)) _api | 
|  | 79 |  | 
|  | 80 | #define CALL_GL_API(_api, ...)                              \ | 
|  | 81 | asm volatile(                                          \ | 
|  | 82 | "mov   r12, #0xFFFF0FFF   \n"                       \ | 
|  | 83 | "ldr   r12, [r12, #-15]   \n"                       \ | 
|  | 84 | "ldr   r12, [r12, %[tls]] \n"                       \ | 
|  | 85 | "cmp   r12, #0            \n"                       \ | 
|  | 86 | "ldrne pc,  [r12, %[api]] \n"                       \ | 
|  | 87 | "bx    lr                 \n"                       \ | 
|  | 88 | :                                                   \ | 
|  | 89 | : [tls] "J"(TLS_SLOT_OPENGL_API*4),                 \ | 
|  | 90 | [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api))    \ | 
|  | 91 | :                                                   \ | 
|  | 92 | ); | 
|  | 93 |  | 
|  | 94 | #define CALL_GL_API_RETURN(_api, ...) \ | 
|  | 95 | CALL_GL_API(_api, __VA_ARGS__) \ | 
|  | 96 | return 0; // placate gcc's warnings. never reached. | 
|  | 97 |  | 
|  | 98 | #else | 
|  | 99 |  | 
|  | 100 | #define API_ENTRY(_api) _api | 
|  | 101 |  | 
|  | 102 | #define CALL_GL_API(_api, ...)                                      \ | 
|  | 103 | gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \ | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 104 | _c->_api(__VA_ARGS__) | 
|  | 105 |  | 
|  | 106 | #define CALL_GL_API_RETURN(_api, ...)                               \ | 
|  | 107 | gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \ | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 108 | return _c->_api(__VA_ARGS__) | 
|  | 109 |  | 
|  | 110 | #endif | 
|  | 111 |  | 
| Mathias Agopian | 53238bd | 2009-04-22 18:24:18 -0700 | [diff] [blame] | 112 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 113 | extern "C" { | 
|  | 114 | #include "gl_api.in" | 
| Mathias Agopian | b519abb | 2009-04-23 18:05:44 -0700 | [diff] [blame] | 115 | #include "glext_api.in" | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 116 | } | 
|  | 117 |  | 
|  | 118 | #undef API_ENTRY | 
|  | 119 | #undef CALL_GL_API | 
|  | 120 | #undef CALL_GL_API_RETURN | 
|  | 121 |  | 
| Mathias Agopian | 53238bd | 2009-04-22 18:24:18 -0700 | [diff] [blame] | 122 |  | 
|  | 123 | /* | 
| Mathias Agopian | b519abb | 2009-04-23 18:05:44 -0700 | [diff] [blame] | 124 | * These GL calls are special because they need to call into EGL to retrieve | 
|  | 125 | * some informations before they can execute. | 
| Mathias Agopian | 53238bd | 2009-04-22 18:24:18 -0700 | [diff] [blame] | 126 | */ | 
|  | 127 |  | 
|  | 128 |  | 
|  | 129 | void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) | 
|  | 130 | { | 
|  | 131 | } | 
|  | 132 |  | 
|  | 133 | void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) | 
|  | 134 | { | 
|  | 135 | } | 
|  | 136 |  |