Merge "GLES translator - enable binding to multiple texture targets"

This commit is contained in:
David Turner
2011-08-03 06:38:17 -07:00
committed by Android Code Review
7 changed files with 238 additions and 130 deletions

View File

@@ -73,6 +73,7 @@ static void initContext(GLEScontext* ctx,ShareGroupPtr grp) {
ctx->setShareGroup(grp); ctx->setShareGroup(grp);
ctx->init(); ctx->init();
glBindTexture(GL_TEXTURE_2D,0); glBindTexture(GL_TEXTURE_2D,0);
glBindTexture(GL_TEXTURE_CUBE_MAP_OES,0);
} }
} }
@@ -169,7 +170,12 @@ GL_API GLESiface* __translator_getIfaces(EGLiface* eglIface){
} }
static TextureData* getTextureData(unsigned int tex){ static ObjectLocalName TextureLocalName(GLenum target, unsigned int tex) {
GET_CTX_RET(0);
return (tex!=0? tex : ctx->getDefaultTextureName(target));
}
static TextureData* getTextureData(ObjectLocalName tex){
GET_CTX_RET(NULL); GET_CTX_RET(NULL);
if(!thrd->shareGroup->isObject(TEXTURE,tex)) if(!thrd->shareGroup->isObject(TEXTURE,tex))
@@ -188,11 +194,10 @@ static TextureData* getTextureData(unsigned int tex){
return texData; return texData;
} }
static TextureData* getTextureData(){ static TextureData* getTextureTargetData(GLenum target){
GET_CTX_RET(NULL); GET_CTX_RET(NULL);
unsigned int tex = ctx->getBindedTexture(); unsigned int tex = ctx->getBindedTexture(target);
return getTextureData(TextureLocalName(target,tex));
return getTextureData(tex);
} }
GL_API GLboolean GL_APIENTRY glIsBuffer(GLuint buffer) { GL_API GLboolean GL_APIENTRY glIsBuffer(GLuint buffer) {
@@ -303,19 +308,27 @@ GL_API void GL_APIENTRY glBindTexture( GLenum target, GLuint texture) {
GET_CTX() GET_CTX()
SET_ERROR_IF(!GLEScmValidate::textureTarget(target),GL_INVALID_ENUM) SET_ERROR_IF(!GLEScmValidate::textureTarget(target),GL_INVALID_ENUM)
GLuint globalTextureName = texture; //for handling default texture (0)
ObjectLocalName localTexName = TextureLocalName(target,texture);
GLuint globalTextureName = localTexName;
if(thrd->shareGroup.Ptr()){ if(thrd->shareGroup.Ptr()){
globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture); globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,localTexName);
//if texture wasn't generated before,generate one //if texture wasn't generated before,generate one
if(!globalTextureName){ if(!globalTextureName){
thrd->shareGroup->genName(TEXTURE,texture); thrd->shareGroup->genName(TEXTURE,localTexName);
globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture); globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,localTexName);
} }
}
ctx->setBindedTexture(texture);
TextureData* tex = getTextureData(texture);
tex->wasBound = true;
TextureData* texData = getTextureData(localTexName);
if (texData->target==0)
texData->target = target;
//if texture was already bound to another target
SET_ERROR_IF(texData->target!=target,GL_INVALID_OPERATION);
texData->wasBound = true;
}
ctx->setBindedTexture(target,texture);
ctx->dispatcher().glBindTexture(target,globalTextureName); ctx->dispatcher().glBindTexture(target,globalTextureName);
} }
@@ -484,10 +497,10 @@ GL_API void GL_APIENTRY glDeleteTextures( GLsizei n, const GLuint *textures) {
const GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,textures[i]); const GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,textures[i]);
ctx->dispatcher().glDeleteTextures(1,&globalTextureName); ctx->dispatcher().glDeleteTextures(1,&globalTextureName);
if(ctx->getBindedTexture() == textures[i]) if(ctx->getBindedTexture(GL_TEXTURE_2D) == textures[i])
{ ctx->setBindedTexture(GL_TEXTURE_2D,0);
ctx->setBindedTexture(0); if (ctx->getBindedTexture(GL_TEXTURE_CUBE_MAP) == textures[i])
} ctx->setBindedTexture(GL_TEXTURE_CUBE_MAP,0);
} }
} }
} }
@@ -521,10 +534,8 @@ GL_API void GL_APIENTRY glDisable( GLenum cap) {
ctx->dispatcher().glDisable(GL_TEXTURE_GEN_R); ctx->dispatcher().glDisable(GL_TEXTURE_GEN_R);
} }
ctx->dispatcher().glDisable(cap); ctx->dispatcher().glDisable(cap);
if (cap==GL_TEXTURE_2D) if (cap==GL_TEXTURE_2D || cap==GL_TEXTURE_CUBE_MAP_OES)
ctx->setTextureEnabled(TEXTURE_2D,false); ctx->setTextureEnabled(cap,false);
else if (cap==GL_TEXTURE_CUBE_MAP_OES)
ctx->setTextureEnabled(TEXTURE_CUBE_MAP,false);
} }
GL_API void GL_APIENTRY glDisableClientState( GLenum array) { GL_API void GL_APIENTRY glDisableClientState( GLenum array) {
@@ -585,10 +596,8 @@ GL_API void GL_APIENTRY glEnable( GLenum cap) {
} }
else else
ctx->dispatcher().glEnable(cap); ctx->dispatcher().glEnable(cap);
if (cap==GL_TEXTURE_2D) if (cap==GL_TEXTURE_2D || cap==GL_TEXTURE_CUBE_MAP_OES)
ctx->setTextureEnabled(TEXTURE_2D,true); ctx->setTextureEnabled(cap,true);
else if (cap==GL_TEXTURE_CUBE_MAP_OES)
ctx->setTextureEnabled(TEXTURE_CUBE_MAP,true);
} }
GL_API void GL_APIENTRY glEnableClientState( GLenum array) { GL_API void GL_APIENTRY glEnableClientState( GLenum array) {
@@ -986,7 +995,7 @@ GL_API void GL_APIENTRY glGetTexEnvxv( GLenum env, GLenum pname, GLfixed *param
GL_API void GL_APIENTRY glGetTexParameterfv( GLenum target, GLenum pname, GLfloat *params) { GL_API void GL_APIENTRY glGetTexParameterfv( GLenum target, GLenum pname, GLfloat *params) {
GET_CTX() GET_CTX()
if (pname==GL_TEXTURE_CROP_RECT_OES) { if (pname==GL_TEXTURE_CROP_RECT_OES) {
TextureData *texData = getTextureData(); TextureData *texData = getTextureTargetData(target);
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
for (int i=0;i<4;++i) for (int i=0;i<4;++i)
params[i] = texData->crop_rect[i]; params[i] = texData->crop_rect[i];
@@ -999,7 +1008,7 @@ GL_API void GL_APIENTRY glGetTexParameterfv( GLenum target, GLenum pname, GLflo
GL_API void GL_APIENTRY glGetTexParameteriv( GLenum target, GLenum pname, GLint *params) { GL_API void GL_APIENTRY glGetTexParameteriv( GLenum target, GLenum pname, GLint *params) {
GET_CTX() GET_CTX()
if (pname==GL_TEXTURE_CROP_RECT_OES) { if (pname==GL_TEXTURE_CROP_RECT_OES) {
TextureData *texData = getTextureData(); TextureData *texData = getTextureTargetData(target);
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
for (int i=0;i<4;++i) for (int i=0;i<4;++i)
params[i] = texData->crop_rect[i]; params[i] = texData->crop_rect[i];
@@ -1012,7 +1021,7 @@ GL_API void GL_APIENTRY glGetTexParameteriv( GLenum target, GLenum pname, GLint
GL_API void GL_APIENTRY glGetTexParameterxv( GLenum target, GLenum pname, GLfixed *params) { GL_API void GL_APIENTRY glGetTexParameterxv( GLenum target, GLenum pname, GLfixed *params) {
GET_CTX() GET_CTX()
if (pname==GL_TEXTURE_CROP_RECT_OES) { if (pname==GL_TEXTURE_CROP_RECT_OES) {
TextureData *texData = getTextureData(); TextureData *texData = getTextureTargetData(target);
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
for (int i=0;i<4;++i) for (int i=0;i<4;++i)
params[i] = F2X(texData->crop_rect[i]); params[i] = F2X(texData->crop_rect[i]);
@@ -1419,13 +1428,14 @@ GL_API void GL_APIENTRY glTexImage2D( GLenum target, GLint level, GLint interna
ctx->dispatcher().glTexImage2D(target,level,internalformat,width,height,border,format,type,pixels); ctx->dispatcher().glTexImage2D(target,level,internalformat,width,height,border,format,type,pixels);
if (thrd->shareGroup.Ptr()){ if (thrd->shareGroup.Ptr()){
TextureData *texData = getTextureData(); TextureData *texData = getTextureTargetData(target);
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
if(texData) { if(texData) {
texData->width = width; texData->width = width;
texData->height = height; texData->height = height;
texData->border = border; texData->border = border;
texData->internalFormat = internalformat; texData->internalFormat = internalformat;
texData->target = target;
if(texData->requiresAutoMipmap) if(texData->requiresAutoMipmap)
{ {
@@ -1435,13 +1445,13 @@ GL_API void GL_APIENTRY glTexImage2D( GLenum target, GLint level, GLint interna
} }
} }
static bool handleMipmapGeneration(GLenum pname, bool param) static bool handleMipmapGeneration(GLenum target, GLenum pname, bool param)
{ {
GET_CTX_RET(false) GET_CTX_RET(false)
if(pname == GL_GENERATE_MIPMAP && !ctx->isAutoMipmapSupported()) if(pname == GL_GENERATE_MIPMAP && !ctx->isAutoMipmapSupported())
{ {
TextureData *texData = getTextureData(); TextureData *texData = getTextureTargetData(target);
if(texData) if(texData)
{ {
texData->requiresAutoMipmap = param; texData->requiresAutoMipmap = param;
@@ -1456,7 +1466,7 @@ GL_API void GL_APIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat p
GET_CTX() GET_CTX()
SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM);
if(handleMipmapGeneration(pname, (bool)param)) if(handleMipmapGeneration(target, pname, (bool)param))
return; return;
ctx->dispatcher().glTexParameterf(target,pname,param); ctx->dispatcher().glTexParameterf(target,pname,param);
@@ -1466,11 +1476,11 @@ GL_API void GL_APIENTRY glTexParameterfv( GLenum target, GLenum pname, const GL
GET_CTX() GET_CTX()
SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM);
if(handleMipmapGeneration(pname, (bool)(*params))) if(handleMipmapGeneration(target, pname, (bool)(*params)))
return; return;
if (pname==GL_TEXTURE_CROP_RECT_OES) { if (pname==GL_TEXTURE_CROP_RECT_OES) {
TextureData *texData = getTextureData(); TextureData *texData = getTextureTargetData(target);
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
for (int i=0;i<4;++i) for (int i=0;i<4;++i)
texData->crop_rect[i] = params[i]; texData->crop_rect[i] = params[i];
@@ -1484,7 +1494,7 @@ GL_API void GL_APIENTRY glTexParameteri( GLenum target, GLenum pname, GLint par
GET_CTX() GET_CTX()
SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM);
if(handleMipmapGeneration(pname, (bool)param)) if(handleMipmapGeneration(target, pname, (bool)param))
return; return;
ctx->dispatcher().glTexParameteri(target,pname,param); ctx->dispatcher().glTexParameteri(target,pname,param);
@@ -1494,11 +1504,11 @@ GL_API void GL_APIENTRY glTexParameteriv( GLenum target, GLenum pname, const GL
GET_CTX() GET_CTX()
SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM);
if(handleMipmapGeneration(pname, (bool)(*params))) if(handleMipmapGeneration(target, pname, (bool)(*params)))
return; return;
if (pname==GL_TEXTURE_CROP_RECT_OES) { if (pname==GL_TEXTURE_CROP_RECT_OES) {
TextureData *texData = getTextureData(); TextureData *texData = getTextureTargetData(target);
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
for (int i=0;i<4;++i) for (int i=0;i<4;++i)
texData->crop_rect[i] = params[i]; texData->crop_rect[i] = params[i];
@@ -1512,7 +1522,7 @@ GL_API void GL_APIENTRY glTexParameterx( GLenum target, GLenum pname, GLfixed p
GET_CTX() GET_CTX()
SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM);
if(handleMipmapGeneration(pname, (bool)param)) if(handleMipmapGeneration(target, pname, (bool)param))
return; return;
ctx->dispatcher().glTexParameterf(target,pname,static_cast<GLfloat>(param)); ctx->dispatcher().glTexParameterf(target,pname,static_cast<GLfloat>(param));
@@ -1522,11 +1532,11 @@ GL_API void GL_APIENTRY glTexParameterxv( GLenum target, GLenum pname, const GL
GET_CTX() GET_CTX()
SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM);
if(handleMipmapGeneration(pname, (bool)(*params))) if(handleMipmapGeneration(target, pname, (bool)(*params)))
return; return;
if (pname==GL_TEXTURE_CROP_RECT_OES) { if (pname==GL_TEXTURE_CROP_RECT_OES) {
TextureData *texData = getTextureData(); TextureData *texData = getTextureTargetData(target);
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
for (int i=0;i<4;++i) for (int i=0;i<4;++i)
texData->crop_rect[i] = X2F(params[i]); texData->crop_rect[i] = X2F(params[i]);
@@ -1547,7 +1557,7 @@ GL_API void GL_APIENTRY glTexSubImage2D( GLenum target, GLint level, GLint xoff
ctx->dispatcher().glTexSubImage2D(target,level,xoffset,yoffset,width,height,format,type,pixels); ctx->dispatcher().glTexSubImage2D(target,level,xoffset,yoffset,width,height,format,type,pixels);
if (thrd->shareGroup.Ptr()){ if (thrd->shareGroup.Ptr()){
TextureData *texData = getTextureData(); TextureData *texData = getTextureTargetData(target);
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
if(texData && texData->requiresAutoMipmap) if(texData && texData->requiresAutoMipmap)
{ {
@@ -1588,7 +1598,7 @@ GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOE
// flag to the OpenGL layer to skip the image creation and map the // flag to the OpenGL layer to skip the image creation and map the
// current binded texture object to the existing global object. // current binded texture object to the existing global object.
if (thrd->shareGroup.Ptr()) { if (thrd->shareGroup.Ptr()) {
unsigned int tex = ctx->getBindedTexture(); ObjectLocalName tex = TextureLocalName(target,ctx->getBindedTexture(target));
unsigned int oldGlobal = thrd->shareGroup->getGlobalName(TEXTURE, tex); unsigned int oldGlobal = thrd->shareGroup->getGlobalName(TEXTURE, tex);
// Delete old texture object // Delete old texture object
if (oldGlobal) { if (oldGlobal) {
@@ -1597,7 +1607,7 @@ GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOE
// replace mapping and bind the new global object // replace mapping and bind the new global object
thrd->shareGroup->replaceGlobalName(TEXTURE, tex,img->globalTexName); thrd->shareGroup->replaceGlobalName(TEXTURE, tex,img->globalTexName);
ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, img->globalTexName); ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, img->globalTexName);
TextureData *texData = getTextureData(); TextureData *texData = getTextureTargetData(target);
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
texData->sourceEGLImage = (unsigned int)image; texData->sourceEGLImage = (unsigned int)image;
texData->eglImageDetach = s_eglIface->eglDetachEGLImage; texData->eglImageDetach = s_eglIface->eglDetachEGLImage;
@@ -1981,7 +1991,8 @@ void glDrawTexOES (T x, T y, T z, T width, T height) {
for (int i=0;i<ctx->getMaxTexUnits();++i) { for (int i=0;i<ctx->getMaxTexUnits();++i) {
if (ctx->isTextureUnitEnabled(GL_TEXTURE0+i)) { if (ctx->isTextureUnitEnabled(GL_TEXTURE0+i)) {
TextureData * texData = NULL; TextureData * texData = NULL;
int tex = ctx->getBindedTexture(GL_TEXTURE0+i); unsigned int texname = ctx->getBindedTexture(GL_TEXTURE0+i,GL_TEXTURE_2D);
ObjectLocalName tex = TextureLocalName(GL_TEXTURE_2D,texname);
ctx->dispatcher().glClientActiveTexture(GL_TEXTURE0+i); ctx->dispatcher().glClientActiveTexture(GL_TEXTURE0+i);
ObjectDataPtr objData = thrd->shareGroup->getObjectData(TEXTURE,tex); ObjectDataPtr objData = thrd->shareGroup->getObjectData(TEXTURE,tex);
if (objData.Ptr()) { if (objData.Ptr()) {

View File

@@ -70,6 +70,7 @@ static void initContext(GLEScontext* ctx,ShareGroupPtr grp) {
ctx->setShareGroup(grp); ctx->setShareGroup(grp);
ctx->init(); ctx->init();
glBindTexture(GL_TEXTURE_2D,0); glBindTexture(GL_TEXTURE_2D,0);
glBindTexture(GL_TEXTURE_CUBE_MAP,0);
} }
} }
static GLEScontext* createGLESContext() { static GLEScontext* createGLESContext() {
@@ -115,6 +116,30 @@ GL_APICALL GLESiface* __translator_getIfaces(EGLiface* eglIface){
} }
static ObjectLocalName TextureLocalName(GLenum target,unsigned int tex) {
GET_CTX_RET(0);
return (tex!=0? tex : ctx->getDefaultTextureName(target));
}
static TextureData* getTextureData(ObjectLocalName tex) {
GET_CTX_RET(NULL);
TextureData *texData = NULL;
ObjectDataPtr objData = thrd->shareGroup->getObjectData(TEXTURE,tex);
if(!objData.Ptr()){
texData = new TextureData();
thrd->shareGroup->setObjectData(TEXTURE, tex, ObjectDataPtr(texData));
} else {
texData = (TextureData*)objData.Ptr();
}
return texData;
}
static TextureData* getTextureTargetData(GLenum target){
GET_CTX_RET(NULL);
unsigned int tex = ctx->getBindedTexture(target);
return getTextureData(TextureLocalName(target,tex));
}
GL_APICALL void GL_APIENTRY glActiveTexture(GLenum texture){ GL_APICALL void GL_APIENTRY glActiveTexture(GLenum texture){
GET_CTX_V2(); GET_CTX_V2();
SET_ERROR_IF (!GLESv2Validate::textureEnum(texture,ctx->getMaxTexUnits()),GL_INVALID_ENUM); SET_ERROR_IF (!GLESv2Validate::textureEnum(texture,ctx->getMaxTexUnits()),GL_INVALID_ENUM);
@@ -204,16 +229,27 @@ GL_APICALL void GL_APIENTRY glBindTexture(GLenum target, GLuint texture){
GET_CTX(); GET_CTX();
SET_ERROR_IF(!GLESv2Validate::textureTarget(target),GL_INVALID_ENUM) SET_ERROR_IF(!GLESv2Validate::textureTarget(target),GL_INVALID_ENUM)
GLuint globalTextureName = texture; //for handling default texture (0)
ObjectLocalName localTexName = TextureLocalName(target,texture);
GLuint globalTextureName = localTexName;
if(thrd->shareGroup.Ptr()){ if(thrd->shareGroup.Ptr()){
globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture); globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,localTexName);
//if texture wasn't generated before,generate one //if texture wasn't generated before,generate one
if(!globalTextureName){ if(!globalTextureName){
thrd->shareGroup->genName(TEXTURE,texture); thrd->shareGroup->genName(TEXTURE,localTexName);
globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture); globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,localTexName);
} }
TextureData* texData = getTextureData(localTexName);
if (texData->target==0)
texData->target = target;
//if texture was already bound to another target
SET_ERROR_IF(texData->target !=target,GL_INVALID_OPERATION);
texData->wasBound = true;
} }
ctx->setBindedTexture(texture);
ctx->setBindedTexture(target,texture);
ctx->dispatcher().glBindTexture(target,globalTextureName); ctx->dispatcher().glBindTexture(target,globalTextureName);
} }
@@ -403,9 +439,16 @@ GL_APICALL void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures)
SET_ERROR_IF(n<0,GL_INVALID_VALUE); SET_ERROR_IF(n<0,GL_INVALID_VALUE);
if(thrd->shareGroup.Ptr()) { if(thrd->shareGroup.Ptr()) {
for(int i=0; i < n; i++){ for(int i=0; i < n; i++){
const GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,textures[i]); if (textures[i]!=0) {
thrd->shareGroup->deleteName(TEXTURE,textures[i]); const GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,textures[i]);
ctx->dispatcher().glDeleteTextures(1,&globalTextureName); thrd->shareGroup->deleteName(TEXTURE,textures[i]);
ctx->dispatcher().glDeleteTextures(1,&globalTextureName);
if (ctx->getBindedTexture(GL_TEXTURE_2D) == textures[i])
ctx->setBindedTexture(GL_TEXTURE_2D,0);
if (ctx->getBindedTexture(GL_TEXTURE_CUBE_MAP) == textures[i])
ctx->setBindedTexture(GL_TEXTURE_CUBE_MAP,0);
}
} }
} }
} }
@@ -571,7 +614,8 @@ GL_APICALL void GL_APIENTRY glFramebufferTexture2D(GLenum target, GLenum attach
SET_ERROR_IF(level != 0, GL_INVALID_VALUE); SET_ERROR_IF(level != 0, GL_INVALID_VALUE);
if(thrd->shareGroup.Ptr()) { if(thrd->shareGroup.Ptr()) {
GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture); ObjectLocalName texname = TextureLocalName(textarget,texture);
GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texname);
ctx->dispatcher().glFramebufferTexture2DEXT(target,attachment,textarget,globalTextureName,level); ctx->dispatcher().glFramebufferTexture2DEXT(target,attachment,textarget,globalTextureName,level);
} }
} }
@@ -1158,10 +1202,10 @@ GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer){
GL_APICALL GLboolean GL_APIENTRY glIsTexture(GLuint texture){ GL_APICALL GLboolean GL_APIENTRY glIsTexture(GLuint texture){
GET_CTX_RET(GL_FALSE) GET_CTX_RET(GL_FALSE)
if(texture && thrd->shareGroup.Ptr()){ if (texture==0)
return thrd->shareGroup->isObject(TEXTURE,texture) ? GL_TRUE :GL_FALSE; return GL_FALSE;
} TextureData* tex = getTextureData(texture);
return GL_FALSE; return tex ? tex->wasBound : GL_FALSE;
} }
GL_APICALL GLboolean GL_APIENTRY glIsProgram(GLuint program){ GL_APICALL GLboolean GL_APIENTRY glIsProgram(GLuint program){
@@ -1310,20 +1354,6 @@ GL_APICALL void GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenu
ctx->dispatcher().glStencilOp(fail,zfail,zpass); ctx->dispatcher().glStencilOp(fail,zfail,zpass);
} }
static TextureData* getTextureData(){
GET_CTX_RET(NULL);
unsigned int tex = ctx->getBindedTexture();
TextureData *texData = NULL;
ObjectDataPtr objData = thrd->shareGroup->getObjectData(TEXTURE,tex);
if(!objData.Ptr()){
texData = new TextureData();
thrd->shareGroup->setObjectData(TEXTURE, tex, ObjectDataPtr(texData));
} else {
texData = (TextureData*)objData.Ptr();
}
return texData;
}
GL_APICALL void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels){ GL_APICALL void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels){
GET_CTX(); GET_CTX();
SET_ERROR_IF(!(GLESv2Validate::textureTargetEx(target) && SET_ERROR_IF(!(GLESv2Validate::textureTargetEx(target) &&
@@ -1335,13 +1365,13 @@ GL_APICALL void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint inte
SET_ERROR_IF(border != 0,GL_INVALID_VALUE); SET_ERROR_IF(border != 0,GL_INVALID_VALUE);
if (thrd->shareGroup.Ptr()){ if (thrd->shareGroup.Ptr()){
unsigned int tex = ctx->getBindedTexture(); TextureData *texData = getTextureTargetData(target);
TextureData *texData = getTextureData();
if(texData) { if(texData) {
texData->width = width; texData->width = width;
texData->height = height; texData->height = height;
texData->border = border; texData->border = border;
texData->internalFormat = internalformat; texData->internalFormat = internalformat;
texData->target = target;
} }
} }
if (type==GL_HALF_FLOAT_OES) if (type==GL_HALF_FLOAT_OES)
@@ -1553,7 +1583,7 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglIma
// flag to the OpenGL layer to skip the image creation and map the // flag to the OpenGL layer to skip the image creation and map the
// current binded texture object to the existing global object. // current binded texture object to the existing global object.
if (thrd->shareGroup.Ptr()) { if (thrd->shareGroup.Ptr()) {
unsigned int tex = ctx->getBindedTexture(); ObjectLocalName tex = TextureLocalName(target,ctx->getBindedTexture(target));
unsigned int oldGlobal = thrd->shareGroup->getGlobalName(TEXTURE, tex); unsigned int oldGlobal = thrd->shareGroup->getGlobalName(TEXTURE, tex);
// Delete old texture object // Delete old texture object
if (oldGlobal) { if (oldGlobal) {
@@ -1562,7 +1592,7 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglIma
// replace mapping and bind the new global object // replace mapping and bind the new global object
thrd->shareGroup->replaceGlobalName(TEXTURE, tex,img->globalTexName); thrd->shareGroup->replaceGlobalName(TEXTURE, tex,img->globalTexName);
ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, img->globalTexName); ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, img->globalTexName);
TextureData *texData = getTextureData(); TextureData *texData = getTextureTargetData(target);
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
texData->sourceEGLImage = (unsigned int)image; texData->sourceEGLImage = (unsigned int)image;
texData->eglImageDetach = s_eglIface->eglDetachEGLImage; texData->eglImageDetach = s_eglIface->eglDetachEGLImage;

View File

@@ -121,11 +121,13 @@ void GLEScontext::init() {
initExtensionString(); initExtensionString();
int maxTexUnits = getMaxTexUnits(); int maxTexUnits = getMaxTexUnits();
m_tex2DBind = new textureUnitState[maxTexUnits]; m_texState = new textureUnitState[maxTexUnits];
for (int i=0;i<maxTexUnits;++i) { for (int i=0;i<maxTexUnits;++i) {
m_tex2DBind[i].texture = 0;
for (int j=0;j<NUM_TEXTURE_TARGETS;++j) for (int j=0;j<NUM_TEXTURE_TARGETS;++j)
m_tex2DBind[i].enabled[j] = GL_FALSE; {
m_texState[i][j].texture = 0;
m_texState[i][j].enabled = GL_FALSE;
}
} }
} }
} }
@@ -135,7 +137,7 @@ GLEScontext::GLEScontext():
m_activeTexture(0) , m_activeTexture(0) ,
m_unpackAlignment(4) , m_unpackAlignment(4) ,
m_glError(GL_NO_ERROR) , m_glError(GL_NO_ERROR) ,
m_tex2DBind(0) , m_texState(0) ,
m_arrayBuffer(0) , m_arrayBuffer(0) ,
m_elementBuffer(0){}; m_elementBuffer(0){};
@@ -158,8 +160,8 @@ GLEScontext::~GLEScontext() {
delete p; delete p;
} }
} }
delete[] m_tex2DBind; delete[] m_texState;
m_tex2DBind = NULL; m_texState = NULL;
} }
const GLvoid* GLEScontext::setPointer(GLenum arrType,GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize) { const GLvoid* GLEScontext::setPointer(GLenum arrType,GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize) {
@@ -518,7 +520,7 @@ void GLEScontext::initCapsLocked(const GLubyte * extensionString)
bool GLEScontext::isTextureUnitEnabled(GLenum unit) { bool GLEScontext::isTextureUnitEnabled(GLenum unit) {
for (int i=0;i<NUM_TEXTURE_TARGETS;++i) { for (int i=0;i<NUM_TEXTURE_TARGETS;++i) {
if (m_tex2DBind[unit-GL_TEXTURE0].enabled[i]) if (m_texState[unit-GL_TEXTURE0][i].enabled)
return true; return true;
} }
return false; return false;
@@ -588,8 +590,11 @@ bool GLEScontext::glGetIntegerv(GLenum pname, GLint *params)
break; break;
case GL_TEXTURE_BINDING_CUBE_MAP: case GL_TEXTURE_BINDING_CUBE_MAP:
*params = m_texState[m_activeTexture][TEXTURE_CUBE_MAP].texture;
break;
case GL_TEXTURE_BINDING_2D: case GL_TEXTURE_BINDING_2D:
*params = m_tex2DBind[m_activeTexture].texture; *params = m_texState[m_activeTexture][TEXTURE_2D].texture;
break; break;
case GL_ACTIVE_TEXTURE: case GL_ACTIVE_TEXTURE:
@@ -610,3 +615,59 @@ bool GLEScontext::glGetIntegerv(GLenum pname, GLint *params)
return true; return true;
} }
TextureTarget GLEScontext::GLTextureTargetToLocal(GLenum target) {
TextureTarget value=TEXTURE_2D;
switch (target) {
case GL_TEXTURE_CUBE_MAP:
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
value = TEXTURE_CUBE_MAP;
break;
case GL_TEXTURE_2D:
value = TEXTURE_2D;
break;
}
return value;
}
unsigned int GLEScontext::getBindedTexture(GLenum target) {
TextureTarget pos = GLTextureTargetToLocal(target);
return m_texState[m_activeTexture][pos].texture;
}
unsigned int GLEScontext::getBindedTexture(GLenum unit, GLenum target) {
TextureTarget pos = GLTextureTargetToLocal(target);
return m_texState[unit-GL_TEXTURE0][pos].texture;
}
void GLEScontext::setBindedTexture(GLenum target, unsigned int tex) {
TextureTarget pos = GLTextureTargetToLocal(target);
m_texState[m_activeTexture][pos].texture = tex;
}
void GLEScontext::setTextureEnabled(GLenum target, GLenum enable) {
TextureTarget pos = GLTextureTargetToLocal(target);
m_texState[m_activeTexture][pos].enabled = enable;
}
#define INTERNAL_NAME(x) (x +0x100000000ll);
ObjectLocalName GLEScontext::getDefaultTextureName(GLenum target) {
ObjectLocalName name = 0;
switch (GLTextureTargetToLocal(target)) {
case TEXTURE_2D:
name = INTERNAL_NAME(0);
break;
case TEXTURE_CUBE_MAP:
name = INTERNAL_NAME(1);
break;
default:
name = 0;
break;
}
return name;
}

View File

@@ -33,11 +33,11 @@ NameSpace::~NameSpace()
} }
} }
unsigned int ObjectLocalName
NameSpace::genName(unsigned int p_localName, bool genGlobal, bool genLocal) NameSpace::genName(ObjectLocalName p_localName, bool genGlobal, bool genLocal)
{ {
unsigned int localName = p_localName; ObjectLocalName localName = p_localName;
if (genLocal) { if (genLocal) {
do { do {
localName = ++m_nextName; localName = ++m_nextName;
@@ -53,7 +53,7 @@ NameSpace::genName(unsigned int p_localName, bool genGlobal, bool genLocal)
} }
unsigned int unsigned int
NameSpace::getGlobalName(unsigned int p_localName) NameSpace::getGlobalName(ObjectLocalName p_localName)
{ {
NamesMap::iterator n( m_localToGlobalMap.find(p_localName) ); NamesMap::iterator n( m_localToGlobalMap.find(p_localName) );
if (n != m_localToGlobalMap.end()) { if (n != m_localToGlobalMap.end()) {
@@ -65,7 +65,7 @@ NameSpace::getGlobalName(unsigned int p_localName)
return 0; return 0;
} }
unsigned int ObjectLocalName
NameSpace::getLocalName(unsigned int p_globalName) NameSpace::getLocalName(unsigned int p_globalName)
{ {
for(NamesMap::iterator it = m_localToGlobalMap.begin(); it != m_localToGlobalMap.end();it++){ for(NamesMap::iterator it = m_localToGlobalMap.begin(); it != m_localToGlobalMap.end();it++){
@@ -80,7 +80,7 @@ NameSpace::getLocalName(unsigned int p_globalName)
} }
void void
NameSpace::deleteName(unsigned int p_localName) NameSpace::deleteName(ObjectLocalName p_localName)
{ {
NamesMap::iterator n( m_localToGlobalMap.find(p_localName) ); NamesMap::iterator n( m_localToGlobalMap.find(p_localName) );
if (n != m_localToGlobalMap.end()) { if (n != m_localToGlobalMap.end()) {
@@ -90,13 +90,13 @@ NameSpace::deleteName(unsigned int p_localName)
} }
bool bool
NameSpace::isObject(unsigned int p_localName) NameSpace::isObject(ObjectLocalName p_localName)
{ {
return (m_localToGlobalMap.find(p_localName) != m_localToGlobalMap.end() ); return (m_localToGlobalMap.find(p_localName) != m_localToGlobalMap.end() );
} }
void void
NameSpace::replaceGlobalName(unsigned int p_localName, unsigned int p_globalName) NameSpace::replaceGlobalName(ObjectLocalName p_localName, unsigned int p_globalName)
{ {
NamesMap::iterator n( m_localToGlobalMap.find(p_localName) ); NamesMap::iterator n( m_localToGlobalMap.find(p_localName) );
if (n != m_localToGlobalMap.end()) { if (n != m_localToGlobalMap.end()) {
@@ -105,7 +105,7 @@ NameSpace::replaceGlobalName(unsigned int p_localName, unsigned int p_globalName
} }
} }
typedef std::pair<NamedObjectType, unsigned int> ObjectIDPair; typedef std::pair<NamedObjectType, ObjectLocalName> ObjectIDPair;
typedef std::map<ObjectIDPair, ObjectDataPtr> ObjectDataMap; typedef std::map<ObjectIDPair, ObjectDataPtr> ObjectDataMap;
ShareGroup::ShareGroup(GlobalNameSpace *globalNameSpace) ShareGroup::ShareGroup(GlobalNameSpace *globalNameSpace)
@@ -133,20 +133,20 @@ ShareGroup::~ShareGroup()
mutex_destroy(&m_lock); mutex_destroy(&m_lock);
} }
unsigned int ObjectLocalName
ShareGroup::genName(NamedObjectType p_type, unsigned int p_localName, bool genLocal) ShareGroup::genName(NamedObjectType p_type, ObjectLocalName p_localName, bool genLocal)
{ {
if (p_type >= NUM_OBJECT_TYPES) return 0; if (p_type >= NUM_OBJECT_TYPES) return 0;
mutex_lock(&m_lock); mutex_lock(&m_lock);
unsigned int localName = m_nameSpace[p_type]->genName(p_localName,true,genLocal); ObjectLocalName localName = m_nameSpace[p_type]->genName(p_localName,true,genLocal);
mutex_unlock(&m_lock); mutex_unlock(&m_lock);
return localName; return localName;
} }
unsigned int unsigned int
ShareGroup::getGlobalName(NamedObjectType p_type, unsigned int p_localName) ShareGroup::getGlobalName(NamedObjectType p_type, ObjectLocalName p_localName)
{ {
if (p_type >= NUM_OBJECT_TYPES) return 0; if (p_type >= NUM_OBJECT_TYPES) return 0;
@@ -157,20 +157,20 @@ ShareGroup::getGlobalName(NamedObjectType p_type, unsigned int p_localName)
return globalName; return globalName;
} }
unsigned int ObjectLocalName
ShareGroup::getLocalName(NamedObjectType p_type, unsigned int p_globalName) ShareGroup::getLocalName(NamedObjectType p_type, unsigned int p_globalName)
{ {
if (p_type >= NUM_OBJECT_TYPES) return 0; if (p_type >= NUM_OBJECT_TYPES) return 0;
mutex_lock(&m_lock); mutex_lock(&m_lock);
unsigned int localName = m_nameSpace[p_type]->getLocalName(p_globalName); ObjectLocalName localName = m_nameSpace[p_type]->getLocalName(p_globalName);
mutex_unlock(&m_lock); mutex_unlock(&m_lock);
return localName; return localName;
} }
void void
ShareGroup::deleteName(NamedObjectType p_type, unsigned int p_localName) ShareGroup::deleteName(NamedObjectType p_type, ObjectLocalName p_localName)
{ {
if (p_type >= NUM_OBJECT_TYPES) return; if (p_type >= NUM_OBJECT_TYPES) return;
@@ -184,7 +184,7 @@ ShareGroup::deleteName(NamedObjectType p_type, unsigned int p_localName)
} }
bool bool
ShareGroup::isObject(NamedObjectType p_type, unsigned int p_localName) ShareGroup::isObject(NamedObjectType p_type, ObjectLocalName p_localName)
{ {
if (p_type >= NUM_OBJECT_TYPES) return 0; if (p_type >= NUM_OBJECT_TYPES) return 0;
@@ -196,7 +196,7 @@ ShareGroup::isObject(NamedObjectType p_type, unsigned int p_localName)
} }
void void
ShareGroup::replaceGlobalName(NamedObjectType p_type, unsigned int p_localName, unsigned int p_globalName) ShareGroup::replaceGlobalName(NamedObjectType p_type, ObjectLocalName p_localName, unsigned int p_globalName)
{ {
if (p_type >= NUM_OBJECT_TYPES) return; if (p_type >= NUM_OBJECT_TYPES) return;
@@ -206,7 +206,7 @@ ShareGroup::replaceGlobalName(NamedObjectType p_type, unsigned int p_localName,
} }
void void
ShareGroup::setObjectData(NamedObjectType p_type, unsigned int p_localName, ObjectDataPtr data) ShareGroup::setObjectData(NamedObjectType p_type, ObjectLocalName p_localName, ObjectDataPtr data)
{ {
if (p_type >= NUM_OBJECT_TYPES) return; if (p_type >= NUM_OBJECT_TYPES) return;
@@ -225,7 +225,7 @@ ShareGroup::setObjectData(NamedObjectType p_type, unsigned int p_localName, Obje
} }
ObjectDataPtr ObjectDataPtr
ShareGroup::getObjectData(NamedObjectType p_type, unsigned int p_localName) ShareGroup::getObjectData(NamedObjectType p_type, ObjectLocalName p_localName)
{ {
ObjectDataPtr ret; ObjectDataPtr ret;

View File

@@ -15,10 +15,12 @@ TEXTURE_CUBE_MAP,
NUM_TEXTURE_TARGETS NUM_TEXTURE_TARGETS
}; };
typedef struct _textureUnitState { typedef struct _textureTargetState {
GLuint texture; GLuint texture;
GLboolean enabled[NUM_TEXTURE_TARGETS]; GLboolean enabled;
} textureUnitState; } textureTargetState;
typedef textureTargetState textureUnitState[NUM_TEXTURE_TARGETS];
class Version{ class Version{
public: public:
@@ -102,11 +104,12 @@ public:
void setGLerror(GLenum err); void setGLerror(GLenum err);
void setShareGroup(ShareGroupPtr grp){m_shareGroup = grp;}; void setShareGroup(ShareGroupPtr grp){m_shareGroup = grp;};
virtual void setActiveTexture(GLenum tex); virtual void setActiveTexture(GLenum tex);
unsigned int getBindedTexture(){return m_tex2DBind[m_activeTexture].texture;}; unsigned int getBindedTexture(GLenum target);
unsigned int getBindedTexture(GLenum unit) { return m_tex2DBind[unit - GL_TEXTURE0].texture;}; unsigned int getBindedTexture(GLenum unit,GLenum target);
void setBindedTexture(unsigned int tex){ m_tex2DBind[m_activeTexture].texture = tex;}; void setBindedTexture(GLenum target,unsigned int tex);
bool isTextureUnitEnabled(GLenum unit); bool isTextureUnitEnabled(GLenum unit);
void setTextureEnabled(TextureTarget target, GLenum enable) {m_tex2DBind[m_activeTexture].enabled[target] = enable; }; void setTextureEnabled(GLenum target, GLenum enable);
ObjectLocalName getDefaultTextureName(GLenum target);
bool isInitialized() { return m_initialized; }; bool isInitialized() { return m_initialized; };
void setUnpackAlignment(GLint param){ m_unpackAlignment = param; }; void setUnpackAlignment(GLint param){ m_unpackAlignment = param; };
GLint getUnpackAlignment(){ return m_unpackAlignment; }; GLint getUnpackAlignment(){ return m_unpackAlignment; };
@@ -166,10 +169,11 @@ private:
virtual void setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride, GLboolean normalized, int pointsIndex = -1) = 0 ; virtual void setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride, GLboolean normalized, int pointsIndex = -1) = 0 ;
GLuint getBuffer(GLenum target); GLuint getBuffer(GLenum target);
TextureTarget GLTextureTargetToLocal(GLenum target);
ShareGroupPtr m_shareGroup; ShareGroupPtr m_shareGroup;
GLenum m_glError; GLenum m_glError;
textureUnitState* m_tex2DBind; textureUnitState* m_texState;
unsigned int m_arrayBuffer; unsigned int m_arrayBuffer;
unsigned int m_elementBuffer; unsigned int m_elementBuffer;
}; };

View File

@@ -44,7 +44,8 @@ public:
internalFormat(GL_RGBA), internalFormat(GL_RGBA),
sourceEGLImage(0), sourceEGLImage(0),
wasBound(false), wasBound(false),
requiresAutoMipmap(false){ requiresAutoMipmap(false),
target(0) {
memset(crop_rect,0,4*sizeof(int)); memset(crop_rect,0,4*sizeof(int));
}; };
@@ -57,6 +58,7 @@ public:
bool requiresAutoMipmap; bool requiresAutoMipmap;
int crop_rect[4]; int crop_rect[4];
void (*eglImageDetach)(unsigned int imageId); void (*eglImageDetach)(unsigned int imageId);
GLenum target;
}; };
struct EglImage struct EglImage

View File

@@ -20,8 +20,6 @@
#include <map> #include <map>
#include "SmartPtr.h" #include "SmartPtr.h"
typedef std::map<unsigned int, unsigned int> NamesMap;
enum NamedObjectType { enum NamedObjectType {
VERTEXBUFFER = 0, VERTEXBUFFER = 0,
TEXTURE = 1, TEXTURE = 1,
@@ -50,6 +48,8 @@ private:
ObjectDataType m_dataType; ObjectDataType m_dataType;
}; };
typedef SmartPtr<ObjectData> ObjectDataPtr; typedef 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 // Class NameSpace - this class manages allocations and deletions of objects
@@ -78,38 +78,38 @@ private:
// the value of the global name can be retrieved using the // the value of the global name can be retrieved using the
// getGlobalName function. // getGlobalName function.
// //
unsigned int genName(unsigned int p_localName, bool genGlobal, bool genLocal); ObjectLocalName genName(ObjectLocalName p_localName, bool genGlobal, bool genLocal);
// //
// getGlobalName - returns the global name of an object or 0 if the object // getGlobalName - returns the global name of an object or 0 if the object
// does not exist. // does not exist.
// //
unsigned int getGlobalName(unsigned int p_localName); unsigned int getGlobalName(ObjectLocalName p_localName);
// //
// getLocaalName - returns the local name of an object or 0 if the object // getLocaalName - returns the local name of an object or 0 if the object
// does not exist. // does not exist.
// //
unsigned int getLocalName(unsigned int p_globalName); ObjectLocalName getLocalName(unsigned int p_globalName);
// //
// deleteName - deletes and object from the namespace as well as its // deleteName - deletes and object from the namespace as well as its
// global name from the global name space. // global name from the global name space.
// //
void deleteName(unsigned int p_localName); void deleteName(ObjectLocalName p_localName);
// //
// isObject - returns true if the named object exist. // isObject - returns true if the named object exist.
// //
bool isObject(unsigned int p_localName); bool isObject(ObjectLocalName p_localName);
// //
// replaces an object to map to an existing global object // replaces an object to map to an existing global object
// //
void replaceGlobalName(unsigned int p_localName, unsigned int p_globalName); void replaceGlobalName(ObjectLocalName p_localName, unsigned int p_globalName);
private: private:
unsigned int m_nextName; ObjectLocalName m_nextName;
NamesMap m_localToGlobalMap; NamesMap m_localToGlobalMap;
const NamedObjectType m_type; const NamedObjectType m_type;
GlobalNameSpace *m_globalNameSpace; GlobalNameSpace *m_globalNameSpace;
@@ -183,46 +183,46 @@ public:
// This function also generates a "global" name for the object // This function also generates a "global" name for the object
// which can be queried using the getGlobalName function. // which can be queried using the getGlobalName function.
// //
unsigned int genName(NamedObjectType p_type, unsigned int p_localName = 0, bool genLocal= false); ObjectLocalName genName(NamedObjectType p_type, ObjectLocalName p_localName = 0, bool genLocal= false);
// //
// getGlobalName - retrieves the "global" name of an object or 0 if the // getGlobalName - retrieves the "global" name of an object or 0 if the
// object does not exist. // object does not exist.
// //
unsigned int getGlobalName(NamedObjectType p_type, unsigned int p_localName); unsigned int getGlobalName(NamedObjectType p_type, ObjectLocalName p_localName);
// //
// getLocalName - retrieves the "local" name of an object or 0 if the // getLocalName - retrieves the "local" name of an object or 0 if the
// object does not exist. // object does not exist.
// //
unsigned int getLocalName(NamedObjectType p_type, unsigned int p_globalName); ObjectLocalName getLocalName(NamedObjectType p_type, unsigned int p_globalName);
// //
// deleteName - deletes and object from the namespace as well as its // deleteName - deletes and object from the namespace as well as its
// global name from the global name space. // global name from the global name space.
// //
void deleteName(NamedObjectType p_type, unsigned int p_localName); void deleteName(NamedObjectType p_type, ObjectLocalName p_localName);
// //
// replaceGlobalName - replaces an object to map to an existing global // replaceGlobalName - replaces an object to map to an existing global
// named object. (used when creating EGLImage siblings) // named object. (used when creating EGLImage siblings)
// //
void replaceGlobalName(NamedObjectType p_type, unsigned int p_localName, unsigned int p_globalName); void replaceGlobalName(NamedObjectType p_type, ObjectLocalName p_localName, unsigned int p_globalName);
// //
// isObject - returns true if the named object exist. // isObject - returns true if the named object exist.
// //
bool isObject(NamedObjectType p_type, unsigned int p_localName); bool isObject(NamedObjectType p_type, ObjectLocalName p_localName);
// //
// Assign object global data to a names object // Assign object global data to a names object
// //
void setObjectData(NamedObjectType p_type, unsigned int p_localName, ObjectDataPtr data); void setObjectData(NamedObjectType p_type, ObjectLocalName p_localName, ObjectDataPtr data);
// //
// Retrieve object global data // Retrieve object global data
// //
ObjectDataPtr getObjectData(NamedObjectType p_type, unsigned int p_localName); ObjectDataPtr getObjectData(NamedObjectType p_type, ObjectLocalName p_localName);
private: private:
explicit ShareGroup(GlobalNameSpace *globalNameSpace); explicit ShareGroup(GlobalNameSpace *globalNameSpace);