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 | |
| 40 | void glColorPointerBounds(GLint size, GLenum type, GLsizei stride, |
| 41 | const GLvoid *ptr, GLsizei count) { |
| 42 | glColorPointer(size, type, stride, ptr); |
| 43 | } |
| 44 | void glNormalPointerBounds(GLenum type, GLsizei stride, |
| 45 | const GLvoid *pointer, GLsizei count) { |
| 46 | glNormalPointer(type, stride, pointer); |
| 47 | } |
| 48 | void glTexCoordPointerBounds(GLint size, GLenum type, |
| 49 | GLsizei stride, const GLvoid *pointer, GLsizei count) { |
| 50 | glTexCoordPointer(size, type, stride, pointer); |
| 51 | } |
| 52 | void glVertexPointerBounds(GLint size, GLenum type, |
| 53 | GLsizei stride, const GLvoid *pointer, GLsizei count) { |
| 54 | glVertexPointer(size, type, stride, pointer); |
| 55 | } |
| 56 | |
| 57 | // ---------------------------------------------------------------------------- |
| 58 | // Actual GL entry-points |
| 59 | // ---------------------------------------------------------------------------- |
| 60 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | #undef API_ENTRY |
| 62 | #undef CALL_GL_API |
| 63 | #undef CALL_GL_API_RETURN |
| 64 | |
| 65 | #if USE_FAST_TLS_KEY |
| 66 | |
| 67 | #define API_ENTRY(_api) __attribute__((naked)) _api |
| 68 | |
| 69 | #define CALL_GL_API(_api, ...) \ |
| 70 | asm volatile( \ |
| 71 | "mov r12, #0xFFFF0FFF \n" \ |
| 72 | "ldr r12, [r12, #-15] \n" \ |
| 73 | "ldr r12, [r12, %[tls]] \n" \ |
| 74 | "cmp r12, #0 \n" \ |
| 75 | "ldrne pc, [r12, %[api]] \n" \ |
| 76 | "bx lr \n" \ |
| 77 | : \ |
| 78 | : [tls] "J"(TLS_SLOT_OPENGL_API*4), \ |
| 79 | [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api)) \ |
| 80 | : \ |
| 81 | ); |
| 82 | |
| 83 | #define CALL_GL_API_RETURN(_api, ...) \ |
| 84 | CALL_GL_API(_api, __VA_ARGS__) \ |
| 85 | return 0; // placate gcc's warnings. never reached. |
| 86 | |
| 87 | #else |
| 88 | |
| 89 | #define API_ENTRY(_api) _api |
| 90 | |
| 91 | #define CALL_GL_API(_api, ...) \ |
| 92 | 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] | 93 | _c->_api(__VA_ARGS__) |
| 94 | |
| 95 | #define CALL_GL_API_RETURN(_api, ...) \ |
| 96 | 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] | 97 | return _c->_api(__VA_ARGS__) |
| 98 | |
| 99 | #endif |
| 100 | |
Mathias Agopian | 53238bd | 2009-04-22 18:24:18 -0700 | [diff] [blame^] | 101 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 102 | extern "C" { |
| 103 | #include "gl_api.in" |
| 104 | } |
| 105 | |
| 106 | #undef API_ENTRY |
| 107 | #undef CALL_GL_API |
| 108 | #undef CALL_GL_API_RETURN |
| 109 | |
Mathias Agopian | 53238bd | 2009-04-22 18:24:18 -0700 | [diff] [blame^] | 110 | |
| 111 | /* |
| 112 | * These GL calls are special because they need to EGL to retrieve some |
| 113 | * informations before they can execute. |
| 114 | */ |
| 115 | |
| 116 | |
| 117 | void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) |
| 118 | { |
| 119 | } |
| 120 | |
| 121 | void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) |
| 122 | { |
| 123 | } |
| 124 | |