mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 951218 - Use RAII to unlock TextureHost. r=bjacob
This commit is contained in:
parent
7426c28af4
commit
1ff99ae9e0
@ -40,32 +40,6 @@ ContentHostBase::GetAsTextureHost()
|
||||
return mTextureHost;
|
||||
}
|
||||
|
||||
class MOZ_STACK_CLASS AutoLockTextureHost
|
||||
{
|
||||
public:
|
||||
AutoLockTextureHost(TextureHost* aHost)
|
||||
: mHost(aHost)
|
||||
{
|
||||
mLockSuccess = mHost ? mHost->Lock() : true;
|
||||
}
|
||||
|
||||
~AutoLockTextureHost()
|
||||
{
|
||||
if (mHost) {
|
||||
mHost->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
bool IsValid()
|
||||
{
|
||||
return mLockSuccess;
|
||||
}
|
||||
|
||||
private:
|
||||
TextureHost* mHost;
|
||||
bool mLockSuccess;
|
||||
};
|
||||
|
||||
void
|
||||
ContentHostBase::Composite(EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
@ -77,12 +51,15 @@ ContentHostBase::Composite(EffectChain& aEffectChain,
|
||||
{
|
||||
NS_ASSERTION(aVisibleRegion, "Requires a visible region");
|
||||
|
||||
if (!mTextureHost) {
|
||||
NS_WARNING("Missing TextureHost");
|
||||
return;
|
||||
}
|
||||
|
||||
AutoLockTextureHost lock(mTextureHost);
|
||||
AutoLockTextureHost lockOnWhite(mTextureHostOnWhite);
|
||||
|
||||
if (!mTextureHost ||
|
||||
!lock.IsValid() ||
|
||||
!lockOnWhite.IsValid()) {
|
||||
if (lock.Failed() || lockOnWhite.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,8 @@ ImageHost::Composite(EffectChain& aEffectChain,
|
||||
// Make sure the front buffer has a compositor
|
||||
mFrontBuffer->SetCompositor(GetCompositor());
|
||||
|
||||
if (!mFrontBuffer->Lock()) {
|
||||
AutoLockTextureHost autoLock(mFrontBuffer);
|
||||
if (autoLock.Failed()) {
|
||||
NS_WARNING("failed to lock front buffer");
|
||||
return;
|
||||
}
|
||||
@ -153,7 +154,6 @@ ImageHost::Composite(EffectChain& aEffectChain,
|
||||
rect, aClipRect,
|
||||
aTransform);
|
||||
}
|
||||
mFrontBuffer->Unlock();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -780,6 +780,30 @@ protected:
|
||||
gfx::SurfaceFormat mFormat;
|
||||
};
|
||||
|
||||
class MOZ_STACK_CLASS AutoLockTextureHost
|
||||
{
|
||||
public:
|
||||
AutoLockTextureHost(TextureHost* aTexture)
|
||||
: mTexture(aTexture)
|
||||
{
|
||||
MOZ_ASSERT(mTexture);
|
||||
mLocked = aTexture->Lock();
|
||||
}
|
||||
|
||||
~AutoLockTextureHost()
|
||||
{
|
||||
if (mLocked) {
|
||||
mTexture->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
bool Failed() { return !mLocked; }
|
||||
|
||||
private:
|
||||
RefPtr<TextureHost> mTexture;
|
||||
bool mLocked;
|
||||
};
|
||||
|
||||
class AutoLockDeprecatedTextureHost
|
||||
{
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user