am 62f593fa: am 7660bb58: Merge "Fix a mess in contexts/surfaces reference count"

* commit '62f593fa2daf2ebc1ba3d10dc4a46dbd2ef3bf39':
  Fix a mess in contexts/surfaces reference count
This commit is contained in:
David Turner
2011-06-03 18:38:18 -07:00
committed by Android Git Automerger
5 changed files with 19 additions and 13 deletions

View File

@@ -53,6 +53,7 @@ public:
bool attachImage(unsigned int imageId,ImagePtr img);
void detachImage(unsigned int imageId);
~EglContext(){}
private:
static unsigned int s_nextContextHndl;
EGLNativeContextType m_native;

View File

@@ -108,7 +108,7 @@ bool EglDisplay::removeSurface(SurfacePtr s) {
SurfacesHndlMap::iterator it;
for(it = m_surfaces.begin(); it!= m_surfaces.end();it++)
{
if((*it).second == s.Ptr()) {
if((*it).second.Ptr() == s.Ptr()) {
break;
}
}
@@ -135,7 +135,7 @@ bool EglDisplay::removeContext(ContextPtr ctx) {
ContextsHndlMap::iterator it;
for(it = m_contexts.begin(); it != m_contexts.end();it++) {
if((*it).second == ctx.Ptr()){
if((*it).second.Ptr() == ctx.Ptr()){
break;
}
}

View File

@@ -564,7 +564,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay display, EGLSurface s
RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE);
}
srfc->destroy(); //mark surface for destruction
srfc->markForDestruction(); //mark surface for destruction
if(destroySurfaceIfNotCurrent(dpy,srfc)) { //removes surface from the list if not current
dpy->removeSurface(surface);
}
@@ -659,7 +659,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay display, EGLContext c
VALIDATE_DISPLAY(display);
VALIDATE_CONTEXT(context);
ctx->destroy(); //mark for destruction
ctx->markForDestruction(); //mark for destruction
if(destroyContextIfNotCurrent(dpy,ctx)){ //removes the context from the list if it is not current
g_eglInfo->getIface(ctx->version())->deleteGLESContext(ctx->getGlesContext());
dpy->removeContext(context);
@@ -816,7 +816,7 @@ EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void) {
EglDisplay* dpy = static_cast<EglDisplay*>(thread->eglDisplay);
EglContext* ctx = static_cast<EglContext*>(thread->eglContext);
if(dpy && ctx){
return dpy->getContext(ContextPtr(ctx));
return dpy->getContext(ctx).Ptr();
}
return EGL_NO_CONTEXT;
}
@@ -830,7 +830,16 @@ EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw) {
if(dpy && ctx) {
SurfacePtr surface = readdraw == EGL_READ ? ctx->read() : ctx->draw();
return dpy->getSurface(surface);
if(surface.Ptr())
{
// This double check is required because a surface might still be
// current after it is destroyed - in which case its handle should
// be invalid, that is EGL_NO_SURFACE should be returned even
// though the surface is current.
surface = dpy->getSurface(surface.Ptr());
if(surface.Ptr())
return surface.Ptr();
}
}
return EGL_NO_SURFACE;
}
@@ -858,7 +867,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine) {
SurfacePtr draw = currCtx->draw();
EGLNativeDisplayType nativeDisplay = dpy->nativeType();
if(read) {
if(read.Ptr()) {
if(read->type() == EglSurface::WINDOW &&
!EglOS::validNativeWin(nativeDisplay,reinterpret_cast<EGLNativeWindowType>(read->native()))) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE);
@@ -868,7 +877,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE);
}
}
if(draw) {
if(draw.Ptr()) {
if(draw->type() == EglSurface::WINDOW &&
!EglOS::validNativeWin(nativeDisplay,reinterpret_cast<EGLNativeWindowType>(draw->native()))) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE);

View File

@@ -1215,7 +1215,7 @@ void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
// Create the texture object in the underlying EGL implementation,
// flag to the OpenGL layer to skip the image creation and map the
// current binded texture object to the existing global object.
if (thrd->shareGroup) {
if (thrd->shareGroup.Ptr()) {
unsigned int tex = ctx->getBindedTexture();
unsigned int oldGlobal = thrd->shareGroup->getGlobalName(TEXTURE, tex);
// Delete old texture object

View File

@@ -91,10 +91,6 @@ public:
return *m_ptr;
}
operator void*() const {
return (void *)m_ptr;
}
// This gives STL lists something to compare.
bool operator <(const SmartPtr<T>& t1) const {
return m_ptr < t1.m_ptr;