gl.cpp revision 9660d304ae51a69509e5506e1fc80178025dee7c
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" 32#include "egl_impl.h" 33 34using namespace android; 35 36// ---------------------------------------------------------------------------- 37// extensions for the framework 38// ---------------------------------------------------------------------------- 39 40extern "C" { 41GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride, 42 const GLvoid *ptr, GLsizei count); 43GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride, 44 const GLvoid *pointer, GLsizei count); 45GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type, 46 GLsizei stride, const GLvoid *pointer, GLsizei count); 47GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type, 48 GLsizei stride, const GLvoid *pointer, GLsizei count); 49} 50 51void glColorPointerBounds(GLint size, GLenum type, GLsizei stride, 52 const GLvoid *ptr, GLsizei count) { 53 glColorPointer(size, type, stride, ptr); 54} 55void glNormalPointerBounds(GLenum type, GLsizei stride, 56 const GLvoid *pointer, GLsizei count) { 57 glNormalPointer(type, stride, pointer); 58} 59void glTexCoordPointerBounds(GLint size, GLenum type, 60 GLsizei stride, const GLvoid *pointer, GLsizei count) { 61 glTexCoordPointer(size, type, stride, pointer); 62} 63void 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 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; \ 104 _c->_api(__VA_ARGS__) 105 106 #define CALL_GL_API_RETURN(_api, ...) \ 107 gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \ 108 return _c->_api(__VA_ARGS__) 109 110#endif 111 112 113extern "C" { 114#include "gl_api.in" 115#include "glext_api.in" 116} 117 118#undef API_ENTRY 119#undef CALL_GL_API 120#undef CALL_GL_API_RETURN 121 122 123/* 124 * These GL calls are special because they need to call into EGL to retrieve 125 * some informations before they can execute. 126 */ 127 128 129void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) 130{ 131} 132 133void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) 134{ 135} 136 137