summaryrefslogtreecommitdiff
path: root/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h
diff options
context:
space:
mode:
authorJesse Hall <jessehall@google.com>2011-11-15 16:14:11 -0800
committerJesse Hall <jessehall@google.com>2011-11-21 13:47:49 -0800
commitaf4f66be50b17c8b8fce1dda53389bb0a10968ba (patch)
tree388de6d1583113413f0c094f291b4687f8c64da9 /tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h
parentf37a7ed6c5c609a3afc33f81bf50893362917ae6 (diff)
EmuGL: implement OES_EGL_image_external for GLESv1
GLESv2 support will come in a followup change but will take advantage of the GLClientState changes. Change-Id: Ib6cbb4dafbd071e3b59b1e5d808b3e23656ada92
Diffstat (limited to 'tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h')
-rw-r--r--tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h b/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h
index 6b12f6871..be66d6828 100644
--- a/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h
@@ -70,6 +70,10 @@ public:
int pack_alignment;
} PixelStoreState;
+ enum {
+ MAX_TEXTURE_UNITS = 32,
+ };
+
public:
GLClientState(int nLocations = CODEC_MAX_VERTEX_ATTRIBUTES);
~GLClientState();
@@ -123,6 +127,53 @@ public:
void setCurrentProgram(GLint program) { m_currentProgram = program; }
GLint currentProgram() const { return m_currentProgram; }
+ /* OES_EGL_image_external
+ *
+ * These functions manipulate GL state which interacts with the
+ * OES_EGL_image_external extension, to support client-side emulation on
+ * top of host implementations that don't have it.
+ *
+ * Most of these calls should only be used with TEXTURE_2D or
+ * TEXTURE_EXTERNAL_OES texture targets; TEXTURE_CUBE_MAP or other extension
+ * targets should bypass this. An exception is bindTexture(), which should
+ * see all glBindTexture() calls for any target.
+ */
+
+ // glActiveTexture(GL_TEXTURE0 + i)
+ // Sets the active texture unit. Up to MAX_TEXTURE_UNITS are supported.
+ GLenum setActiveTextureUnit(GLenum texture);
+
+ // glEnable(GL_TEXTURE_(2D|EXTERNAL_OES))
+ void enableTextureTarget(GLenum target);
+
+ // glDisable(GL_TEXTURE_(2D|EXTERNAL_OES))
+ void disableTextureTarget(GLenum target);
+
+ // Implements the target priority logic:
+ // * Return GL_TEXTURE_EXTERNAL_OES if enabled, else
+ // * Return GL_TEXTURE_2D if enabled, else
+ // * Return the allDisabled value.
+ // For some cases passing GL_TEXTURE_2D for allDisabled makes callee code
+ // simpler; for other cases passing a recognizable enum like GL_ZERO or
+ // GL_INVALID_ENUM is appropriate.
+ GLenum getPriorityEnabledTarget(GLenum allDisabled) const;
+
+ // glBindTexture(GL_TEXTURE_*, ...)
+ // Set the target binding of the active texture unit to texture. Returns
+ // GL_NO_ERROR on success or GL_INVALID_OPERATION if the texture has
+ // previously been bound to a different target. If firstUse is not NULL,
+ // it is set to indicate whether this is the first use of the texture.
+ // For accurate error detection, bindTexture should be called for *all*
+ // targets, not just 2D and EXTERNAL_OES.
+ GLenum bindTexture(GLenum target, GLuint texture, GLboolean* firstUse);
+
+ // Return the texture currently bound to GL_TEXTURE_(2D|EXTERNAL_OES).
+ GLuint getBoundTexture(GLenum target) const;
+
+ // glDeleteTextures(...)
+ // Remove references to the to-be-deleted textures.
+ void deleteTextures(GLsizei n, const GLuint* textures);
+
private:
PixelStoreState m_pixelStore;
VertexAttribState *m_states;
@@ -133,6 +184,32 @@ private:
GLint m_currentProgram;
bool validLocation(int location) { return (location >= 0 && location < m_nLocations); }
+
+ enum TextureTarget {
+ TEXTURE_2D = 0,
+ TEXTURE_EXTERNAL = 1,
+ TEXTURE_TARGET_COUNT
+ };
+ struct TextureUnit {
+ unsigned int enables;
+ GLuint texture[TEXTURE_TARGET_COUNT];
+ };
+ struct TextureRec {
+ GLuint id;
+ GLenum target;
+ };
+ struct TextureState {
+ TextureUnit unit[MAX_TEXTURE_UNITS];
+ TextureUnit* activeUnit;
+ TextureRec* textures;
+ GLuint numTextures;
+ GLuint allocTextures;
+ };
+ TextureState m_tex;
+
+ static int compareTexId(const void* pid, const void* prec);
+ TextureRec* addTextureRec(GLuint id, GLenum target);
+
public:
void getClientStatePointer(GLenum pname, GLvoid** params);