diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.cpp index 9fcdf64fe..d9357c2d1 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.cpp +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.cpp @@ -67,7 +67,10 @@ EglConfig::EglConfig(EGLint red_size, m_trans_red_val(trans_red_val), m_trans_green_val(trans_green_val), m_trans_blue_val(trans_blue_val), - m_nativeFormat(frmt){}; + m_conformant(((red_size + green_size + blue_size + alpha_size > 0) && + (caveat!=EGL_NON_CONFORMANT_CONFIG)) ? + m_renderable_type : 0), + m_nativeFormat(frmt) {}; EglConfig::EglConfig(const EglConfig& conf):m_buffer_size(conf.m_buffer_size), @@ -98,7 +101,8 @@ EglConfig::EglConfig(EGLint red_size, m_trans_red_val(conf.m_trans_red_val), m_trans_green_val(conf.m_trans_green_val), m_trans_blue_val(conf.m_trans_blue_val), - m_nativeFormat(conf.m_nativeFormat){}; + m_conformant(conf.m_conformant), + m_nativeFormat(conf.m_nativeFormat) {}; @@ -187,6 +191,9 @@ bool EglConfig::getConfAttrib(EGLint attrib,EGLint* val) const { case EGL_TRANSPARENT_BLUE_VALUE: *val = m_trans_blue_val; break; + case EGL_CONFORMANT: + *val = m_conformant; + break; default: return false; } @@ -283,6 +290,9 @@ bool EglConfig::choosen(const EglConfig& dummy) { //mask if(dummy.m_surface_type != EGL_DONT_CARE && ((dummy.m_surface_type & m_surface_type) != dummy.m_surface_type)) return false; + + if(dummy.m_conformant != EGL_DONT_CARE && + ((dummy.m_conformant & m_conformant) != dummy.m_conformant)) return false; if(dummy.m_renderable_type != EGL_DONT_CARE && ((dummy.m_renderable_type & m_renderable_type) != dummy.m_renderable_type)) return false; diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.h b/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.h index 3336f0e67..ad4e37d2d 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.h +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.h @@ -91,6 +91,7 @@ private: const EGLint m_trans_red_val; const EGLint m_trans_green_val; const EGLint m_trans_blue_val; + const EGLenum m_conformant; const EGLNativePixelFormatType m_nativeFormat; }; diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp index 6710baafb..122316842 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp @@ -29,7 +29,8 @@ m_glesContext(glesCtx), m_read(NULL), m_draw(NULL), m_destroy(false), -m_version(ver) +m_version(ver), +m_mngr(mngr) { m_shareGroup = shared_context.Ptr()? mngr->attachShareGroup(context,shared_context.Ptr()->getShareGroup().Ptr()): @@ -37,6 +38,14 @@ m_version(ver) m_hndl = ++s_nextContextHndl; } +EglContext::~EglContext() +{ + if (m_mngr) + { + m_mngr->deleteShareGroup(m_native); + } +} + void EglContext::setSurfaces(SurfacePtr read,SurfacePtr draw) { m_read = read; diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.h b/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.h index 5b528ab9f..1f5463151 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.h +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.h @@ -53,7 +53,8 @@ public: bool attachImage(unsigned int imageId,ImagePtr img); void detachImage(unsigned int imageId); - ~EglContext(){} + ~EglContext(); + private: static unsigned int s_nextContextHndl; EGLNativeContextType m_native; @@ -64,6 +65,7 @@ private: SurfacePtr m_draw; bool m_destroy; GLESVersion m_version; + ObjectNameManager *m_mngr; unsigned int m_hndl; ImagesHndlMap m_attachedImages; }; diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglValidate.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglValidate.cpp index a4b2cc677..d87f9b9b0 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglValidate.cpp +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglValidate.cpp @@ -46,6 +46,7 @@ bool EglValidate::confAttrib(EGLint attrib) { case EGL_TRANSPARENT_RED_VALUE: case EGL_TRANSPARENT_GREEN_VALUE: case EGL_TRANSPARENT_BLUE_VALUE: + case EGL_CONFORMANT: return true; } return false; diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp index a695d37ee..3aee4b46d 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp @@ -39,16 +39,16 @@ int ErrorHandler::s_lastErrorCode = 0; android::Mutex ErrorHandler::s_lock; ErrorHandler::ErrorHandler(EGLNativeDisplayType dpy){ - s_lock.lock(); + android::Mutex::Autolock mutex(s_lock); XSync(dpy,False); s_lastErrorCode = 0; m_oldErrorHandler = XSetErrorHandler(errorHandlerProc); } ErrorHandler::~ErrorHandler(){ + android::Mutex::Autolock mutex(s_lock); XSetErrorHandler(m_oldErrorHandler); s_lastErrorCode = 0; - s_lock.unlock(); } int ErrorHandler::errorHandlerProc(EGLNativeDisplayType dpy,XErrorEvent* event){ @@ -130,7 +130,11 @@ EglConfig* pixelFormatToConfig(EGLNativeDisplayType dpy,int renderableType,EGLNa IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_LEVEL,&level)); IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_FBCONFIG_ID,&configId)); IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_SAMPLES,&samples)); - + //Filter out configs that does not support RGBA + IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_RENDER_TYPE,&tmp)); + if (!(tmp & GLX_RGBA_BIT)) { + return NULL; + } return new EglConfig(red,green,blue,alpha,caveat,configId,depth,level,pMaxWidth,pMaxHeight, pMaxPixels,renderable,renderableType,visualId,visualType,samples,stencil, diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp index d708a258e..7e2141c5e 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp +++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp @@ -141,7 +141,7 @@ GL_APICALL void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer){ } ctx->bindBuffer(target,buffer); GLESbuffer* vbo = (GLESbuffer*)thrd->shareGroup->getObjectData(VERTEXBUFFER,buffer).Ptr(); - vbo->wasBinded(); + vbo->setBinded(); } GL_APICALL void GL_APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer){ @@ -1251,7 +1251,7 @@ GL_APICALL void GL_APIENTRY glVertexAttribPointer(GLuint indx, GLint size, GLen if (type==GL_HALF_FLOAT_OES) type = GL_HALF_FLOAT; const GLvoid* data = ctx->setPointer(indx,size,type,stride,ptr); - if(type != GL_FIXED) ctx->dispatcher().glVertexAttribPointer(indx,size,type,normalized,stride,ptr); + if(type != GL_FIXED) ctx->dispatcher().glVertexAttribPointer(indx,size,type,normalized,stride,data); } GL_APICALL void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height){