Bug 776334 - Don't double free shared texture handles for Flash on Android r=blassey

This commit is contained in:
James Willcox 2012-08-16 12:48:35 -04:00
parent e482af5c0a
commit 24e33f1004

View File

@ -88,15 +88,12 @@ class SharedPluginTexture {
public:
NS_INLINE_DECL_REFCOUNTING(SharedPluginTexture)
SharedPluginTexture() :
mCurrentHandle(0), mNeedNewImage(false), mLock("SharedPluginTexture.mLock")
SharedPluginTexture() : mLock("SharedPluginTexture.mLock")
{
}
~SharedPluginTexture()
{
// This will be destroyed in the compositor (as it normally is)
mCurrentHandle = 0;
}
TextureInfo Lock()
@ -115,9 +112,7 @@ public:
}
void Release(TextureInfo& aTextureInfo)
{
mNeedNewImage = true;
{
mTextureInfo = aTextureInfo;
mLock.Unlock();
}
@ -126,33 +121,25 @@ public:
{
MutexAutoLock lock(mLock);
if (!mNeedNewImage)
return mCurrentHandle;
if (!EnsureGLContext())
return 0;
mNeedNewImage = false;
if (mTextureInfo.mWidth == 0 || mTextureInfo.mHeight == 0)
return 0;
mCurrentHandle = sPluginContext->CreateSharedHandle(TextureImage::ThreadShared, (void*)mTextureInfo.mTexture, GLContext::TextureID);
SharedTextureHandle handle = sPluginContext->CreateSharedHandle(TextureImage::ThreadShared, (void*)mTextureInfo.mTexture, GLContext::TextureID);
// We want forget about this now, so delete the texture. Assigning it to zero
// ensures that we create a new one in Lock()
sPluginContext->fDeleteTextures(1, &mTextureInfo.mTexture);
mTextureInfo.mTexture = 0;
return mCurrentHandle;
return handle;
}
private:
TextureInfo mTextureInfo;
SharedTextureHandle mCurrentHandle;
bool mNeedNewImage;
Mutex mLock;
};