• 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 _GL_ENCODER_H_
17 #define _GL_ENCODER_H_
18 
19 #include <vector>
20 
21 #include "gl_enc.h"
22 #include "GLClientState.h"
23 #include "GLSharedGroup.h"
24 #include "ChecksumCalculator.h"
25 
26 class GLEncoder : public gl_encoder_context_t {
27 
28 public:
29     GLEncoder(IOStream *stream, ChecksumCalculator* protocol);
30     virtual ~GLEncoder();
setClientState(GLClientState * state)31     void setClientState(GLClientState *state) {
32         m_state = state;
33     }
setSharedGroup(GLSharedGroupPtr shared)34     void setSharedGroup(GLSharedGroupPtr shared) {
35         m_shared = shared;
36         if (m_state && m_shared.Ptr())
37             m_state->setTextureData(m_shared->getTextureData());
38     }
flush()39     void flush() { m_stream->flush(); }
40     size_t pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack);
41 
setInitialized()42     void setInitialized(){ m_initialized = true; };
isInitialized()43     bool isInitialized(){ return m_initialized; };
44 
setError(GLenum error)45     virtual void setError(GLenum error){ m_error = error; };
getError()46     virtual GLenum getError() { return m_error; };
47 
48     void override2DTextureTarget(GLenum target);
49     void restore2DTextureTarget();
50 
51 private:
52 
53     bool    m_initialized;
54     GLClientState *m_state;
55     GLSharedGroupPtr m_shared;
56     GLenum  m_error;
57     std::vector<char> m_fixedBuffer;
58     GLint *m_compressedTextureFormats;
59     GLint m_num_compressedTextureFormats;
60 
61     GLint *getCompressedTextureFormats();
62     // original functions;
63     glGetError_client_proc_t    m_glGetError_enc;
64     glGetIntegerv_client_proc_t m_glGetIntegerv_enc;
65     glGetFloatv_client_proc_t m_glGetFloatv_enc;
66     glGetFixedv_client_proc_t m_glGetFixedv_enc;
67     glGetBooleanv_client_proc_t m_glGetBooleanv_enc;
68     glGetPointerv_client_proc_t m_glGetPointerv_enc;
69 
70     glPixelStorei_client_proc_t m_glPixelStorei_enc;
71     glVertexPointer_client_proc_t m_glVertexPointer_enc;
72     glNormalPointer_client_proc_t m_glNormalPointer_enc;
73     glColorPointer_client_proc_t m_glColorPointer_enc;
74     glPointSizePointerOES_client_proc_t m_glPointSizePointerOES_enc;
75     glTexCoordPointer_client_proc_t m_glTexCoordPointer_enc;
76     glClientActiveTexture_client_proc_t m_glClientActiveTexture_enc;
77     glMatrixIndexPointerOES_client_proc_t m_glMatrixIndexPointerOES_enc;
78     glWeightPointerOES_client_proc_t m_glWeightPointerOES_enc;
79 
80     glBindBuffer_client_proc_t m_glBindBuffer_enc;
81     glBufferData_client_proc_t m_glBufferData_enc;
82     glBufferSubData_client_proc_t m_glBufferSubData_enc;
83     glDeleteBuffers_client_proc_t m_glDeleteBuffers_enc;
84 
85     glEnableClientState_client_proc_t m_glEnableClientState_enc;
86     glDisableClientState_client_proc_t m_glDisableClientState_enc;
87     glIsEnabled_client_proc_t m_glIsEnabled_enc;
88     glDrawArrays_client_proc_t m_glDrawArrays_enc;
89     glDrawElements_client_proc_t m_glDrawElements_enc;
90     glFlush_client_proc_t m_glFlush_enc;
91 
92     glActiveTexture_client_proc_t m_glActiveTexture_enc;
93     glBindTexture_client_proc_t m_glBindTexture_enc;
94     glDeleteTextures_client_proc_t m_glDeleteTextures_enc;
95     glDisable_client_proc_t m_glDisable_enc;
96     glEnable_client_proc_t m_glEnable_enc;
97     glGetTexParameterfv_client_proc_t m_glGetTexParameterfv_enc;
98     glGetTexParameteriv_client_proc_t m_glGetTexParameteriv_enc;
99     glGetTexParameterxv_client_proc_t m_glGetTexParameterxv_enc;
100     glTexParameterf_client_proc_t m_glTexParameterf_enc;
101     glTexParameterfv_client_proc_t m_glTexParameterfv_enc;
102     glTexParameteri_client_proc_t m_glTexParameteri_enc;
103     glTexParameterx_client_proc_t m_glTexParameterx_enc;
104     glTexParameteriv_client_proc_t m_glTexParameteriv_enc;
105     glTexParameterxv_client_proc_t m_glTexParameterxv_enc;
106 
107     glGenFramebuffersOES_client_proc_t m_glGenFramebuffersOES_enc;
108     glDeleteFramebuffersOES_client_proc_t m_glDeleteFramebuffersOES_enc;
109     glBindFramebufferOES_client_proc_t m_glBindFramebufferOES_enc;
110     glFramebufferTexture2DOES_client_proc_t m_glFramebufferTexture2DOES_enc;
111     glFramebufferTexture2DMultisampleIMG_client_proc_t m_glFramebufferTexture2DMultisampleIMG_enc;
112     glGetFramebufferAttachmentParameterivOES_client_proc_t m_glGetFramebufferAttachmentParameterivOES_enc;
113 
114     // statics
115     static GLenum s_glGetError(void * self);
116     static void s_glGetIntegerv(void *self, GLenum pname, GLint *ptr);
117     static void s_glGetBooleanv(void *self, GLenum pname, GLboolean *ptr);
118     static void s_glGetFloatv(void *self, GLenum pname, GLfloat *ptr);
119     static void s_glGetFixedv(void *self, GLenum pname, GLfixed *ptr);
120     static void s_glGetPointerv(void *self, GLenum pname, GLvoid **params);
121 
122     static void s_glFlush(void * self);
123     static const GLubyte * s_glGetString(void *self, GLenum name);
124     static void s_glVertexPointer(void *self, int size, GLenum type, GLsizei stride, const void *data);
125     static void s_glNormalPointer(void *self, GLenum type, GLsizei stride, const void *data);
126     static void s_glColorPointer(void *self, int size, GLenum type, GLsizei stride, const void *data);
127     static void s_glPointSizePointerOES(void *self, GLenum type, GLsizei stride, const void *data);
128     static void s_glClientActiveTexture(void *self, GLenum texture);
129     static void s_glTexCoordPointer(void *self, int size, GLenum type, GLsizei stride, const void *data);
130     static void s_glMatrixIndexPointerOES(void *self, int size, GLenum type, GLsizei stride, const void * data);
131     static void s_glWeightPointerOES(void *self, int size, GLenum type, GLsizei stride, const void * data);
132     static void s_glDisableClientState(void *self, GLenum state);
133     static void s_glEnableClientState(void *self, GLenum state);
134     static GLboolean s_glIsEnabled(void *self, GLenum cap);
135     static void s_glBindBuffer(void *self, GLenum target, GLuint id);
136     static void s_glBufferData(void *self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
137     static void s_glBufferSubData(void *self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data);
138     static void s_glDeleteBuffers(void *self, GLsizei n, const GLuint * buffers);
139 
140     static void s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count);
141     static void s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices);
142     static void s_glPixelStorei(void *self, GLenum param, GLint value);
143 
144     static void s_glFinish(void *self);
145     void sendVertexData(unsigned first, unsigned count);
146 
147     static void s_glActiveTexture(void* self, GLenum texture);
148     static void s_glBindTexture(void* self, GLenum target, GLuint texture);
149     static void s_glDeleteTextures(void* self, GLsizei n, const GLuint* textures);
150     static void s_glDisable(void* self, GLenum cap);
151     static void s_glEnable(void* self, GLenum cap);
152     static void s_glGetTexParameterfv(void* self, GLenum target, GLenum pname, GLfloat* params);
153     static void s_glGetTexParameteriv(void* self, GLenum target, GLenum pname, GLint* params);
154     static void s_glGetTexParameterxv(void* self, GLenum target, GLenum pname, GLfixed* params);
155     static void s_glTexParameterf(void* self, GLenum target, GLenum pname, GLfloat param);
156     static void s_glTexParameterfv(void* self, GLenum target, GLenum pname, const GLfloat* params);
157     static void s_glTexParameteri(void* self, GLenum target, GLenum pname, GLint param);
158     static void s_glTexParameterx(void* self, GLenum target, GLenum pname, GLfixed param);
159     static void s_glTexParameteriv(void* self, GLenum target, GLenum pname, const GLint* params);
160     static void s_glTexParameterxv(void* self, GLenum target, GLenum pname, const GLfixed* params);
161 
162     static void s_glGenFramebuffersOES(void* self, GLsizei n, GLuint* framebuffers);
163     static void s_glDeleteFramebuffersOES(void* self, GLsizei n, const GLuint* framebuffers);
164     static void s_glBindFramebufferOES(void* self, GLenum target, GLuint framebuffer);
165     static void s_glFramebufferTexture2DOES(void* self, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
166     static void s_glFramebufferTexture2DMultisampleIMG(void* self, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
167     static void s_glGetFramebufferAttachmentParameterivOES(void* self, GLenum target, GLenum attachment, GLenum pname, GLint* params);
168     static void s_glReadnPixelsEXT(void* self, GLint x, GLint y, GLsizei width,
169             GLsizei height, GLenum format, GLenum type, GLsizei bufSize,
170             GLvoid* pixels);
171 
172 public:
173     glEGLImageTargetTexture2DOES_client_proc_t m_glEGLImageTargetTexture2DOES_enc;
174 
175 };
176 #endif
177