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