summaryrefslogtreecommitdiffstats
path: root/distrib/android-emugl/host/libs/Translator/include/GLcommon
diff options
context:
space:
mode:
Diffstat (limited to 'distrib/android-emugl/host/libs/Translator/include/GLcommon')
-rw-r--r--distrib/android-emugl/host/libs/Translator/include/GLcommon/FramebufferData.h72
-rw-r--r--distrib/android-emugl/host/libs/Translator/include/GLcommon/GLDispatch.h267
-rw-r--r--distrib/android-emugl/host/libs/Translator/include/GLcommon/GLESbuffer.h47
-rw-r--r--distrib/android-emugl/host/libs/Translator/include/GLcommon/GLEScontext.h218
-rw-r--r--distrib/android-emugl/host/libs/Translator/include/GLcommon/GLESmacros.h47
-rw-r--r--distrib/android-emugl/host/libs/Translator/include/GLcommon/GLESpointer.h58
-rw-r--r--distrib/android-emugl/host/libs/Translator/include/GLcommon/GLESvalidate.h44
-rw-r--r--distrib/android-emugl/host/libs/Translator/include/GLcommon/GLconversion_macros.h31
-rw-r--r--distrib/android-emugl/host/libs/Translator/include/GLcommon/GLutils.h52
-rw-r--r--distrib/android-emugl/host/libs/Translator/include/GLcommon/PaletteTexture.h25
-rw-r--r--distrib/android-emugl/host/libs/Translator/include/GLcommon/RangeManip.h69
-rw-r--r--distrib/android-emugl/host/libs/Translator/include/GLcommon/TextureUtils.h31
-rw-r--r--distrib/android-emugl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h102
-rw-r--r--distrib/android-emugl/host/libs/Translator/include/GLcommon/etc1.h108
-rw-r--r--distrib/android-emugl/host/libs/Translator/include/GLcommon/gldefs.h42
-rw-r--r--distrib/android-emugl/host/libs/Translator/include/GLcommon/objectNameManager.h269
16 files changed, 1482 insertions, 0 deletions
diff --git a/distrib/android-emugl/host/libs/Translator/include/GLcommon/FramebufferData.h b/distrib/android-emugl/host/libs/Translator/include/GLcommon/FramebufferData.h
new file mode 100644
index 000000000..46cb651f5
--- /dev/null
+++ b/distrib/android-emugl/host/libs/Translator/include/GLcommon/FramebufferData.h
@@ -0,0 +1,72 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef _FRAMEBUFFER_DATA_H
+#define _FRAMEBUFFER_DATA_H
+
+#include "objectNameManager.h"
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
+class RenderbufferData : public ObjectData
+{
+public:
+ RenderbufferData();
+ ~RenderbufferData();
+
+ unsigned int sourceEGLImage;
+ void (*eglImageDetach)(unsigned int imageId);
+ GLuint attachedFB;
+ GLenum attachedPoint;
+ GLuint eglImageGlobalTexName;
+
+};
+
+const int MAX_ATTACH_POINTS = 3;
+
+class FramebufferData : public ObjectData
+{
+public:
+ explicit FramebufferData(GLuint name);
+ ~FramebufferData();
+
+ void setAttachment(GLenum attachment,
+ GLenum target,
+ GLuint name,
+ ObjectDataPtr obj,
+ bool takeOwnership = false);
+
+ GLuint getAttachment(GLenum attachment,
+ GLenum *outTarget,
+ ObjectDataPtr *outObj);
+
+ void validate(class GLEScontext* ctx);
+
+private:
+ inline int attachmentPointIndex(GLenum attachment);
+ void detachObject(int idx);
+
+private:
+ GLuint m_fbName;
+ struct attachPoint {
+ GLenum target; // OGL if owned, GLES otherwise
+ GLuint name; // OGL if owned, GLES otherwise
+ ObjectDataPtr obj;
+ bool owned;
+ } m_attachPoints[MAX_ATTACH_POINTS+1];
+ bool m_dirty;
+};
+
+#endif
diff --git a/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLDispatch.h b/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLDispatch.h
new file mode 100644
index 000000000..6eda55bf7
--- /dev/null
+++ b/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLDispatch.h
@@ -0,0 +1,267 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef GLDISPATCHH
+#define GLDISPATCHH
+
+#include <GLES/gl.h>
+#include <GLES2/gl2.h>
+#include "emugl/common/mutex.h"
+#include "gldefs.h"
+#include "GLutils.h"
+
+#define GLAPIENTRY GL_APIENTRY
+typedef void(*FUNCPTR)();
+
+class GLDispatch
+{
+public:
+
+ GLDispatch();
+ void dispatchFuncs(GLESVersion version);
+
+ /* OpenGL functions which are needed for implementing BOTH GLES 1.1 & GLES 2.0*/
+ static void (GLAPIENTRY *glActiveTexture) ( GLenum texture );
+ static void (GLAPIENTRY *glBindBuffer) (GLenum target, GLuint buffer);
+ static void (GLAPIENTRY *glBindTexture) (GLenum target, GLuint texture);
+ static void (GLAPIENTRY *glBlendFunc) (GLenum sfactor, GLenum dfactor);
+ static void (GLAPIENTRY *glBlendEquation)( GLenum mode );
+ static void (GLAPIENTRY *glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha);
+ static void (GLAPIENTRY *glBlendFuncSeparate)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+ static void (GLAPIENTRY *glBufferData) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
+ static void (GLAPIENTRY *glBufferSubData) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
+ static void (GLAPIENTRY *glClear) (GLbitfield mask);
+ static void (GLAPIENTRY *glClearColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+ static void (GLAPIENTRY *glClearStencil) (GLint s);
+ static void (GLAPIENTRY *glColorMask) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+ static void (GLAPIENTRY *glCompressedTexImage2D) ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data );
+ static void (GLAPIENTRY *glCompressedTexSubImage2D) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data );
+ static void (GLAPIENTRY *glCopyTexImage2D) (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+ static void (GLAPIENTRY *glCopyTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+ static void (GLAPIENTRY *glCullFace) (GLenum mode);
+ static void (GLAPIENTRY *glDeleteBuffers) (GLsizei n, const GLuint *buffers);
+ static void (GLAPIENTRY *glDeleteTextures) (GLsizei n, const GLuint *textures);
+ static void (GLAPIENTRY *glDepthFunc) (GLenum func);
+ static void (GLAPIENTRY *glDepthMask) (GLboolean flag);
+ static void (GLAPIENTRY *glDepthRange) (GLclampd zNear, GLclampd zFar);
+ static void (GLAPIENTRY *glDisable) (GLenum cap);
+ static void (GLAPIENTRY *glDrawArrays) (GLenum mode, GLint first, GLsizei count);
+ static void (GLAPIENTRY *glDrawElements) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
+ static void (GLAPIENTRY *glEnable) (GLenum cap);
+ static void (GLAPIENTRY *glFinish) (void);
+ static void (GLAPIENTRY *glFlush) (void);
+ static void (GLAPIENTRY *glFrontFace) (GLenum mode);
+ static void (GLAPIENTRY *glGenBuffers) (GLsizei n, GLuint *buffers);
+ static void (GLAPIENTRY *glGenTextures) (GLsizei n, GLuint *textures);
+ static void (GLAPIENTRY *glGetBooleanv) (GLenum pname, GLboolean *params);
+ static void (GLAPIENTRY *glGetBufferParameteriv) (GLenum, GLenum, GLint *);
+ static GLenum (GLAPIENTRY *glGetError) (void);
+ static void (GLAPIENTRY *glGetFloatv) (GLenum pname, GLfloat *params);
+ static void (GLAPIENTRY *glGetIntegerv) (GLenum pname, GLint *params);
+ static const GLubyte * (GLAPIENTRY *glGetString) (GLenum name);
+ static void (GLAPIENTRY *glGetTexParameterfv) (GLenum target, GLenum pname, GLfloat *params);
+ static void (GLAPIENTRY *glGetTexParameteriv) (GLenum target, GLenum pname, GLint *params);
+ static void (GLAPIENTRY *glGetTexLevelParameteriv) (GLenum target, GLint level, GLenum pname, GLint *params);
+ static void (GLAPIENTRY *glHint) (GLenum target, GLenum mode);
+ static GLboolean (GLAPIENTRY *glIsBuffer) (GLuint);
+ static GLboolean (GLAPIENTRY *glIsEnabled) (GLenum cap);
+ static GLboolean (GLAPIENTRY *glIsTexture) (GLuint texture);
+ static void (GLAPIENTRY *glLineWidth) (GLfloat width);
+ static void (GLAPIENTRY *glPolygonOffset) (GLfloat factor, GLfloat units);
+ static void (GLAPIENTRY *glPixelStorei) (GLenum pname, GLint param);
+ static void (GLAPIENTRY *glReadPixels) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
+ static void (GLAPIENTRY *glSampleCoverage) ( GLclampf value, GLboolean invert );
+ static void (GLAPIENTRY *glScissor) (GLint x, GLint y, GLsizei width, GLsizei height);
+ static void (GLAPIENTRY *glStencilFunc) (GLenum func, GLint ref, GLuint mask);
+ static void (GLAPIENTRY *glStencilMask) (GLuint mask);
+ static void (GLAPIENTRY *glStencilOp) (GLenum fail, GLenum zfail, GLenum zpass);
+ static void (GLAPIENTRY *glTexImage2D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+ static void (GLAPIENTRY *glTexParameteri) (GLenum target, GLenum pname, GLint param);
+ static void (GLAPIENTRY *glTexParameteriv) (GLenum target, GLenum pname, const GLint *params);
+ static void (GLAPIENTRY *glTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+ static void (GLAPIENTRY *glViewport) (GLint x, GLint y, GLsizei width, GLsizei height);
+ static void (GLAPIENTRY *glPushAttrib) ( GLbitfield mask );
+ static void (GLAPIENTRY *glPopAttrib) ( void );
+ static void (GLAPIENTRY *glPushClientAttrib) ( GLbitfield mask );
+ static void (GLAPIENTRY *glPopClientAttrib) ( void );
+ static GLboolean (GLAPIENTRY *glIsRenderbufferEXT) (GLuint renderbuffer);
+ static void (GLAPIENTRY *glBindRenderbufferEXT) (GLenum target, GLuint renderbuffer);
+ static void (GLAPIENTRY *glDeleteRenderbuffersEXT) (GLsizei n, const GLuint *renderbuffers);
+ static void (GLAPIENTRY *glGenRenderbuffersEXT) (GLsizei n, GLuint *renderbuffers);
+ static void (GLAPIENTRY *glRenderbufferStorageEXT) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+ static void (GLAPIENTRY *glGetRenderbufferParameterivEXT) (GLenum target, GLenum pname, GLint *params);
+ static GLboolean (GLAPIENTRY *glIsFramebufferEXT) (GLuint framebuffer);
+ static void (GLAPIENTRY *glBindFramebufferEXT) (GLenum target, GLuint framebuffer);
+ static void (GLAPIENTRY *glDeleteFramebuffersEXT) (GLsizei n, const GLuint *framebuffers);
+ static void (GLAPIENTRY *glGenFramebuffersEXT) (GLsizei n, GLuint *framebuffers);
+ static GLenum (GLAPIENTRY *glCheckFramebufferStatusEXT) (GLenum target);
+ static void (GLAPIENTRY *glFramebufferTexture1DEXT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+ static void (GLAPIENTRY *glFramebufferTexture2DEXT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+ static void (GLAPIENTRY *glFramebufferTexture3DEXT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+ static void (GLAPIENTRY *glFramebufferRenderbufferEXT) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+ static void (GLAPIENTRY *glGetFramebufferAttachmentParameterivEXT) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+ static void (GLAPIENTRY *glGenerateMipmapEXT) (GLenum target);
+
+ /* OpenGL functions which are needed ONLY for implementing GLES 1.1*/
+ static void (GLAPIENTRY *glAlphaFunc) (GLenum func, GLclampf ref);
+ static void (GLAPIENTRY *glBegin)( GLenum mode );
+ static void (GLAPIENTRY *glClearDepth) (GLclampd depth);
+ static void (GLAPIENTRY *glClientActiveTexture) ( GLenum texture );
+ static void (GLAPIENTRY *glClipPlane) (GLenum plane, const GLdouble *equation);
+ static void (GLAPIENTRY *glColor4d) (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);
+ static void (GLAPIENTRY *glColor4f) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+ static void (GLAPIENTRY *glColor4fv) ( const GLfloat *v );
+ static void (GLAPIENTRY *glColor4ub) (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
+ static void (GLAPIENTRY *glColor4ubv) ( const GLubyte *v );
+ static void (GLAPIENTRY *glColorPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+ static void (GLAPIENTRY *glDisableClientState) (GLenum array);
+ static void (GLAPIENTRY *glEnableClientState) (GLenum array);
+ static void (GLAPIENTRY *glEnd) (void);
+ static void (GLAPIENTRY *glFogf) (GLenum pname, GLfloat param);
+ static void (GLAPIENTRY *glFogfv) (GLenum pname, const GLfloat *params);
+ static void (GLAPIENTRY *glFrustum) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+ static void (GLAPIENTRY *glGetClipPlane) (GLenum plane, GLdouble *equation);
+ static void (GLAPIENTRY *glGetDoublev) ( GLenum pname, GLdouble *params );
+ static void (GLAPIENTRY *glGetLightfv) (GLenum light, GLenum pname, GLfloat *params);
+ static void (GLAPIENTRY *glGetMaterialfv) (GLenum face, GLenum pname, GLfloat *params);
+ static void (GLAPIENTRY *glGetPointerv) (GLenum pname, GLvoid* *params);
+ static void (GLAPIENTRY *glGetTexEnvfv) (GLenum target, GLenum pname, GLfloat *params);
+ static void (GLAPIENTRY *glGetTexEnviv) (GLenum target, GLenum pname, GLint *params);
+ static void (GLAPIENTRY *glLightf) (GLenum light, GLenum pname, GLfloat param);
+ static void (GLAPIENTRY *glLightfv) (GLenum light, GLenum pname, const GLfloat *params);
+ static void (GLAPIENTRY *glLightModelf) (GLenum pname, GLfloat param);
+ static void (GLAPIENTRY *glLightModelfv) (GLenum pname, const GLfloat *params);
+ static void (GLAPIENTRY *glLoadIdentity) (void);
+ static void (GLAPIENTRY *glLoadMatrixf) (const GLfloat *m);
+ static void (GLAPIENTRY *glLogicOp) (GLenum opcode);
+ static void (GLAPIENTRY *glMaterialf) (GLenum face, GLenum pname, GLfloat param);
+ static void (GLAPIENTRY *glMaterialfv) (GLenum face, GLenum pname, const GLfloat *params);
+ static void (GLAPIENTRY *glMultiTexCoord2fv) ( GLenum target, const GLfloat *v );
+ static void (GLAPIENTRY *glMultiTexCoord2sv) ( GLenum target, const GLshort *v );
+ static void (GLAPIENTRY *glMultiTexCoord3fv) ( GLenum target, const GLfloat *v );
+ static void (GLAPIENTRY *glMultiTexCoord3sv) ( GLenum target, const GLshort *v );
+ static void (GLAPIENTRY *glMultiTexCoord4f) ( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q );
+ static void (GLAPIENTRY *glMultiTexCoord4fv) ( GLenum target, const GLfloat *v );
+ static void (GLAPIENTRY *glMultiTexCoord4sv) ( GLenum target, const GLshort *v );
+ static void (GLAPIENTRY *glMultMatrixf) (const GLfloat *m);
+ static void (GLAPIENTRY *glNormal3f) (GLfloat nx, GLfloat ny, GLfloat nz);
+ static void (GLAPIENTRY *glNormal3fv) ( const GLfloat *v );
+ static void (GLAPIENTRY *glNormal3sv) ( const GLshort *v );
+ static void (GLAPIENTRY *glOrtho) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+ static void (GLAPIENTRY *glPointParameterf) (GLenum, GLfloat);
+ static void (GLAPIENTRY *glPointParameterfv) (GLenum, const GLfloat *);
+ static void (GLAPIENTRY *glPointSize) (GLfloat size);
+ static void (GLAPIENTRY *glRotatef) (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+ static void (GLAPIENTRY *glScalef) (GLfloat x, GLfloat y, GLfloat z);
+ static void (GLAPIENTRY *glTexEnvf) (GLenum target, GLenum pname, GLfloat param);
+ static void (GLAPIENTRY *glTexEnvfv) (GLenum target, GLenum pname, const GLfloat *params);
+ static void (GLAPIENTRY *glTexParameterf) (GLenum target, GLenum pname, GLfloat param);
+ static void (GLAPIENTRY *glTexParameterfv) (GLenum target, GLenum pname, const GLfloat *params);
+ static void (GLAPIENTRY *glMatrixMode) (GLenum mode);
+ static void (GLAPIENTRY *glNormalPointer) (GLenum type, GLsizei stride, const GLvoid *pointer);
+ static void (GLAPIENTRY *glPopMatrix) (void);
+ static void (GLAPIENTRY *glPushMatrix) (void);
+ static void (GLAPIENTRY *glShadeModel) (GLenum mode);
+ static void (GLAPIENTRY *glTexCoordPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+ static void (GLAPIENTRY *glTexEnvi) (GLenum target, GLenum pname, GLint param);
+ static void (GLAPIENTRY *glTexEnviv) (GLenum target, GLenum pname, const GLint *params);
+ static void (GLAPIENTRY *glTranslatef) (GLfloat x, GLfloat y, GLfloat z);
+ static void (GLAPIENTRY *glVertexPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+
+ /* OpenGL functions which are needed ONLY for implementing GLES 1.1 EXTENSIONS*/
+ static void (GLAPIENTRY *glCurrentPaletteMatrixARB) (GLint index);
+ static void (GLAPIENTRY *glMatrixIndexuivARB) (GLint size, GLuint * indices);
+ static void (GLAPIENTRY *glMatrixIndexPointerARB) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+ static void (GLAPIENTRY *glWeightPointerARB) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+ static void (GLAPIENTRY *glTexGenf) (GLenum coord, GLenum pname, GLfloat param );
+ static void (GLAPIENTRY *glTexGeni) (GLenum coord, GLenum pname, GLint param );
+ static void (GLAPIENTRY *glTexGenfv) (GLenum coord, GLenum pname, const GLfloat *params );
+ static void (GLAPIENTRY *glTexGeniv) (GLenum coord, GLenum pname, const GLint *params );
+ static void (GLAPIENTRY *glGetTexGenfv) (GLenum coord, GLenum pname, GLfloat *params );
+ static void (GLAPIENTRY *glGetTexGeniv) (GLenum coord, GLenum pname, GLint *params );
+
+ /* Loading OpenGL functions which are needed ONLY for implementing GLES 2.0*/
+ static void (GL_APIENTRY *glBlendColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+ static void (GL_APIENTRY *glStencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask);
+ static void (GL_APIENTRY *glStencilMaskSeparate)(GLenum face, GLuint mask);
+ static GLboolean (GL_APIENTRY *glIsProgram)(GLuint program);
+ static GLboolean (GL_APIENTRY *glIsShader)(GLuint shader);
+ static void (GL_APIENTRY *glVertexAttrib1f)(GLuint indx, GLfloat x);
+ static void (GL_APIENTRY *glVertexAttrib1fv)(GLuint indx, const GLfloat* values);
+ static void (GL_APIENTRY *glVertexAttrib2f)(GLuint indx, GLfloat x, GLfloat y);
+ static void (GL_APIENTRY *glVertexAttrib2fv)(GLuint indx, const GLfloat* values);
+ static void (GL_APIENTRY *glVertexAttrib3f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
+ static void (GL_APIENTRY *glVertexAttrib3fv)(GLuint indx, const GLfloat* values);
+ static void (GL_APIENTRY *glVertexAttrib4f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+ static void (GL_APIENTRY *glVertexAttrib4fv)(GLuint indx, const GLfloat* values);
+ static void (GL_APIENTRY *glVertexAttribPointer)(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr);
+ static void (GL_APIENTRY *glDisableVertexAttribArray)(GLuint index);
+ static void (GL_APIENTRY *glEnableVertexAttribArray)(GLuint index);
+ static void (GL_APIENTRY *glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat* params);
+ static void (GL_APIENTRY *glGetVertexAttribiv)(GLuint index, GLenum pname, GLint* params);
+ static void (GL_APIENTRY *glGetVertexAttribPointerv)(GLuint index, GLenum pname, GLvoid** pointer);
+ static void (GL_APIENTRY *glUniform1f)(GLint location, GLfloat x);
+ static void (GL_APIENTRY *glUniform1fv)(GLint location, GLsizei count, const GLfloat* v);
+ static void (GL_APIENTRY *glUniform1i)(GLint location, GLint x);
+ static void (GL_APIENTRY *glUniform1iv)(GLint location, GLsizei count, const GLint* v);
+ static void (GL_APIENTRY *glUniform2f)(GLint location, GLfloat x, GLfloat y);
+ static void (GL_APIENTRY *glUniform2fv)(GLint location, GLsizei count, const GLfloat* v);
+ static void (GL_APIENTRY *glUniform2i)(GLint location, GLint x, GLint y);
+ static void (GL_APIENTRY *glUniform2iv)(GLint location, GLsizei count, const GLint* v);
+ static void (GL_APIENTRY *glUniform3f)(GLint location, GLfloat x, GLfloat y, GLfloat z);
+ static void (GL_APIENTRY *glUniform3fv)(GLint location, GLsizei count, const GLfloat* v);
+ static void (GL_APIENTRY *glUniform3i)(GLint location, GLint x, GLint y, GLint z);
+ static void (GL_APIENTRY *glUniform3iv)(GLint location, GLsizei count, const GLint* v);
+ static void (GL_APIENTRY *glUniform4f)(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+ static void (GL_APIENTRY *glUniform4fv)(GLint location, GLsizei count, const GLfloat* v);
+ static void (GL_APIENTRY *glUniform4i)(GLint location, GLint x, GLint y, GLint z, GLint w);
+ static void (GL_APIENTRY *glUniform4iv)(GLint location, GLsizei count, const GLint* v);
+ static void (GL_APIENTRY *glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ static void (GL_APIENTRY *glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ static void (GL_APIENTRY *glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ static void (GL_APIENTRY *glAttachShader)(GLuint program, GLuint shader);
+ static void (GL_APIENTRY *glBindAttribLocation)(GLuint program, GLuint index, const GLchar* name);
+ static void (GL_APIENTRY *glCompileShader)(GLuint shader);
+ static GLuint (GL_APIENTRY *glCreateProgram)(void);
+ static GLuint (GL_APIENTRY *glCreateShader)(GLenum type);
+ static void (GL_APIENTRY *glDeleteProgram)(GLuint program);
+ static void (GL_APIENTRY *glDeleteShader)(GLuint shader);
+ static void (GL_APIENTRY *glDetachShader)(GLuint program, GLuint shader);
+ static void (GL_APIENTRY *glLinkProgram)(GLuint program);
+ static void (GL_APIENTRY *glUseProgram)(GLuint program);
+ static void (GL_APIENTRY *glValidateProgram)(GLuint program);
+ static void (GL_APIENTRY *glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+ static void (GL_APIENTRY *glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+ static void (GL_APIENTRY *glGetAttachedShaders)(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
+ static int (GL_APIENTRY *glGetAttribLocation)(GLuint program, const GLchar* name);
+ static void (GL_APIENTRY *glGetProgramiv)(GLuint program, GLenum pname, GLint* params);
+ static void (GL_APIENTRY *glGetProgramInfoLog)(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+ static void (GL_APIENTRY *glGetShaderiv)(GLuint shader, GLenum pname, GLint* params);
+ static void (GL_APIENTRY *glGetShaderInfoLog)(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+ static void (GL_APIENTRY *glGetShaderPrecisionFormat)(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
+ static void (GL_APIENTRY *glGetShaderSource)(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
+ static void (GL_APIENTRY *glGetUniformfv)(GLuint program, GLint location, GLfloat* params);
+ static void (GL_APIENTRY *glGetUniformiv)(GLuint program, GLint location, GLint* params);
+ static int (GL_APIENTRY *glGetUniformLocation)(GLuint program, const GLchar* name);
+ static void (GL_APIENTRY *glReleaseShaderCompiler)(void);
+ static void (GL_APIENTRY *glShaderBinary)(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
+ static void (GL_APIENTRY *glShaderSource)(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
+
+private:
+ bool m_isLoaded;
+ static emugl::Mutex s_lock;
+};
+
+#endif
diff --git a/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLESbuffer.h b/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLESbuffer.h
new file mode 100644
index 000000000..38429d137
--- /dev/null
+++ b/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLESbuffer.h
@@ -0,0 +1,47 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef GLES_BUFFER_H
+#define GLES_BUFFER_H
+
+#include <stdio.h>
+#include <GLES/gl.h>
+#include <GLcommon/objectNameManager.h>
+#include <GLcommon/RangeManip.h>
+
+class GLESbuffer: public ObjectData {
+public:
+ GLESbuffer():ObjectData(BUFFER_DATA),m_size(0),m_usage(GL_STATIC_DRAW),m_data(NULL),m_wasBound(false){}
+ GLuint getSize(){return m_size;};
+ GLuint getUsage(){return m_usage;};
+ GLvoid* getData(){ return m_data;}
+ bool setBuffer(GLuint size,GLuint usage,const GLvoid* data);
+ bool setSubBuffer(GLint offset,GLuint size,const GLvoid* data);
+ void getConversions(const RangeList& rIn,RangeList& rOut);
+ bool fullyConverted(){return m_conversionManager.size() == 0;};
+ void setBinded(){m_wasBound = true;};
+ bool wasBinded(){return m_wasBound;};
+ ~GLESbuffer();
+
+private:
+ GLuint m_size;
+ GLuint m_usage;
+ unsigned char* m_data;
+ RangeList m_conversionManager;
+ bool m_wasBound;
+};
+
+typedef emugl::SmartPtr<GLESbuffer> GLESbufferPtr;
+#endif
diff --git a/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLEScontext.h b/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLEScontext.h
new file mode 100644
index 000000000..5aed0adb9
--- /dev/null
+++ b/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLEScontext.h
@@ -0,0 +1,218 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef GLES_CONTEXT_H
+#define GLES_CONTEXT_H
+
+#include "GLDispatch.h"
+#include "GLESpointer.h"
+#include "objectNameManager.h"
+#include "emugl/common/mutex.h"
+#include <string>
+
+typedef std::map<GLenum,GLESpointer*> ArraysMap;
+
+enum TextureTarget {
+TEXTURE_2D,
+TEXTURE_CUBE_MAP,
+NUM_TEXTURE_TARGETS
+};
+
+typedef struct _textureTargetState {
+ GLuint texture;
+ GLboolean enabled;
+} textureTargetState;
+
+typedef textureTargetState textureUnitState[NUM_TEXTURE_TARGETS];
+
+class Version{
+public:
+ Version();
+ Version(int major,int minor,int release);
+ Version(const char* versionString);
+ Version(const Version& ver);
+ bool operator<(const Version& ver) const;
+ Version& operator=(const Version& ver);
+private:
+ int m_major;
+ int m_minor;
+ int m_release;
+};
+
+struct GLSupport {
+ GLSupport():maxLights(0),maxVertexAttribs(0),maxClipPlane(0),maxTexUnits(0), \
+ maxTexImageUnits(0),maxTexSize(0) , \
+ GL_EXT_TEXTURE_FORMAT_BGRA8888(false), GL_EXT_FRAMEBUFFER_OBJECT(false), \
+ GL_ARB_VERTEX_BLEND(false), GL_ARB_MATRIX_PALETTE(false), \
+ GL_EXT_PACKED_DEPTH_STENCIL(false) , GL_OES_READ_FORMAT(false), \
+ GL_ARB_HALF_FLOAT_PIXEL(false), GL_NV_HALF_FLOAT(false), \
+ GL_ARB_HALF_FLOAT_VERTEX(false),GL_SGIS_GENERATE_MIPMAP(false),
+ GL_ARB_ES2_COMPATIBILITY(false),GL_OES_STANDARD_DERIVATIVES(false) {} ;
+ int maxLights;
+ int maxVertexAttribs;
+ int maxClipPlane;
+ int maxTexUnits;
+ int maxTexImageUnits;
+ int maxTexSize;
+ Version glslVersion;
+ bool GL_EXT_TEXTURE_FORMAT_BGRA8888;
+ bool GL_EXT_FRAMEBUFFER_OBJECT;
+ bool GL_ARB_VERTEX_BLEND;
+ bool GL_ARB_MATRIX_PALETTE;
+ bool GL_EXT_PACKED_DEPTH_STENCIL;
+ bool GL_OES_READ_FORMAT;
+ bool GL_ARB_HALF_FLOAT_PIXEL;
+ bool GL_NV_HALF_FLOAT;
+ bool GL_ARB_HALF_FLOAT_VERTEX;
+ bool GL_SGIS_GENERATE_MIPMAP;
+ bool GL_ARB_ES2_COMPATIBILITY;
+ bool GL_OES_STANDARD_DERIVATIVES;
+
+};
+
+struct ArrayData{
+ ArrayData():data(NULL),
+ type(0),
+ stride(0),
+ allocated(false){};
+
+ void* data;
+ GLenum type;
+ unsigned int stride;
+ bool allocated;
+};
+
+class GLESConversionArrays
+{
+public:
+ GLESConversionArrays():m_current(0){};
+ void setArr(void* data,unsigned int stride,GLenum type);
+ void allocArr(unsigned int size,GLenum type);
+ ArrayData& operator[](int i);
+ void* getCurrentData();
+ ArrayData& getCurrentArray();
+ unsigned int getCurrentIndex();
+ void operator++();
+
+ ~GLESConversionArrays();
+private:
+ std::map<GLenum,ArrayData> m_arrays;
+ unsigned int m_current;
+};
+
+class GLEScontext{
+public:
+ virtual void init();
+ GLEScontext();
+ GLenum getGLerror();
+ void setGLerror(GLenum err);
+ void setShareGroup(ShareGroupPtr grp){m_shareGroup = grp;};
+ ShareGroupPtr shareGroup() const { return m_shareGroup; }
+ virtual void setActiveTexture(GLenum tex);
+ unsigned int getBindedTexture(GLenum target);
+ unsigned int getBindedTexture(GLenum unit,GLenum target);
+ void setBindedTexture(GLenum target,unsigned int tex);
+ bool isTextureUnitEnabled(GLenum unit);
+ void setTextureEnabled(GLenum target, GLenum enable);
+ ObjectLocalName getDefaultTextureName(GLenum target);
+ bool isInitialized() { return m_initialized; };
+ void setUnpackAlignment(GLint param){ m_unpackAlignment = param; };
+ GLint getUnpackAlignment(){ return m_unpackAlignment; };
+
+ bool isArrEnabled(GLenum);
+ void enableArr(GLenum arr,bool enable);
+ const GLvoid* setPointer(GLenum arrType,GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize = false);
+ virtual const GLESpointer* getPointer(GLenum arrType);
+ virtual void setupArraysPointers(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct) = 0;
+ void bindBuffer(GLenum target,GLuint buffer);
+ void unbindBuffer(GLuint buffer);
+ bool isBuffer(GLuint buffer);
+ bool isBindedBuffer(GLenum target);
+ GLvoid* getBindedBuffer(GLenum target);
+ void getBufferSize(GLenum target,GLint* param);
+ void getBufferUsage(GLenum target,GLint* param);
+ bool setBufferData(GLenum target,GLsizeiptr size,const GLvoid* data,GLenum usage);
+ bool setBufferSubData(GLenum target,GLintptr offset,GLsizeiptr size,const GLvoid* data);
+ const char * getExtensionString();
+ const char * getVendorString() const;
+ const char * getRendererString() const;
+ const char * getVersionString() const;
+ void getGlobalLock();
+ void releaseGlobalLock();
+ virtual GLSupport* getCaps(){return &s_glSupport;};
+ virtual ~GLEScontext();
+ virtual int getMaxTexUnits() = 0;
+ virtual void drawValidate(void);
+
+ void setRenderbufferBinding(GLuint rb) { m_renderbuffer = rb; }
+ GLuint getRenderbufferBinding() const { return m_renderbuffer; }
+ void setFramebufferBinding(GLuint fb) { m_framebuffer = fb; }
+ GLuint getFramebufferBinding() const { return m_framebuffer; }
+
+ static GLDispatch& dispatcher(){return s_glDispatch;};
+
+ static int getMaxLights(){return s_glSupport.maxLights;}
+ static int getMaxClipPlanes(){return s_glSupport.maxClipPlane;}
+ static int getMaxTexSize(){return s_glSupport.maxTexSize;}
+ static Version glslVersion(){return s_glSupport.glslVersion;}
+ static bool isAutoMipmapSupported(){return s_glSupport.GL_SGIS_GENERATE_MIPMAP;}
+ static TextureTarget GLTextureTargetToLocal(GLenum target);
+ static int findMaxIndex(GLsizei count,GLenum type,const GLvoid* indices);
+
+ virtual bool glGetIntegerv(GLenum pname, GLint *params);
+ virtual bool glGetBooleanv(GLenum pname, GLboolean *params);
+ virtual bool glGetFloatv(GLenum pname, GLfloat *params);
+ virtual bool glGetFixedv(GLenum pname, GLfixed *params);
+
+protected:
+ static void buildStrings(const char* baseVendor, const char* baseRenderer, const char* baseVersion, const char* version);
+ virtual bool needConvert(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct,GLESpointer* p,GLenum array_id) = 0;
+ void convertDirect(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum array_id,GLESpointer* p);
+ void convertDirectVBO(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum array_id,GLESpointer* p);
+ void convertIndirect(GLESConversionArrays& fArrs,GLsizei count,GLenum type,const GLvoid* indices,GLenum array_id,GLESpointer* p);
+ void convertIndirectVBO(GLESConversionArrays& fArrs,GLsizei count,GLenum indices_type,const GLvoid* indices,GLenum array_id,GLESpointer* p);
+ void initCapsLocked(const GLubyte * extensionString);
+ virtual void initExtensionString() =0;
+
+ static emugl::Mutex s_lock;
+ static GLDispatch s_glDispatch;
+ bool m_initialized;
+ unsigned int m_activeTexture;
+ GLint m_unpackAlignment;
+ ArraysMap m_map;
+ static std::string* s_glExtensions;
+ static GLSupport s_glSupport;
+
+private:
+
+ virtual void setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride, GLboolean normalized, int pointsIndex = -1) = 0 ;
+ GLuint getBuffer(GLenum target);
+
+ ShareGroupPtr m_shareGroup;
+ GLenum m_glError;
+ textureUnitState* m_texState;
+ unsigned int m_arrayBuffer;
+ unsigned int m_elementBuffer;
+ GLuint m_renderbuffer;
+ GLuint m_framebuffer;
+
+ static std::string s_glVendor;
+ static std::string s_glRenderer;
+ static std::string s_glVersion;
+};
+
+#endif
+
diff --git a/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLESmacros.h b/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLESmacros.h
new file mode 100644
index 000000000..95ffadb8d
--- /dev/null
+++ b/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLESmacros.h
@@ -0,0 +1,47 @@
+#ifndef GLES_MACROS_H
+#define GLES_MACROS_H
+
+#define GET_CTX() \
+ if(!s_eglIface) return; \
+ GLEScontext *ctx = s_eglIface->getGLESContext(); \
+
+#define GET_CTX_CM() \
+ if(!s_eglIface) return; \
+ GLEScmContext *ctx = static_cast<GLEScmContext *>(s_eglIface->getGLESContext()); \
+ if(!ctx) return;
+
+#define GET_CTX_V2() \
+ if(!s_eglIface) return; \
+ GLESv2Context *ctx = static_cast<GLESv2Context *>(s_eglIface->getGLESContext()); \
+ if(!ctx) return;
+
+#define GET_CTX_RET(failure_ret) \
+ if(!s_eglIface) return failure_ret; \
+ GLEScontext *ctx = s_eglIface->getGLESContext(); \
+ if(!ctx) return failure_ret;
+
+#define GET_CTX_CM_RET(failure_ret) \
+ if(!s_eglIface) return failure_ret; \
+ GLEScmContext *ctx = static_cast<GLEScmContext *>(s_eglIface->getGLESContext()); \
+ if(!ctx) return failure_ret;
+
+#define GET_CTX_V2_RET(failure_ret) \
+ if(!s_eglIface) return failure_ret; \
+ GLESv2Context *ctx = static_cast<GLESv2Context *>(s_eglIface->getGLESContext()); \
+ if(!ctx) return failure_ret;
+
+
+#define SET_ERROR_IF(condition,err) if((condition)) { \
+ fprintf(stderr, "%s:%s:%d error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
+ ctx->setGLerror(err); \
+ return; \
+ }
+
+
+#define RET_AND_SET_ERROR_IF(condition,err,ret) if((condition)) { \
+ fprintf(stderr, "%s:%s:%d error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
+ ctx->setGLerror(err); \
+ return ret; \
+ }
+
+#endif
diff --git a/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLESpointer.h b/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLESpointer.h
new file mode 100644
index 000000000..851fe451a
--- /dev/null
+++ b/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLESpointer.h
@@ -0,0 +1,58 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef GLES_POINTER_H
+#define GLES_POINTER_H
+
+#include <GLES/gl.h>
+#include "GLESbuffer.h"
+
+class GLESpointer
+{
+
+public:
+ GLESpointer();
+ GLenum getType() const;
+ GLint getSize() const;
+ GLsizei getStride() const;
+ const GLvoid* getArrayData() const;
+ GLvoid* getBufferData() const;
+ GLuint getBufferName() const;
+ GLboolean getNormalized() const { return m_normalize ? GL_TRUE : GL_FALSE; }
+ const GLvoid* getData() const;
+ unsigned int getBufferOffset() const;
+ void redirectPointerData();
+ void getBufferConversions(const RangeList& rl,RangeList& rlOut);
+ bool bufferNeedConversion(){ return !m_buffer->fullyConverted();}
+ void setArray (GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize = false);
+ void setBuffer(GLint size,GLenum type,GLsizei stride,GLESbuffer* buf,GLuint bufferName,int offset,bool normalize = false);
+ bool isEnable() const;
+ bool isNormalize() const;
+ bool isVBO() const;
+ void enable(bool b);
+
+private:
+ GLint m_size;
+ GLenum m_type;
+ GLsizei m_stride;
+ bool m_enabled;
+ bool m_normalize;
+ const GLvoid* m_data;
+ GLESbuffer* m_buffer;
+ GLuint m_bufferName;
+ unsigned int m_buffOffset;
+ bool m_isVBO;
+};
+#endif
diff --git a/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLESvalidate.h b/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLESvalidate.h
new file mode 100644
index 000000000..92c1f3311
--- /dev/null
+++ b/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLESvalidate.h
@@ -0,0 +1,44 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef GLES_VALIDATE_H
+#define GLES_VALIDATE_H
+
+#include <GLES/gl.h>
+#include "GLEScontext.h"
+struct GLESvalidate
+{
+static bool textureEnum(GLenum e,unsigned int maxTex);
+static bool pixelType(GLEScontext * ctx,GLenum type);
+static bool pixelOp(GLenum format,GLenum type);
+static bool pixelFrmt(GLEScontext* ctx , GLenum format);
+static bool bufferTarget(GLenum target);
+static bool bufferUsage(GLenum usage);
+static bool bufferParam(GLenum param);
+static bool drawMode(GLenum mode);
+static bool drawType(GLenum mode);
+static bool textureTarget(GLenum target);
+static bool textureTargetLimited(GLenum target);
+static bool textureTargetEx(GLenum target);
+static bool texImgDim(GLsizei width,GLsizei height,int maxTexSize);
+static bool blendEquationMode(GLenum mode);
+static bool framebufferTarget(GLenum target);
+static bool framebufferAttachment(GLenum attachment);
+static bool framebufferAttachmentParams(GLenum pname);
+static bool renderbufferTarget(GLenum target);
+static bool renderbufferParams(GLenum pname);
+};
+
+#endif
diff --git a/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLconversion_macros.h b/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLconversion_macros.h
new file mode 100644
index 000000000..83e99b46c
--- /dev/null
+++ b/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLconversion_macros.h
@@ -0,0 +1,31 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef _GL_FIXED_OPS_H
+#define _GL_FIXED_OPS_H
+
+#define X2F(x) (((float)(x))/65536.0f)
+#define X2D(x) (((double)(x))/65536.0)
+#define X2I(x) ((x) /65536)
+#define B2S(x) ((short)x)
+
+
+#define F2X(d) ((d) > 32767.65535 ? 32767 * 65536 + 65535 : \
+ (d) < -32768.65535 ? -32768 * 65536 + 65535 : \
+ ((GLfixed) ((d) * 65536)))
+
+#define I2X(d) ((d)*65536)
+
+#endif
diff --git a/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLutils.h b/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLutils.h
new file mode 100644
index 000000000..974b9be52
--- /dev/null
+++ b/distrib/android-emugl/host/libs/Translator/include/GLcommon/GLutils.h
@@ -0,0 +1,52 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef GL_UTILS_H
+#define GL_UTILS_H
+
+#include <assert.h>
+#include <inttypes.h>
+
+typedef enum {
+ GLES_1_1 = 1,
+ GLES_2_0 = 2,
+ MAX_GLES_VERSION //Must be last
+} GLESVersion;
+
+template <class T>
+void swap(T& x,T& y) {
+ T temp;
+ temp = x;
+ x = y;
+ y = temp;
+}
+
+bool isPowerOf2(int num);
+
+// <EGL/egl.h> defines many types as 'void*' while they're really
+// implemented as unsigned integers. These convenience template functions
+// help casting between them safely without generating compiler warnings.
+inline void* SafePointerFromUInt(unsigned int handle) {
+ return (void*)(uintptr_t)(handle);
+}
+
+inline unsigned int SafeUIntFromPointer(const void* ptr) {
+ // Assertion error if the pointer contains a value that does not fit
+ // in an unsigned integer!
+ assert((uintptr_t)(ptr) == (unsigned int)(uintptr_t)(ptr));
+ return (unsigned int)(uintptr_t)(ptr);
+}
+
+#endif
diff --git a/distrib/android-emugl/host/libs/Translator/include/GLcommon/PaletteTexture.h b/distrib/android-emugl/host/libs/Translator/include/GLcommon/PaletteTexture.h
new file mode 100644
index 000000000..90b206d0c
--- /dev/null
+++ b/distrib/android-emugl/host/libs/Translator/include/GLcommon/PaletteTexture.h
@@ -0,0 +1,25 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef __PALETTE_TEXTURE_H__
+#define __PALETTE_TEXTURE_H__
+
+#include <GLES/gl.h>
+
+#define MAX_SUPPORTED_PALETTE 10
+
+unsigned char* uncompressTexture(GLenum internalformat,GLenum& formatOut,GLsizei width,GLsizei height,GLsizei imageSize, const GLvoid* data,GLint level);
+
+#endif
diff --git a/distrib/android-emugl/host/libs/Translator/include/GLcommon/RangeManip.h b/distrib/android-emugl/host/libs/Translator/include/GLcommon/RangeManip.h
new file mode 100644
index 000000000..e3162b8d6
--- /dev/null
+++ b/distrib/android-emugl/host/libs/Translator/include/GLcommon/RangeManip.h
@@ -0,0 +1,69 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef RANGE_H
+#define RANGE_H
+
+#include <vector>
+
+class Range {
+
+public:
+ Range():m_start(0),m_end(0),m_size(0){};
+ Range(int start,int size):m_start(start),m_end(start+size),m_size(size){};
+ Range(const Range& r):m_start(r.m_start),m_end(r.m_end),m_size(r.m_size){};
+ void setRange(int start,int size){m_start = start; m_end = start+size; m_size = size;};
+ inline int getStart() const{return m_start;};
+ inline int getEnd() const{return m_end;};
+ inline int getSize() const{return m_size;};
+ Range& operator=(const Range& r) {
+ m_start = r.m_start;
+ m_end = r.m_end;
+ m_size = r.m_size;
+ return *this;
+ }
+ bool operator ==(const Range& r) const {
+ return m_start == r.m_start && m_size == r.m_size && m_end == r.m_end;
+ }
+ bool operator !=(const Range& r) const {return !((*this) == r);};
+ bool rangeIntersection(const Range& r,Range& rOut) const ;
+ bool rangeUnion(const Range& r,Range& rOut) const ;
+
+private:
+ int m_start;
+ int m_end;
+ int m_size;
+};
+
+class RangeList {
+public:
+ void addRange(const Range& r);
+ void addRanges(const RangeList& rl);
+ void delRange(const Range& r,RangeList& deleted);
+ void delRanges(const RangeList& rl,RangeList& deleted);
+ bool empty() const;
+ void merge();
+ int size() const;
+ void clear();
+ Range& operator[](unsigned int i){return list[i];};
+private:
+ void erase(unsigned int i);
+ std::vector<Range> list;
+};
+
+
+
+
+#endif
diff --git a/distrib/android-emugl/host/libs/Translator/include/GLcommon/TextureUtils.h b/distrib/android-emugl/host/libs/Translator/include/GLcommon/TextureUtils.h
new file mode 100644
index 000000000..9b0c4eacf
--- /dev/null
+++ b/distrib/android-emugl/host/libs/Translator/include/GLcommon/TextureUtils.h
@@ -0,0 +1,31 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef _TEXTURE_UTILS_H
+#define _TEXTURE_UTILS_H
+
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+#include "GLEScontext.h"
+#include "PaletteTexture.h"
+#include "etc1.h"
+
+int getCompressedFormats(int* formats);
+void doCompressedTexImage2D(GLEScontext * ctx, GLenum target, GLint level,
+ GLenum internalformat, GLsizei width,
+ GLsizei height, GLint border,
+ GLsizei imageSize, const GLvoid* data, void * funcPtr);
+
+#endif
diff --git a/distrib/android-emugl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h b/distrib/android-emugl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h
new file mode 100644
index 000000000..e0d1bfb89
--- /dev/null
+++ b/distrib/android-emugl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h
@@ -0,0 +1,102 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef TRANSLATOR_IFACES_H
+#define TRANSLATOR_IFACES_H
+#include <GLES/gl.h>
+#include <string.h>
+#include "objectNameManager.h"
+
+extern "C" {
+
+/* This is a generic function pointer type, whose name indicates it must
+ * be cast to the proper type *and calling convention* before use.
+ */
+typedef void (*__translatorMustCastToProperFunctionPointerType)(void);
+
+typedef struct {
+ const char* name;
+ __translatorMustCastToProperFunctionPointerType address;
+}ExtentionDescriptor;
+
+class TextureData : public ObjectData
+{
+public:
+ ~TextureData() {
+ if (sourceEGLImage && eglImageDetach) (*eglImageDetach)(sourceEGLImage);
+ }
+ TextureData(): ObjectData(TEXTURE_DATA),
+ width(0),
+ height(0),
+ border(0),
+ internalFormat(GL_RGBA),
+ sourceEGLImage(0),
+ wasBound(false),
+ requiresAutoMipmap(false),
+ target(0),
+ oldGlobal(0) {
+ memset(crop_rect,0,4*sizeof(int));
+ };
+
+ unsigned int width;
+ unsigned int height;
+ unsigned int border;
+ unsigned int internalFormat;
+ unsigned int sourceEGLImage;
+ bool wasBound;
+ bool requiresAutoMipmap;
+ int crop_rect[4];
+ void (*eglImageDetach)(unsigned int imageId);
+ GLenum target;
+ GLuint oldGlobal;
+};
+
+struct EglImage
+{
+ ~EglImage(){};
+ unsigned int imageId;
+ unsigned int globalTexName;
+ unsigned int width;
+ unsigned int height;
+ unsigned int internalFormat;
+ unsigned int border;
+};
+
+typedef emugl::SmartPtr<EglImage> ImagePtr;
+typedef std::map< unsigned int, ImagePtr> ImagesHndlMap;
+
+class GLEScontext;
+
+typedef struct {
+ GLEScontext* (*createGLESContext)();
+ void (*initContext)(GLEScontext*,ShareGroupPtr);
+ void (*deleteGLESContext)(GLEScontext*);
+ void (*flush)();
+ void (*finish)();
+ void (*setShareGroup)(GLEScontext*,ShareGroupPtr);
+ __translatorMustCastToProperFunctionPointerType (*getProcAddress)(const char*);
+}GLESiface;
+
+
+typedef struct {
+ GLEScontext* (*getGLESContext)();
+ EglImage* (*eglAttachEGLImage)(unsigned int imageId);
+ void (*eglDetachEGLImage)(unsigned int imageId);
+}EGLiface;
+
+typedef GLESiface* (*__translator_getGLESIfaceFunc)(EGLiface*);
+
+}
+#endif
diff --git a/distrib/android-emugl/host/libs/Translator/include/GLcommon/etc1.h b/distrib/android-emugl/host/libs/Translator/include/GLcommon/etc1.h
new file mode 100644
index 000000000..15ee9ac40
--- /dev/null
+++ b/distrib/android-emugl/host/libs/Translator/include/GLcommon/etc1.h
@@ -0,0 +1,108 @@
+// Copyright 2009 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __etc1_h__
+#define __etc1_h__
+
+#define MAX_ETC_SUPPORTED 1
+
+#define ETC1_ENCODED_BLOCK_SIZE 8
+#define ETC1_DECODED_BLOCK_SIZE 48
+
+#ifndef ETC1_RGB8_OES
+#define ETC1_RGB8_OES 0x8D64
+#endif
+
+typedef unsigned char etc1_byte;
+typedef int etc1_bool;
+typedef unsigned int etc1_uint32;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Encode a block of pixels.
+//
+// pIn is a pointer to a ETC_DECODED_BLOCK_SIZE array of bytes that represent a
+// 4 x 4 square of 3-byte pixels in form R, G, B. Byte (3 * (x + 4 * y) is the R
+// value of pixel (x, y).
+//
+// validPixelMask is a 16-bit mask where bit (1 << (x + y * 4)) indicates whether
+// the corresponding (x,y) pixel is valid. Invalid pixel color values are ignored when compressing.
+//
+// pOut is an ETC1 compressed version of the data.
+
+void etc1_encode_block(const etc1_byte* pIn, etc1_uint32 validPixelMask, etc1_byte* pOut);
+
+// Decode a block of pixels.
+//
+// pIn is an ETC1 compressed version of the data.
+//
+// pOut is a pointer to a ETC_DECODED_BLOCK_SIZE array of bytes that represent a
+// 4 x 4 square of 3-byte pixels in form R, G, B. Byte (3 * (x + 4 * y) is the R
+// value of pixel (x, y).
+
+void etc1_decode_block(const etc1_byte* pIn, etc1_byte* pOut);
+
+// Return the size of the encoded image data (does not include size of PKM header).
+
+etc1_uint32 etc1_get_encoded_data_size(etc1_uint32 width, etc1_uint32 height);
+
+// Encode an entire image.
+// pIn - pointer to the image data. Formatted such that
+// pixel (x,y) is at pIn + pixelSize * x + stride * y;
+// pOut - pointer to encoded data. Must be large enough to store entire encoded image.
+// pixelSize can be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image.
+// returns non-zero if there is an error.
+
+int etc1_encode_image(const etc1_byte* pIn, etc1_uint32 width, etc1_uint32 height,
+ etc1_uint32 pixelSize, etc1_uint32 stride, etc1_byte* pOut);
+
+// Decode an entire image.
+// pIn - pointer to encoded data.
+// pOut - pointer to the image data. Will be written such that
+// pixel (x,y) is at pIn + pixelSize * x + stride * y. Must be
+// large enough to store entire image.
+// pixelSize can be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image.
+// returns non-zero if there is an error.
+
+int etc1_decode_image(const etc1_byte* pIn, etc1_byte* pOut,
+ etc1_uint32 width, etc1_uint32 height,
+ etc1_uint32 pixelSize, etc1_uint32 stride);
+
+// Size of a PKM header, in bytes.
+
+#define ETC_PKM_HEADER_SIZE 16
+
+// Format a PKM header
+
+void etc1_pkm_format_header(etc1_byte* pHeader, etc1_uint32 width, etc1_uint32 height);
+
+// Check if a PKM header is correctly formatted.
+
+etc1_bool etc1_pkm_is_valid(const etc1_byte* pHeader);
+
+// Read the image width from a PKM header
+
+etc1_uint32 etc1_pkm_get_width(const etc1_byte* pHeader);
+
+// Read the image height from a PKM header
+
+etc1_uint32 etc1_pkm_get_height(const etc1_byte* pHeader);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/distrib/android-emugl/host/libs/Translator/include/GLcommon/gldefs.h b/distrib/android-emugl/host/libs/Translator/include/GLcommon/gldefs.h
new file mode 100644
index 000000000..1f0c7efde
--- /dev/null
+++ b/distrib/android-emugl/host/libs/Translator/include/GLcommon/gldefs.h
@@ -0,0 +1,42 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+typedef double GLclampd; /* double precision float in [0,1] */
+typedef double GLdouble; /* double precision float */
+
+#define GL_S 0x2000
+#define GL_T 0x2001
+#define GL_R 0x2002
+#define GL_Q 0x2003
+#define GL_TEXTURE_GEN_S 0x0C60
+#define GL_TEXTURE_GEN_T 0x0C61
+#define GL_TEXTURE_GEN_R 0x0C62
+#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002
+#define GL_TRANSFORM_BIT 0x00001000
+#define GL_INT 0x1404
+#define GL_HALF_FLOAT_NV 0x140B
+#define GL_HALF_FLOAT 0x140B
+#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
+#define GL_POINT_SPRITE 0x8861
+#define GL_FRAMEBUFFER_EXT 0x8D40
+#define GL_TEXTURE_WIDTH 0x1000
+#define GL_TEXTURE_HEIGHT 0x1001
+#define GL_TEXTURE_RED_SIZE 0x805C
+#define GL_TEXTURE_GREEN_SIZE 0x805D
+#define GL_TEXTURE_BLUE_SIZE 0x805E
+#define GL_TEXTURE_ALPHA_SIZE 0x805F
+#define GL_TEXTURE_DEPTH_SIZE 0x884A
+#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
diff --git a/distrib/android-emugl/host/libs/Translator/include/GLcommon/objectNameManager.h b/distrib/android-emugl/host/libs/Translator/include/GLcommon/objectNameManager.h
new file mode 100644
index 000000000..4d4d038d7
--- /dev/null
+++ b/distrib/android-emugl/host/libs/Translator/include/GLcommon/objectNameManager.h
@@ -0,0 +1,269 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef _OBJECT_NAME_MANAGER_H
+#define _OBJECT_NAME_MANAGER_H
+
+#include <map>
+#include "emugl/common/mutex.h"
+#include "emugl/common/smart_ptr.h"
+
+enum NamedObjectType {
+ VERTEXBUFFER = 0,
+ TEXTURE = 1,
+ RENDERBUFFER = 2,
+ FRAMEBUFFER = 3,
+ SHADER = 4,
+ NUM_OBJECT_TYPES = 5 // Must be last
+};
+
+enum ObjectDataType {
+ SHADER_DATA,
+ PROGRAM_DATA,
+ TEXTURE_DATA,
+ BUFFER_DATA,
+ UNDEFINED_DATA
+};
+
+class ObjectData
+{
+public:
+ ObjectData() : m_dataType(UNDEFINED_DATA) {};
+ ObjectData(ObjectDataType type): m_dataType(type) {};
+ ObjectDataType getDataType() { return m_dataType; };
+ virtual ~ObjectData() {};
+private:
+ ObjectDataType m_dataType;
+};
+typedef emugl::SmartPtr<ObjectData> ObjectDataPtr;
+typedef unsigned long long ObjectLocalName;
+typedef std::map<ObjectLocalName, unsigned int> NamesMap;
+
+//
+// Class NameSpace - this class manages allocations and deletions of objects
+// from a single "local" namespace (private to context group).
+// For each allocated object name, a "global" name is
+// generated as well to be used in the space where all
+// contexts are shared.
+//
+// NOTE: this class does not used by the EGL/GLES layer directly,
+// the EGL/GLES layer creates objects using the ShareGroup class
+// interface (see below).
+class GlobalNameSpace;
+class NameSpace
+{
+ friend class ShareGroup;
+ friend class GlobalNameSpace;
+
+private:
+ NameSpace(NamedObjectType p_type, GlobalNameSpace *globalNameSpace);
+ ~NameSpace();
+
+ //
+ // genName - creates new object in the namespace and returns its name.
+ // if genLocal is false then the specified p_localName will be used.
+ // This function also generate a global name for the object,
+ // the value of the global name can be retrieved using the
+ // getGlobalName function.
+ //
+ ObjectLocalName genName(ObjectLocalName p_localName, bool genGlobal, bool genLocal);
+
+ // genGlobalName() - This function creates a global name
+ // with no associated local name, for the
+ // translator internal use.
+ unsigned int genGlobalName(void);
+
+ //
+ // getGlobalName - returns the global name of an object or 0 if the object
+ // does not exist.
+ //
+ unsigned int getGlobalName(ObjectLocalName p_localName);
+
+ //
+ // getLocaalName - returns the local name of an object or 0 if the object
+ // does not exist.
+ //
+ ObjectLocalName getLocalName(unsigned int p_globalName);
+
+ //
+ // deleteName - deletes and object from the namespace as well as its
+ // global name from the global name space.
+ //
+ void deleteName(ObjectLocalName p_localName);
+
+ //
+ // isObject - returns true if the named object exist.
+ //
+ bool isObject(ObjectLocalName p_localName);
+
+ //
+ // replaces an object to map to an existing global object
+ //
+ void replaceGlobalName(ObjectLocalName p_localName, unsigned int p_globalName);
+
+private:
+ ObjectLocalName m_nextName;
+ NamesMap m_localToGlobalMap;
+ const NamedObjectType m_type;
+ GlobalNameSpace *m_globalNameSpace;
+};
+
+class GlobalNameSpace
+{
+public:
+ GlobalNameSpace();
+ ~GlobalNameSpace();
+ unsigned int genName(NamedObjectType p_type);
+ void deleteName(NamedObjectType p_type, unsigned int p_name);
+
+private:
+ emugl::Mutex m_lock;
+};
+
+//
+// class ShareGroup -
+// That class manages objects of one "local" context share group, typically
+// there will be one inctance of ShareGroup for each user OpenGL context
+// unless the user context share with another user context. In that case they
+// both will share the same ShareGroup instance.
+// calls into that class gets serialized through a lock so it is thread safe.
+//
+class ShareGroup
+{
+ friend class ObjectNameManager;
+ friend class emugl::SmartPtr<ShareGroup>; // to allow destructing when ShareGroupPtr refcount reaches zero
+
+public:
+
+ //
+ // genName - generates new object name and returns its name value.
+ // if genLocal is false, p_localName will be used as the name.
+ // This function also generates a "global" name for the object
+ // which can be queried using the getGlobalName function.
+ //
+ ObjectLocalName genName(NamedObjectType p_type, ObjectLocalName p_localName = 0, bool genLocal= false);
+
+ // genGlobalName() - This function creates a global name
+ // with no associated local name, for the
+ // translator internal use.
+ unsigned int genGlobalName(NamedObjectType p_type);
+
+ //
+ // getGlobalName - retrieves the "global" name of an object or 0 if the
+ // object does not exist.
+ //
+ unsigned int getGlobalName(NamedObjectType p_type, ObjectLocalName p_localName);
+
+ //
+ // getLocalName - retrieves the "local" name of an object or 0 if the
+ // object does not exist.
+ //
+ ObjectLocalName getLocalName(NamedObjectType p_type, unsigned int p_globalName);
+
+ //
+ // deleteName - deletes and object from the namespace as well as its
+ // global name from the global name space.
+ //
+ void deleteName(NamedObjectType p_type, ObjectLocalName p_localName);
+
+ //
+ // replaceGlobalName - replaces an object to map to an existing global
+ // named object. (used when creating EGLImage siblings)
+ //
+ void replaceGlobalName(NamedObjectType p_type, ObjectLocalName p_localName, unsigned int p_globalName);
+
+ //
+ // isObject - returns true if the named object exist.
+ //
+ bool isObject(NamedObjectType p_type, ObjectLocalName p_localName);
+
+ //
+ // Assign object global data to a names object
+ //
+ void setObjectData(NamedObjectType p_type, ObjectLocalName p_localName, ObjectDataPtr data);
+
+ //
+ // Retrieve object global data
+ //
+ ObjectDataPtr getObjectData(NamedObjectType p_type, ObjectLocalName p_localName);
+
+private:
+ explicit ShareGroup(GlobalNameSpace *globalNameSpace);
+ ~ShareGroup();
+
+private:
+ emugl::Mutex m_lock;
+ NameSpace *m_nameSpace[NUM_OBJECT_TYPES];
+ void *m_objectsData;
+};
+
+typedef emugl::SmartPtr<ShareGroup> ShareGroupPtr;
+typedef std::multimap<void *, ShareGroupPtr> ShareGroupsMap;
+
+//
+// ObjectNameManager -
+// This class manages the set of all ShareGroups instances,
+// each ShareGroup instance can be accessed through one or more 'groupName'
+// values. the type of 'groupName' is void *, the intent is that the EGL
+// layer will use the user context handle as the name for its ShareGroup
+// object. Multiple names can be attached to a ShareGroup object to support
+// user context sharing.
+//
+class ObjectNameManager
+{
+public:
+ explicit ObjectNameManager(GlobalNameSpace *globalNameSpace);
+ ~ObjectNameManager();
+
+ //
+ // createShareGroup - create a new ShareGroup object and attach it with
+ // the "name" specified by p_groupName.
+ //
+ ShareGroupPtr createShareGroup(void *p_groupName);
+
+ //
+ // attachShareGroup - find the ShareGroup object attached to the name
+ // specified in p_existingGroupName and attach p_groupName to the same
+ // ShareGroup instance.
+ //
+ ShareGroupPtr attachShareGroup(void *p_groupName, void *p_existingGroupName);
+
+ //
+ // getShareGroup - retreive a ShareGroup object based on its "name"
+ //
+ ShareGroupPtr getShareGroup(void *p_groupName);
+
+ //
+ // deleteShareGroup - deletes the attachment of the p_groupName to its
+ // attached ShareGroup. When the last name of ShareGroup is
+ // deleted the ShareGroup object is destroyed.
+ //
+ void deleteShareGroup(void *p_groupName);
+
+ //
+ // getGlobalContext() - this function returns a name of an existing
+ // ShareGroup. The intent is that the EGL layer will
+ // use that function to get the GL context which each
+ // new context needs to share with.
+ //
+ void *getGlobalContext();
+
+private:
+ ShareGroupsMap m_groups;
+ emugl::Mutex m_lock;
+ GlobalNameSpace *m_globalNameSpace;
+};
+
+#endif