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 "gl_enc.h" 20 #include "GLClientState.h" 21 #include "GLSharedGroup.h" 22 #include "FixedBuffer.h" 23 24 class GLEncoder : public gl_encoder_context_t { 25 26 public: 27 GLEncoder(IOStream *stream); 28 virtual ~GLEncoder(); 29 void setClientState(GLClientState *state) { 30 m_state = state; 31 } 32 void setSharedGroup(GLSharedGroupPtr shared) { m_shared = shared; } 33 void flush() { m_stream->flush(); } 34 size_t pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack); 35 36 void setInitialized(){ m_initialized = true; }; 37 bool isInitialized(){ return m_initialized; }; 38 39 virtual void setError(GLenum error){ m_error = error; }; 40 virtual GLenum getError() { return m_error; }; 41 42 private: 43 44 bool m_initialized; 45 GLClientState *m_state; 46 GLSharedGroupPtr m_shared; 47 GLenum m_error; 48 FixedBuffer m_fixedBuffer; 49 GLint *m_compressedTextureFormats; 50 GLint m_num_compressedTextureFormats; 51 52 GLint *getCompressedTextureFormats(); 53 // original functions; 54 glGetError_client_proc_t m_glGetError_enc; 55 glGetIntegerv_client_proc_t m_glGetIntegerv_enc; 56 glGetFloatv_client_proc_t m_glGetFloatv_enc; 57 glGetFixedv_client_proc_t m_glGetFixedv_enc; 58 glGetBooleanv_client_proc_t m_glGetBooleanv_enc; 59 glGetPointerv_client_proc_t m_glGetPointerv_enc; 60 61 glPixelStorei_client_proc_t m_glPixelStorei_enc; 62 glVertexPointer_client_proc_t m_glVertexPointer_enc; 63 glNormalPointer_client_proc_t m_glNormalPointer_enc; 64 glColorPointer_client_proc_t m_glColorPointer_enc; 65 glPointSizePointerOES_client_proc_t m_glPointSizePointerOES_enc; 66 glTexCoordPointer_client_proc_t m_glTexCoordPointer_enc; 67 glClientActiveTexture_client_proc_t m_glClientActiveTexture_enc; 68 glMatrixIndexPointerOES_client_proc_t m_glMatrixIndexPointerOES_enc; 69 glWeightPointerOES_client_proc_t m_glWeightPointerOES_enc; 70 71 glBindBuffer_client_proc_t m_glBindBuffer_enc; 72 glBufferData_client_proc_t m_glBufferData_enc; 73 glBufferSubData_client_proc_t m_glBufferSubData_enc; 74 glDeleteBuffers_client_proc_t m_glDeleteBuffers_enc; 75 76 glEnableClientState_client_proc_t m_glEnableClientState_enc; 77 glDisableClientState_client_proc_t m_glDisableClientState_enc; 78 glIsEnabled_client_proc_t m_glIsEnabled_enc; 79 glDrawArrays_client_proc_t m_glDrawArrays_enc; 80 glDrawElements_client_proc_t m_glDrawElements_enc; 81 glFlush_client_proc_t m_glFlush_enc; 82 83 // statics 84 static GLenum s_glGetError(void * self); 85 static void s_glGetIntegerv(void *self, GLenum pname, GLint *ptr); 86 static void s_glGetBooleanv(void *self, GLenum pname, GLboolean *ptr); 87 static void s_glGetFloatv(void *self, GLenum pname, GLfloat *ptr); 88 static void s_glGetFixedv(void *self, GLenum pname, GLfixed *ptr); 89 static void s_glGetPointerv(void *self, GLenum pname, GLvoid **params); 90 91 static void s_glFlush(void * self); 92 static const GLubyte * s_glGetString(void *self, GLenum name); 93 static void s_glVertexPointer(void *self, int size, GLenum type, GLsizei stride, const void *data); 94 static void s_glNormalPointer(void *self, GLenum type, GLsizei stride, const void *data); 95 static void s_glColorPointer(void *self, int size, GLenum type, GLsizei stride, const void *data); 96 static void s_glPointsizePointer(void *self, GLenum type, GLsizei stride, const void *data); 97 static void s_glClientActiveTexture(void *self, GLenum texture); 98 static void s_glTexcoordPointer(void *self, int size, GLenum type, GLsizei stride, const void *data); 99 static void s_glMatrixIndexPointerOES(void *self, int size, GLenum type, GLsizei stride, const void * data); 100 static void s_glWeightPointerOES(void *self, int size, GLenum type, GLsizei stride, const void * data); 101 static void s_glDisableClientState(void *self, GLenum state); 102 static void s_glEnableClientState(void *self, GLenum state); 103 static GLboolean s_glIsEnabled(void *self, GLenum cap); 104 static void s_glBindBuffer(void *self, GLenum target, GLuint id); 105 static void s_glBufferData(void *self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage); 106 static void s_glBufferSubData(void *self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data); 107 static void s_glDeleteBuffers(void *self, GLsizei n, const GLuint * buffers); 108 109 110 static void s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count); 111 static void s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices); 112 static void s_glPixelStorei(void *self, GLenum param, GLint value); 113 114 static void s_glFinish(void *self); 115 static void s_glEGLImageTargetTexture2DOES(void * self, GLenum target, GLeglImageOES image); 116 void sendVertexData(unsigned first, unsigned count); 117 118 }; 119 #endif 120