Home | History | Annotate | Download | only in GLESv2_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 _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 
     25 class GL2Encoder : public gl2_encoder_context_t {
     26 public:
     27     GL2Encoder(IOStream *stream);
     28     virtual ~GL2Encoder();
     29     void setClientState(GLClientState *state) {
     30         m_state = state;
     31     }
     32     void setSharedGroup(GLSharedGroupPtr shared){ m_shared = shared; }
     33     const GLClientState *state() { return m_state; }
     34     const GLSharedGroupPtr shared() { return m_shared; }
     35     void flush() { m_stream->flush(); }
     36 
     37     void setInitialized(){ m_initialized = true; };
     38     bool isInitialized(){ return m_initialized; };
     39 
     40     virtual void setError(GLenum error){ m_error = error; };
     41     virtual GLenum getError() { return m_error; };
     42 
     43     void override2DTextureTarget(GLenum target);
     44     void restore2DTextureTarget();
     45 
     46 private:
     47 
     48     bool    m_initialized;
     49     GLClientState *m_state;
     50     GLSharedGroupPtr m_shared;
     51     GLenum  m_error;
     52 
     53     GLint *m_compressedTextureFormats;
     54     GLint m_num_compressedTextureFormats;
     55     GLint *getCompressedTextureFormats();
     56 
     57     FixedBuffer m_fixedBuffer;
     58 
     59     void sendVertexAttributes(GLint first, GLsizei count);
     60     bool updateHostTexture2DBinding(GLenum texUnit, GLenum newTarget);
     61 
     62     glGetError_client_proc_t    m_glGetError_enc;
     63     static GLenum s_glGetError(void * self);
     64 
     65     glFlush_client_proc_t m_glFlush_enc;
     66     static void s_glFlush(void * self);
     67 
     68     glPixelStorei_client_proc_t m_glPixelStorei_enc;
     69     static void s_glPixelStorei(void *self, GLenum param, GLint value);
     70 
     71     glGetString_client_proc_t m_glGetString_enc;
     72     static const GLubyte * s_glGetString(void *self, GLenum name);
     73 
     74     glBindBuffer_client_proc_t m_glBindBuffer_enc;
     75     static void s_glBindBuffer(void *self, GLenum target, GLuint id);
     76 
     77 
     78     glBufferData_client_proc_t m_glBufferData_enc;
     79     static void s_glBufferData(void *self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
     80     glBufferSubData_client_proc_t m_glBufferSubData_enc;
     81     static void s_glBufferSubData(void *self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data);
     82     glDeleteBuffers_client_proc_t m_glDeleteBuffers_enc;
     83     static void s_glDeleteBuffers(void *self, GLsizei n, const GLuint * buffers);
     84 
     85     glDrawArrays_client_proc_t m_glDrawArrays_enc;
     86     static void s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count);
     87 
     88     glDrawElements_client_proc_t m_glDrawElements_enc;
     89     static void s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices);
     90 
     91 
     92     glGetIntegerv_client_proc_t m_glGetIntegerv_enc;
     93     static void s_glGetIntegerv(void *self, GLenum pname, GLint *ptr);
     94 
     95     glGetFloatv_client_proc_t m_glGetFloatv_enc;
     96     static void s_glGetFloatv(void *self, GLenum pname, GLfloat *ptr);
     97 
     98     glGetBooleanv_client_proc_t m_glGetBooleanv_enc;
     99     static void s_glGetBooleanv(void *self, GLenum pname, GLboolean *ptr);
    100 
    101     glVertexAttribPointer_client_proc_t m_glVertexAttribPointer_enc;
    102     static void s_glVertexAtrribPointer(void *self, GLuint indx, GLint size, GLenum type,
    103                                         GLboolean normalized, GLsizei stride, const GLvoid * ptr);
    104 
    105     glEnableVertexAttribArray_client_proc_t m_glEnableVertexAttribArray_enc;
    106     static void s_glEnableVertexAttribArray(void *self, GLuint index);
    107 
    108     glDisableVertexAttribArray_client_proc_t m_glDisableVertexAttribArray_enc;
    109     static void s_glDisableVertexAttribArray(void *self, GLuint index);
    110 
    111     glGetVertexAttribiv_client_proc_t m_glGetVertexAttribiv_enc;
    112     static void s_glGetVertexAttribiv(void *self, GLuint index, GLenum pname, GLint *params);
    113 
    114     glGetVertexAttribfv_client_proc_t m_glGetVertexAttribfv_enc;
    115     static void s_glGetVertexAttribfv(void *self, GLuint index, GLenum pname, GLfloat *params);
    116 
    117     glGetVertexAttribPointerv_client_proc_t m_glGetVertexAttribPointerv;
    118     static void s_glGetVertexAttribPointerv(void *self, GLuint index, GLenum pname, GLvoid **pointer);
    119 
    120     static void s_glShaderSource(void *self, GLuint shader, GLsizei count, const GLchar *const *string, const GLint *length);
    121 
    122     static void s_glFinish(void *self);
    123 
    124     glLinkProgram_client_proc_t m_glLinkProgram_enc;
    125     static void s_glLinkProgram(void *self, GLuint program);
    126 
    127     glDeleteProgram_client_proc_t m_glDeleteProgram_enc;
    128     static void s_glDeleteProgram(void * self, GLuint program);
    129 
    130     glGetUniformiv_client_proc_t m_glGetUniformiv_enc;
    131     static void s_glGetUniformiv(void *self, GLuint program, GLint location , GLint *params);
    132 
    133     glGetUniformfv_client_proc_t m_glGetUniformfv_enc;
    134     static void s_glGetUniformfv(void *self, GLuint program, GLint location , GLfloat *params);
    135 
    136     glCreateProgram_client_proc_t m_glCreateProgram_enc;
    137     static GLuint s_glCreateProgram(void *self);
    138 
    139     glCreateShader_client_proc_t m_glCreateShader_enc;
    140     static GLuint s_glCreateShader(void *self, GLenum shaderType);
    141 
    142     glDeleteShader_client_proc_t m_glDeleteShader_enc;
    143     static void s_glDeleteShader(void *self, GLuint shader);
    144 
    145     glAttachShader_client_proc_t m_glAttachShader_enc;
    146     static void s_glAttachShader(void *self, GLuint program, GLuint shader);
    147 
    148     glDetachShader_client_proc_t m_glDetachShader_enc;
    149     static void s_glDetachShader(void *self, GLuint program, GLuint shader);
    150 
    151     glGetUniformLocation_client_proc_t m_glGetUniformLocation_enc;
    152     static int s_glGetUniformLocation(void *self, GLuint program, const GLchar *name);
    153     glUseProgram_client_proc_t m_glUseProgram_enc;
    154 
    155     glUniform1f_client_proc_t m_glUniform1f_enc;
    156     glUniform1fv_client_proc_t m_glUniform1fv_enc;
    157     glUniform1i_client_proc_t m_glUniform1i_enc;
    158     glUniform1iv_client_proc_t m_glUniform1iv_enc;
    159     glUniform2f_client_proc_t m_glUniform2f_enc;
    160     glUniform2fv_client_proc_t m_glUniform2fv_enc;
    161     glUniform2i_client_proc_t m_glUniform2i_enc;
    162     glUniform2iv_client_proc_t m_glUniform2iv_enc;
    163     glUniform3f_client_proc_t m_glUniform3f_enc;
    164     glUniform3fv_client_proc_t m_glUniform3fv_enc;
    165     glUniform3i_client_proc_t m_glUniform3i_enc;
    166     glUniform3iv_client_proc_t m_glUniform3iv_enc;
    167     glUniform4f_client_proc_t m_glUniform4f_enc;
    168     glUniform4fv_client_proc_t m_glUniform4fv_enc;
    169     glUniform4i_client_proc_t m_glUniform4i_enc;
    170     glUniform4iv_client_proc_t m_glUniform4iv_enc;
    171     glUniformMatrix2fv_client_proc_t m_glUniformMatrix2fv_enc;
    172     glUniformMatrix3fv_client_proc_t m_glUniformMatrix3fv_enc;
    173     glUniformMatrix4fv_client_proc_t m_glUniformMatrix4fv_enc;
    174 
    175     static void s_glUseProgram(void *self, GLuint program);
    176 	static void s_glUniform1f(void *self , GLint location, GLfloat x);
    177 	static void s_glUniform1fv(void *self , GLint location, GLsizei count, const GLfloat* v);
    178 	static void s_glUniform1i(void *self , GLint location, GLint x);
    179 	static void s_glUniform1iv(void *self , GLint location, GLsizei count, const GLint* v);
    180 	static void s_glUniform2f(void *self , GLint location, GLfloat x, GLfloat y);
    181 	static void s_glUniform2fv(void *self , GLint location, GLsizei count, const GLfloat* v);
    182 	static void s_glUniform2i(void *self , GLint location, GLint x, GLint y);
    183 	static void s_glUniform2iv(void *self , GLint location, GLsizei count, const GLint* v);
    184 	static void s_glUniform3f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z);
    185 	static void s_glUniform3fv(void *self , GLint location, GLsizei count, const GLfloat* v);
    186 	static void s_glUniform3i(void *self , GLint location, GLint x, GLint y, GLint z);
    187 	static void s_glUniform3iv(void *self , GLint location, GLsizei count, const GLint* v);
    188 	static void s_glUniform4f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
    189 	static void s_glUniform4fv(void *self , GLint location, GLsizei count, const GLfloat* v);
    190 	static void s_glUniform4i(void *self , GLint location, GLint x, GLint y, GLint z, GLint w);
    191 	static void s_glUniform4iv(void *self , GLint location, GLsizei count, const GLint* v);
    192 	static void s_glUniformMatrix2fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
    193 	static void s_glUniformMatrix3fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
    194 	static void s_glUniformMatrix4fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
    195 
    196     glActiveTexture_client_proc_t m_glActiveTexture_enc;
    197     glBindTexture_client_proc_t m_glBindTexture_enc;
    198     glDeleteTextures_client_proc_t m_glDeleteTextures_enc;
    199     glGetTexParameterfv_client_proc_t m_glGetTexParameterfv_enc;
    200     glGetTexParameteriv_client_proc_t m_glGetTexParameteriv_enc;
    201     glTexParameterf_client_proc_t m_glTexParameterf_enc;
    202     glTexParameterfv_client_proc_t m_glTexParameterfv_enc;
    203     glTexParameteri_client_proc_t m_glTexParameteri_enc;
    204     glTexParameteriv_client_proc_t m_glTexParameteriv_enc;
    205 
    206     static void s_glActiveTexture(void* self, GLenum texture);
    207     static void s_glBindTexture(void* self, GLenum target, GLuint texture);
    208     static void s_glDeleteTextures(void* self, GLsizei n, const GLuint* textures);
    209     static void s_glGetTexParameterfv(void* self, GLenum target, GLenum pname, GLfloat* params);
    210     static void s_glGetTexParameteriv(void* self, GLenum target, GLenum pname, GLint* params);
    211     static void s_glTexParameterf(void* self, GLenum target, GLenum pname, GLfloat param);
    212     static void s_glTexParameterfv(void* self, GLenum target, GLenum pname, const GLfloat* params);
    213     static void s_glTexParameteri(void* self, GLenum target, GLenum pname, GLint param);
    214     static void s_glTexParameteriv(void* self, GLenum target, GLenum pname, const GLint* params);
    215 };
    216 #endif
    217