mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1098000 - Track the number of compositable references to TextureHost and only unbind gralloc textures after the last ref goes away. r=sotaro
This commit is contained in:
parent
cff89b6253
commit
6b1e0d15f3
@ -215,9 +215,6 @@ ContentHostTexture::Composite(EffectChain& aEffectChain,
|
||||
void
|
||||
ContentHostTexture::UseTextureHost(TextureHost* aTexture)
|
||||
{
|
||||
if (mTextureHost && mTextureHost != aTexture) {
|
||||
mTextureHost->UnbindTextureSource();
|
||||
}
|
||||
ContentHostBase::UseTextureHost(aTexture);
|
||||
mTextureHost = aTexture;
|
||||
mTextureHostOnWhite = nullptr;
|
||||
@ -231,12 +228,6 @@ void
|
||||
ContentHostTexture::UseComponentAlphaTextures(TextureHost* aTextureOnBlack,
|
||||
TextureHost* aTextureOnWhite)
|
||||
{
|
||||
if (mTextureHost && mTextureHost != aTextureOnBlack) {
|
||||
mTextureHost->UnbindTextureSource();
|
||||
}
|
||||
if (mTextureHostOnWhite && mTextureHostOnWhite != aTextureOnWhite) {
|
||||
mTextureHostOnWhite->UnbindTextureSource();
|
||||
}
|
||||
ContentHostBase::UseComponentAlphaTextures(aTextureOnBlack, aTextureOnWhite);
|
||||
mTextureHost = aTextureOnBlack;
|
||||
mTextureHostOnWhite = aTextureOnWhite;
|
||||
|
@ -173,8 +173,8 @@ public:
|
||||
virtual TemporaryRef<TexturedEffect> GenEffect(const gfx::Filter& aFilter) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
RefPtr<TextureHost> mTextureHost;
|
||||
RefPtr<TextureHost> mTextureHostOnWhite;
|
||||
CompositableTextureHostRef mTextureHost;
|
||||
CompositableTextureHostRef mTextureHostOnWhite;
|
||||
CompositableTextureSourceRef mTextureSource;
|
||||
CompositableTextureSourceRef mTextureSourceOnWhite;
|
||||
bool mLocked;
|
||||
|
@ -29,24 +29,17 @@ class ISurfaceAllocator;
|
||||
|
||||
ImageHost::ImageHost(const TextureInfo& aTextureInfo)
|
||||
: CompositableHost(aTextureInfo)
|
||||
, mFrontBuffer(nullptr)
|
||||
, mHasPictureRect(false)
|
||||
, mLocked(false)
|
||||
{}
|
||||
|
||||
ImageHost::~ImageHost()
|
||||
{
|
||||
if (mFrontBuffer) {
|
||||
mFrontBuffer->UnbindTextureSource();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ImageHost::UseTextureHost(TextureHost* aTexture)
|
||||
{
|
||||
if (mFrontBuffer && mFrontBuffer != aTexture) {
|
||||
mFrontBuffer->UnbindTextureSource();
|
||||
}
|
||||
CompositableHost::UseTextureHost(aTexture);
|
||||
mFrontBuffer = aTexture;
|
||||
if (mFrontBuffer) {
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
RefPtr<TextureHost> mFrontBuffer;
|
||||
CompositableTextureHostRef mFrontBuffer;
|
||||
CompositableTextureSourceRef mTextureSource;
|
||||
nsIntRect mPictureRect;
|
||||
bool mHasPictureRect;
|
||||
|
@ -289,6 +289,7 @@ TextureHost::CompositorRecycle()
|
||||
TextureHost::TextureHost(TextureFlags aFlags)
|
||||
: mActor(nullptr)
|
||||
, mFlags(aFlags)
|
||||
, mCompositableCount(0)
|
||||
{}
|
||||
|
||||
TextureHost::~TextureHost()
|
||||
|
@ -169,20 +169,21 @@ protected:
|
||||
* equivalent of a RefPtr<TextureSource>, that calls AddCompositableRef and
|
||||
* ReleaseCompositableRef in addition to the usual AddRef and Release.
|
||||
*/
|
||||
class CompositableTextureSourceRef {
|
||||
template<typename T>
|
||||
class CompositableTextureRef {
|
||||
public:
|
||||
CompositableTextureSourceRef() {}
|
||||
CompositableTextureRef() {}
|
||||
|
||||
~CompositableTextureSourceRef()
|
||||
~CompositableTextureRef()
|
||||
{
|
||||
if (mRef) {
|
||||
mRef->ReleaseCompositableRef();
|
||||
}
|
||||
}
|
||||
|
||||
CompositableTextureSourceRef& operator=(const TemporaryRef<TextureSource>& aOther)
|
||||
CompositableTextureRef& operator=(const TemporaryRef<T>& aOther)
|
||||
{
|
||||
RefPtr<TextureSource> temp = aOther;
|
||||
RefPtr<T> temp = aOther;
|
||||
if (temp) {
|
||||
temp->AddCompositableRef();
|
||||
}
|
||||
@ -193,7 +194,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
CompositableTextureSourceRef& operator=(TextureSource* aOther)
|
||||
CompositableTextureRef& operator=(T* aOther)
|
||||
{
|
||||
if (aOther) {
|
||||
aOther->AddCompositableRef();
|
||||
@ -205,15 +206,18 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
TextureSource* get() const { return mRef; }
|
||||
operator TextureSource*() const { return mRef; }
|
||||
TextureSource* operator->() const { return mRef; }
|
||||
TextureSource& operator*() const { return *mRef; }
|
||||
T* get() const { return mRef; }
|
||||
operator T*() const { return mRef; }
|
||||
T* operator->() const { return mRef; }
|
||||
T& operator*() const { return *mRef; }
|
||||
|
||||
private:
|
||||
RefPtr<TextureSource> mRef;
|
||||
RefPtr<T> mRef;
|
||||
};
|
||||
|
||||
typedef CompositableTextureRef<TextureSource> CompositableTextureSourceRef;
|
||||
typedef CompositableTextureRef<TextureHost> CompositableTextureHostRef;
|
||||
|
||||
/**
|
||||
* Interface for TextureSources that can be updated from a DataSourceSurface.
|
||||
*
|
||||
@ -505,11 +509,25 @@ public:
|
||||
*/
|
||||
virtual TextureHostOGL* AsHostOGL() { return nullptr; }
|
||||
|
||||
void AddCompositableRef() { ++mCompositableCount; }
|
||||
|
||||
void ReleaseCompositableRef()
|
||||
{
|
||||
--mCompositableCount;
|
||||
MOZ_ASSERT(mCompositableCount >= 0);
|
||||
if (mCompositableCount == 0) {
|
||||
UnbindTextureSource();
|
||||
}
|
||||
}
|
||||
|
||||
int NumCompositableRefs() const { return mCompositableCount; }
|
||||
|
||||
protected:
|
||||
void RecycleTexture(TextureFlags aFlags);
|
||||
|
||||
PTextureParent* mActor;
|
||||
TextureFlags mFlags;
|
||||
int mCompositableCount;
|
||||
|
||||
friend class TextureParent;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user