blob: 0057168fdd6648507a97fb3b95cddab2d59ff622 [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#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 Agopian53238bd2009-04-22 18:24:18 -070032#include "egl_impl.h"
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080033
34using namespace android;
35
36// ----------------------------------------------------------------------------
37// extensions for the framework
38// ----------------------------------------------------------------------------
39
40void glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
41 const GLvoid *ptr, GLsizei count) {
42 glColorPointer(size, type, stride, ptr);
43}
44void glNormalPointerBounds(GLenum type, GLsizei stride,
45 const GLvoid *pointer, GLsizei count) {
46 glNormalPointer(type, stride, pointer);
47}
48void glTexCoordPointerBounds(GLint size, GLenum type,
49 GLsizei stride, const GLvoid *pointer, GLsizei count) {
50 glTexCoordPointer(size, type, stride, pointer);
51}
52void 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 Projectedbf3b62009-03-03 19:31:44 -080061#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 Projectedbf3b62009-03-03 19:31:44 -080093 _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 Projectedbf3b62009-03-03 19:31:44 -080097 return _c->_api(__VA_ARGS__)
98
99#endif
100
Mathias Agopian53238bd2009-04-22 18:24:18 -0700101
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800102extern "C" {
103#include "gl_api.in"
Mathias Agopianb519abb2009-04-23 18:05:44 -0700104#include "glext_api.in"
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800105}
106
107#undef API_ENTRY
108#undef CALL_GL_API
109#undef CALL_GL_API_RETURN
110
Mathias Agopian53238bd2009-04-22 18:24:18 -0700111
112/*
Mathias Agopianb519abb2009-04-23 18:05:44 -0700113 * These GL calls are special because they need to call into EGL to retrieve
114 * some informations before they can execute.
Mathias Agopian53238bd2009-04-22 18:24:18 -0700115 */
116
117
118void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
119{
120}
121
122void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
123{
124}
125