• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (C) 2011 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 #ifndef _GL2_ENCODER_H_
17 #define _GL2_ENCODER_H_
18 
19 #include "gl2_enc.h"
20 #include "GLClientState.h"
21 #include "GLSharedGroup.h"
22 #include "FixedBuffer.h"
23 
24 class GL2Encoder : public gl2_encoder_context_t {
25 public:
26     GL2Encoder(IOStream *stream, ChecksumCalculator* protocol);
27     virtual ~GL2Encoder();
setClientState(GLClientState * state)28     void setClientState(GLClientState *state) {
29         m_state = state;
30     }
setClientStateMakeCurrent(GLClientState * state)31     void setClientStateMakeCurrent(GLClientState *state) {
32         m_state = state;
33         m_state->fromMakeCurrent();
34     }
setSharedGroup(GLSharedGroupPtr shared)35     void setSharedGroup(GLSharedGroupPtr shared){ m_shared = shared; }
state()36     const GLClientState *state() { return m_state; }
shared()37     const GLSharedGroupPtr shared() { return m_shared; }
flush()38     void flush() { m_stream->flush(); }
39 
setInitialized()40     void setInitialized(){ m_initialized = true; };
isInitialized()41     bool isInitialized(){ return m_initialized; };
42 
setError(GLenum error)43     virtual void setError(GLenum error){ m_error = error; };
getError()44     virtual GLenum getError() { return m_error; };
45 
46     void override2DTextureTarget(GLenum target);
47     void restore2DTextureTarget(GLenum target);
48 
49 
50 private:
51 
52     bool    m_initialized;
53     GLClientState *m_state;
54     GLSharedGroupPtr m_shared;
55     GLenum  m_error;
56 
57     GLint *m_compressedTextureFormats;
58     GLint m_num_compressedTextureFormats;
59     GLint *getCompressedTextureFormats();
60 
61     GLint m_max_cubeMapTextureSize;
62     GLint m_max_renderBufferSize;
63     GLint m_max_textureSize;
64     FixedBuffer m_fixedBuffer;
65 
66     void sendVertexAttributes(GLint first, GLsizei count);
67     bool updateHostTexture2DBinding(GLenum texUnit, GLenum newTarget);
68     bool texture2DNeedsOverride(GLenum target) const;
69     bool isCompleteFbo(const GLClientState* state, GLenum attachment) const;
70 
71     glGetError_client_proc_t    m_glGetError_enc;
72     static GLenum s_glGetError(void * self);
73 
74     glFlush_client_proc_t m_glFlush_enc;
75     static void s_glFlush(void * self);
76 
77     glPixelStorei_client_proc_t m_glPixelStorei_enc;
78     static void s_glPixelStorei(void *self, GLenum param, GLint value);
79 
80     glGetString_client_proc_t m_glGetString_enc;
81     static const GLubyte * s_glGetString(void *self, GLenum name);
82 
83     glBindBuffer_client_proc_t m_glBindBuffer_enc;
84     static void s_glBindBuffer(void *self, GLenum target, GLuint id);
85 
86 
87     glBufferData_client_proc_t m_glBufferData_enc;
88     static void s_glBufferData(void *self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
89     glBufferSubData_client_proc_t m_glBufferSubData_enc;
90     static void s_glBufferSubData(void *self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data);
91     glDeleteBuffers_client_proc_t m_glDeleteBuffers_enc;
92     static void s_glDeleteBuffers(void *self, GLsizei n, const GLuint * buffers);
93 
94     glDrawArrays_client_proc_t m_glDrawArrays_enc;
95     static void s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count);
96 
97     glDrawElements_client_proc_t m_glDrawElements_enc;
98     static void s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices);
99 
100 
101     glGetIntegerv_client_proc_t m_glGetIntegerv_enc;
102     static void s_glGetIntegerv(void *self, GLenum pname, GLint *ptr);
103 
104     glGetFloatv_client_proc_t m_glGetFloatv_enc;
105     static void s_glGetFloatv(void *self, GLenum pname, GLfloat *ptr);
106 
107     glGetBooleanv_client_proc_t m_glGetBooleanv_enc;
108     static void s_glGetBooleanv(void *self, GLenum pname, GLboolean *ptr);
109 
110     glVertexAttribPointer_client_proc_t m_glVertexAttribPointer_enc;
111     static void s_glVertexAttribPointer(void *self, GLuint indx, GLint size, GLenum type,
112                                         GLboolean normalized, GLsizei stride, const GLvoid * ptr);
113 
114     glEnableVertexAttribArray_client_proc_t m_glEnableVertexAttribArray_enc;
115     static void s_glEnableVertexAttribArray(void *self, GLuint index);
116 
117     glDisableVertexAttribArray_client_proc_t m_glDisableVertexAttribArray_enc;
118     static void s_glDisableVertexAttribArray(void *self, GLuint index);
119 
120     glGetVertexAttribiv_client_proc_t m_glGetVertexAttribiv_enc;
121     static void s_glGetVertexAttribiv(void *self, GLuint index, GLenum pname, GLint *params);
122 
123     glGetVertexAttribfv_client_proc_t m_glGetVertexAttribfv_enc;
124     static void s_glGetVertexAttribfv(void *self, GLuint index, GLenum pname, GLfloat *params);
125 
126     glGetVertexAttribPointerv_client_proc_t m_glGetVertexAttribPointerv_enc;
127     static void s_glGetVertexAttribPointerv(void *self, GLuint index, GLenum pname, GLvoid **pointer);
128 
129     static void s_glShaderBinary(void *self, GLsizei n, const GLuint *shaders, GLenum binaryformat, const void* binary, GLsizei length);
130 
131     static void s_glShaderSource(void *self, GLuint shader, GLsizei count, const GLchar * const *string, const GLint *length);
132 
133     static void s_glFinish(void *self);
134 
135     glLinkProgram_client_proc_t m_glLinkProgram_enc;
136     static void s_glLinkProgram(void *self, GLuint program);
137 
138     glDeleteProgram_client_proc_t m_glDeleteProgram_enc;
139     static void s_glDeleteProgram(void * self, GLuint program);
140 
141     glGetUniformiv_client_proc_t m_glGetUniformiv_enc;
142     static void s_glGetUniformiv(void *self, GLuint program, GLint location , GLint *params);
143 
144     glGetUniformfv_client_proc_t m_glGetUniformfv_enc;
145     static void s_glGetUniformfv(void *self, GLuint program, GLint location , GLfloat *params);
146 
147     glCreateProgram_client_proc_t m_glCreateProgram_enc;
148     static GLuint s_glCreateProgram(void *self);
149 
150     glCreateShader_client_proc_t m_glCreateShader_enc;
151     static GLuint s_glCreateShader(void *self, GLenum shaderType);
152 
153     glDeleteShader_client_proc_t m_glDeleteShader_enc;
154     static void s_glDeleteShader(void *self, GLuint shader);
155 
156     glAttachShader_client_proc_t m_glAttachShader_enc;
157     static void s_glAttachShader(void *self, GLuint program, GLuint shader);
158 
159     glDetachShader_client_proc_t m_glDetachShader_enc;
160     static void s_glDetachShader(void *self, GLuint program, GLuint shader);
161 
162     glGetAttachedShaders_client_proc_t m_glGetAttachedShaders_enc;
163     static void s_glGetAttachedShaders(void *self, GLuint program, GLsizei maxCount,
164             GLsizei* count, GLuint* shaders);
165 
166     glGetShaderSource_client_proc_t m_glGetShaderSource_enc;
167     static void s_glGetShaderSource(void *self, GLuint shader, GLsizei bufsize,
168             GLsizei* length, GLchar* source);
169 
170     glGetShaderInfoLog_client_proc_t m_glGetShaderInfoLog_enc;
171     static void s_glGetShaderInfoLog(void *self,GLuint shader,
172             GLsizei bufsize, GLsizei* length, GLchar* infolog);
173 
174     glGetProgramInfoLog_client_proc_t m_glGetProgramInfoLog_enc;
175     static void s_glGetProgramInfoLog(void *self,GLuint program,
176             GLsizei bufsize, GLsizei* length, GLchar* infolog);
177 
178     glGetUniformLocation_client_proc_t m_glGetUniformLocation_enc;
179     static int s_glGetUniformLocation(void *self, GLuint program, const GLchar *name);
180     glUseProgram_client_proc_t m_glUseProgram_enc;
181 
182     glUniform1f_client_proc_t m_glUniform1f_enc;
183     glUniform1fv_client_proc_t m_glUniform1fv_enc;
184     glUniform1i_client_proc_t m_glUniform1i_enc;
185     glUniform1iv_client_proc_t m_glUniform1iv_enc;
186     glUniform2f_client_proc_t m_glUniform2f_enc;
187     glUniform2fv_client_proc_t m_glUniform2fv_enc;
188     glUniform2i_client_proc_t m_glUniform2i_enc;
189     glUniform2iv_client_proc_t m_glUniform2iv_enc;
190     glUniform3f_client_proc_t m_glUniform3f_enc;
191     glUniform3fv_client_proc_t m_glUniform3fv_enc;
192     glUniform3i_client_proc_t m_glUniform3i_enc;
193     glUniform3iv_client_proc_t m_glUniform3iv_enc;
194     glUniform4f_client_proc_t m_glUniform4f_enc;
195     glUniform4fv_client_proc_t m_glUniform4fv_enc;
196     glUniform4i_client_proc_t m_glUniform4i_enc;
197     glUniform4iv_client_proc_t m_glUniform4iv_enc;
198     glUniformMatrix2fv_client_proc_t m_glUniformMatrix2fv_enc;
199     glUniformMatrix3fv_client_proc_t m_glUniformMatrix3fv_enc;
200     glUniformMatrix4fv_client_proc_t m_glUniformMatrix4fv_enc;
201 
202     static void s_glUseProgram(void *self, GLuint program);
203 	static void s_glUniform1f(void *self , GLint location, GLfloat x);
204 	static void s_glUniform1fv(void *self , GLint location, GLsizei count, const GLfloat* v);
205 	static void s_glUniform1i(void *self , GLint location, GLint x);
206 	static void s_glUniform1iv(void *self , GLint location, GLsizei count, const GLint* v);
207 	static void s_glUniform2f(void *self , GLint location, GLfloat x, GLfloat y);
208 	static void s_glUniform2fv(void *self , GLint location, GLsizei count, const GLfloat* v);
209 	static void s_glUniform2i(void *self , GLint location, GLint x, GLint y);
210 	static void s_glUniform2iv(void *self , GLint location, GLsizei count, const GLint* v);
211 	static void s_glUniform3f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z);
212 	static void s_glUniform3fv(void *self , GLint location, GLsizei count, const GLfloat* v);
213 	static void s_glUniform3i(void *self , GLint location, GLint x, GLint y, GLint z);
214 	static void s_glUniform3iv(void *self , GLint location, GLsizei count, const GLint* v);
215 	static void s_glUniform4f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
216 	static void s_glUniform4fv(void *self , GLint location, GLsizei count, const GLfloat* v);
217 	static void s_glUniform4i(void *self , GLint location, GLint x, GLint y, GLint z, GLint w);
218 	static void s_glUniform4iv(void *self , GLint location, GLsizei count, const GLint* v);
219 	static void s_glUniformMatrix2fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
220 	static void s_glUniformMatrix3fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
221 	static void s_glUniformMatrix4fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
222 
223     glActiveTexture_client_proc_t m_glActiveTexture_enc;
224     glBindTexture_client_proc_t m_glBindTexture_enc;
225     glDeleteTextures_client_proc_t m_glDeleteTextures_enc;
226     glGetTexParameterfv_client_proc_t m_glGetTexParameterfv_enc;
227     glGetTexParameteriv_client_proc_t m_glGetTexParameteriv_enc;
228     glTexParameterf_client_proc_t m_glTexParameterf_enc;
229     glTexParameterfv_client_proc_t m_glTexParameterfv_enc;
230     glTexParameteri_client_proc_t m_glTexParameteri_enc;
231     glTexParameteriv_client_proc_t m_glTexParameteriv_enc;
232     glTexImage2D_client_proc_t m_glTexImage2D_enc;
233     glTexSubImage2D_client_proc_t m_glTexSubImage2D_enc;
234     glCopyTexImage2D_client_proc_t m_glCopyTexImage2D_enc;
235 
236     static void s_glActiveTexture(void* self, GLenum texture);
237     static void s_glBindTexture(void* self, GLenum target, GLuint texture);
238     static void s_glDeleteTextures(void* self, GLsizei n, const GLuint* textures);
239     static void s_glGetTexParameterfv(void* self, GLenum target, GLenum pname, GLfloat* params);
240     static void s_glGetTexParameteriv(void* self, GLenum target, GLenum pname, GLint* params);
241     static void s_glTexParameterf(void* self, GLenum target, GLenum pname, GLfloat param);
242     static void s_glTexParameterfv(void* self, GLenum target, GLenum pname, const GLfloat* params);
243     static void s_glTexParameteri(void* self, GLenum target, GLenum pname, GLint param);
244     static void s_glTexParameteriv(void* self, GLenum target, GLenum pname, const GLint* params);
245     static void s_glTexImage2D(void* self, GLenum target, GLint level, GLint internalformat,
246             GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type,
247             const GLvoid* pixels);
248     static void s_glTexSubImage2D(void* self, GLenum target, GLint level, GLint xoffset,
249             GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type,
250             const GLvoid* pixels);
251     static void s_glCopyTexImage2D(void* self, GLenum target, GLint level, GLenum internalformat,
252             GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
253 
254     glGenRenderbuffers_client_proc_t m_glGenRenderbuffers_enc;
255     static void s_glGenRenderbuffers(void* self, GLsizei n, GLuint* renderbuffers);
256     glDeleteRenderbuffers_client_proc_t m_glDeleteRenderbuffers_enc;
257     static void s_glDeleteRenderbuffers(void* self, GLsizei n, const GLuint* renderbuffers);
258 
259     glBindRenderbuffer_client_proc_t m_glBindRenderbuffer_enc;
260     static void s_glBindRenderbuffer(void* self, GLenum target, GLuint renderbuffer);
261 
262     glRenderbufferStorage_client_proc_t m_glRenderbufferStorage_enc;
263     static void s_glRenderbufferStorage(void* self, GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
264 
265     glFramebufferRenderbuffer_client_proc_t m_glFramebufferRenderbuffer_enc;
266     static void s_glFramebufferRenderbuffer(void* self, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
267 
268     glGenFramebuffers_client_proc_t m_glGenFramebuffers_enc;
269     static void s_glGenFramebuffers(void* self, GLsizei n, GLuint* framebuffers);
270     glDeleteFramebuffers_client_proc_t m_glDeleteFramebuffers_enc;
271     static void s_glDeleteFramebuffers(void* self, GLsizei n, const GLuint* framebuffers);
272 
273     glBindFramebuffer_client_proc_t m_glBindFramebuffer_enc;
274     static void s_glBindFramebuffer(void* self, GLenum target, GLuint framebuffer);
275 
276     glFramebufferTexture2D_client_proc_t m_glFramebufferTexture2D_enc;
277     static void s_glFramebufferTexture2D(void* self, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
278 
279     glFramebufferTexture3DOES_client_proc_t m_glFramebufferTexture3DOES_enc;
280     static void s_glFramebufferTexture3DOES(void*self, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
281 
282     glGetFramebufferAttachmentParameteriv_client_proc_t m_glGetFramebufferAttachmentParameteriv_enc;
283     static void s_glGetFramebufferAttachmentParameteriv(void* self, GLenum target, GLenum attachment, GLenum pname, GLint* params);
284 
285     glCheckFramebufferStatus_client_proc_t m_glCheckFramebufferStatus_enc;
286     static GLenum s_glCheckFramebufferStatus(void* self,
287             GLenum target);
288 
289 
290 public:
291     glEGLImageTargetTexture2DOES_client_proc_t m_glEGLImageTargetTexture2DOES_enc;
292 
293 };
294 #endif
295