Home | History | Annotate | Download | only in GLESv1_enc
      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     void override2DTextureTarget(GLenum target);
     43     void restore2DTextureTarget();
     44 
     45 private:
     46 
     47     bool    m_initialized;
     48     GLClientState *m_state;
     49     GLSharedGroupPtr m_shared;
     50     GLenum  m_error;
     51     FixedBuffer m_fixedBuffer;
     52     GLint *m_compressedTextureFormats;
     53     GLint m_num_compressedTextureFormats;
     54 
     55     GLint *getCompressedTextureFormats();
     56     // original functions;
     57     glGetError_client_proc_t    m_glGetError_enc;
     58     glGetIntegerv_client_proc_t m_glGetIntegerv_enc;
     59     glGetFloatv_client_proc_t m_glGetFloatv_enc;
     60     glGetFixedv_client_proc_t m_glGetFixedv_enc;
     61     glGetBooleanv_client_proc_t m_glGetBooleanv_enc;
     62     glGetPointerv_client_proc_t m_glGetPointerv_enc;
     63 
     64     glPixelStorei_client_proc_t m_glPixelStorei_enc;
     65     glVertexPointer_client_proc_t m_glVertexPointer_enc;
     66     glNormalPointer_client_proc_t m_glNormalPointer_enc;
     67     glColorPointer_client_proc_t m_glColorPointer_enc;
     68     glPointSizePointerOES_client_proc_t m_glPointSizePointerOES_enc;
     69     glTexCoordPointer_client_proc_t m_glTexCoordPointer_enc;
     70     glClientActiveTexture_client_proc_t m_glClientActiveTexture_enc;
     71     glMatrixIndexPointerOES_client_proc_t m_glMatrixIndexPointerOES_enc;
     72     glWeightPointerOES_client_proc_t m_glWeightPointerOES_enc;
     73 
     74     glBindBuffer_client_proc_t m_glBindBuffer_enc;
     75     glBufferData_client_proc_t m_glBufferData_enc;
     76     glBufferSubData_client_proc_t m_glBufferSubData_enc;
     77     glDeleteBuffers_client_proc_t m_glDeleteBuffers_enc;
     78 
     79     glEnableClientState_client_proc_t m_glEnableClientState_enc;
     80     glDisableClientState_client_proc_t m_glDisableClientState_enc;
     81     glIsEnabled_client_proc_t m_glIsEnabled_enc;
     82     glDrawArrays_client_proc_t m_glDrawArrays_enc;
     83     glDrawElements_client_proc_t m_glDrawElements_enc;
     84     glFlush_client_proc_t m_glFlush_enc;
     85 
     86     glActiveTexture_client_proc_t m_glActiveTexture_enc;
     87     glBindTexture_client_proc_t m_glBindTexture_enc;
     88     glDeleteTextures_client_proc_t m_glDeleteTextures_enc;
     89     glDisable_client_proc_t m_glDisable_enc;
     90     glEnable_client_proc_t m_glEnable_enc;
     91     glGetTexParameterfv_client_proc_t m_glGetTexParameterfv_enc;
     92     glGetTexParameteriv_client_proc_t m_glGetTexParameteriv_enc;
     93     glGetTexParameterxv_client_proc_t m_glGetTexParameterxv_enc;
     94     glTexParameterf_client_proc_t m_glTexParameterf_enc;
     95     glTexParameterfv_client_proc_t m_glTexParameterfv_enc;
     96     glTexParameteri_client_proc_t m_glTexParameteri_enc;
     97     glTexParameterx_client_proc_t m_glTexParameterx_enc;
     98     glTexParameteriv_client_proc_t m_glTexParameteriv_enc;
     99     glTexParameterxv_client_proc_t m_glTexParameterxv_enc;
    100 
    101     // statics
    102     static GLenum s_glGetError(void * self);
    103     static void s_glGetIntegerv(void *self, GLenum pname, GLint *ptr);
    104     static void s_glGetBooleanv(void *self, GLenum pname, GLboolean *ptr);
    105     static void s_glGetFloatv(void *self, GLenum pname, GLfloat *ptr);
    106     static void s_glGetFixedv(void *self, GLenum pname, GLfixed *ptr);
    107     static void s_glGetPointerv(void *self, GLenum pname, GLvoid **params);
    108 
    109     static void s_glFlush(void * self);
    110     static const GLubyte * s_glGetString(void *self, GLenum name);
    111     static void s_glVertexPointer(void *self, int size, GLenum type, GLsizei stride, const void *data);
    112     static void s_glNormalPointer(void *self, GLenum type, GLsizei stride, const void *data);
    113     static void s_glColorPointer(void *self, int size, GLenum type, GLsizei stride, const void *data);
    114     static void s_glPointSizePointerOES(void *self, GLenum type, GLsizei stride, const void *data);
    115     static void s_glClientActiveTexture(void *self, GLenum texture);
    116     static void s_glTexCoordPointer(void *self, int size, GLenum type, GLsizei stride, const void *data);
    117     static void s_glMatrixIndexPointerOES(void *self, int size, GLenum type, GLsizei stride, const void * data);
    118     static void s_glWeightPointerOES(void *self, int size, GLenum type, GLsizei stride, const void * data);
    119     static void s_glDisableClientState(void *self, GLenum state);
    120     static void s_glEnableClientState(void *self, GLenum state);
    121     static GLboolean s_glIsEnabled(void *self, GLenum cap);
    122     static void s_glBindBuffer(void *self, GLenum target, GLuint id);
    123     static void s_glBufferData(void *self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
    124     static void s_glBufferSubData(void *self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data);
    125     static void s_glDeleteBuffers(void *self, GLsizei n, const GLuint * buffers);
    126 
    127     static void s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count);
    128     static void s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices);
    129     static void s_glPixelStorei(void *self, GLenum param, GLint value);
    130 
    131     static void s_glFinish(void *self);
    132     void sendVertexData(unsigned first, unsigned count);
    133 
    134     static void s_glActiveTexture(void* self, GLenum texture);
    135     static void s_glBindTexture(void* self, GLenum target, GLuint texture);
    136     static void s_glDeleteTextures(void* self, GLsizei n, const GLuint* textures);
    137     static void s_glDisable(void* self, GLenum cap);
    138     static void s_glEnable(void* self, GLenum cap);
    139     static void s_glGetTexParameterfv(void* self, GLenum target, GLenum pname, GLfloat* params);
    140     static void s_glGetTexParameteriv(void* self, GLenum target, GLenum pname, GLint* params);
    141     static void s_glGetTexParameterxv(void* self, GLenum target, GLenum pname, GLfixed* params);
    142     static void s_glTexParameterf(void* self, GLenum target, GLenum pname, GLfloat param);
    143     static void s_glTexParameterfv(void* self, GLenum target, GLenum pname, const GLfloat* params);
    144     static void s_glTexParameteri(void* self, GLenum target, GLenum pname, GLint param);
    145     static void s_glTexParameterx(void* self, GLenum target, GLenum pname, GLfixed param);
    146     static void s_glTexParameteriv(void* self, GLenum target, GLenum pname, const GLint* params);
    147     static void s_glTexParameterxv(void* self, GLenum target, GLenum pname, const GLfixed* params);
    148 };
    149 #endif
    150