зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1039883 - release Tiled layer's gralloc when an application is background r=nical
This commit is contained in:
Родитель
9222a1a27e
Коммит
1179090250
|
@ -47,6 +47,7 @@ ClientTiledThebesLayer::ClearCachedResources()
|
|||
if (mContentClient) {
|
||||
mContentClient->ClearCachedResources();
|
||||
}
|
||||
mValidRegion.SetEmpty();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -101,8 +101,8 @@ TiledContentClient::TiledContentClient(ClientTiledThebesLayer* aThebesLayer,
|
|||
void
|
||||
TiledContentClient::ClearCachedResources()
|
||||
{
|
||||
mTiledBuffer.DiscardBackBuffers();
|
||||
mLowPrecisionTiledBuffer.DiscardBackBuffers();
|
||||
mTiledBuffer.DiscardBuffers();
|
||||
mLowPrecisionTiledBuffer.DiscardBuffers();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -678,10 +678,11 @@ ClientTiledLayerBuffer::Release()
|
|||
}
|
||||
|
||||
void
|
||||
ClientTiledLayerBuffer::DiscardBackBuffers()
|
||||
ClientTiledLayerBuffer::DiscardBuffers()
|
||||
{
|
||||
for (size_t i = 0; i < mRetainedTiles.Length(); i++) {
|
||||
if (mRetainedTiles[i].IsPlaceholderTile()) continue;
|
||||
mRetainedTiles[i].DiscardFrontBuffer();
|
||||
mRetainedTiles[i].DiscardBackBuffer();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -380,7 +380,7 @@ public:
|
|||
|
||||
void Release();
|
||||
|
||||
void DiscardBackBuffers();
|
||||
void DiscardBuffers();
|
||||
|
||||
const CSSToParentLayerScale& GetFrameResolution() { return mFrameResolution; }
|
||||
|
||||
|
|
|
@ -235,7 +235,7 @@ public:
|
|||
// detached in any case. if aLayer is null, then we will only detach if we are
|
||||
// not async.
|
||||
// Only force detach if the IPDL tree is being shutdown.
|
||||
void Detach(Layer* aLayer = nullptr, AttachFlags aFlags = NO_FLAGS)
|
||||
virtual void Detach(Layer* aLayer = nullptr, AttachFlags aFlags = NO_FLAGS)
|
||||
{
|
||||
if (!mKeepAttached ||
|
||||
aLayer == mLayer ||
|
||||
|
|
|
@ -232,6 +232,19 @@ TiledContentHost::Attach(Layer* aLayer,
|
|||
static_cast<ThebesLayerComposite*>(aLayer)->EnsureTiled();
|
||||
}
|
||||
|
||||
void
|
||||
TiledContentHost::Detach(Layer* aLayer,
|
||||
AttachFlags aFlags /* = NO_FLAGS */)
|
||||
{
|
||||
if (!mKeepAttached || aLayer == mLayer || aFlags & FORCE_DETACH) {
|
||||
mTiledBuffer = TiledLayerBufferComposite();
|
||||
mLowPrecisionTiledBuffer = TiledLayerBufferComposite();
|
||||
mOldTiledBuffer = TiledLayerBufferComposite();
|
||||
mOldLowPrecisionTiledBuffer = TiledLayerBufferComposite();
|
||||
}
|
||||
CompositableHost::Detach(aLayer,aFlags);
|
||||
}
|
||||
|
||||
void
|
||||
TiledContentHost::UseTiledLayerBuffer(ISurfaceAllocator* aAllocator,
|
||||
const SurfaceDescriptorTiles& aTiledDescriptor)
|
||||
|
|
|
@ -229,6 +229,9 @@ public:
|
|||
Compositor* aCompositor,
|
||||
AttachFlags aFlags = NO_FLAGS) MOZ_OVERRIDE;
|
||||
|
||||
virtual void Detach(Layer* aLayer = nullptr,
|
||||
AttachFlags aFlags = NO_FLAGS) MOZ_OVERRIDE;
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
virtual void Dump(std::stringstream& aStream,
|
||||
const char* aPrefix="",
|
||||
|
|
|
@ -327,5 +327,11 @@ ISurfaceAllocator::DeallocGrallocBuffer(MaybeMagicGrallocBufferHandle* aHandle)
|
|||
SharedBufferManagerChild::GetSingleton()->DeallocGrallocBuffer(*aHandle);
|
||||
}
|
||||
|
||||
void
|
||||
ISurfaceAllocator::DropGrallocBuffer(MaybeMagicGrallocBufferHandle* aHandle)
|
||||
{
|
||||
SharedBufferManagerChild::GetSingleton()->DropGrallocBuffer(*aHandle);
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -162,6 +162,8 @@ public:
|
|||
|
||||
void DeallocGrallocBuffer(MaybeMagicGrallocBufferHandle* aHandle);
|
||||
|
||||
void DropGrallocBuffer(MaybeMagicGrallocBufferHandle* aHandle);
|
||||
|
||||
virtual bool IPCOpen() const { return true; }
|
||||
virtual bool IsSameProcess() const = 0;
|
||||
|
||||
|
|
|
@ -317,18 +317,29 @@ SharedBufferManagerChild::DeallocGrallocBufferNow(const mozilla::layers::MaybeMa
|
|||
#endif
|
||||
}
|
||||
|
||||
bool SharedBufferManagerChild::RecvDropGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& handle)
|
||||
void
|
||||
SharedBufferManagerChild::DropGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& aHandle)
|
||||
{
|
||||
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
||||
NS_ASSERTION(handle.type() == mozilla::layers::MaybeMagicGrallocBufferHandle::TGrallocBufferRef, "shouldn't go this way");
|
||||
int64_t bufferKey = handle.get_GrallocBufferRef().mKey;
|
||||
int64_t bufferKey = -1;
|
||||
if (aHandle.type() == mozilla::layers::MaybeMagicGrallocBufferHandle::TMagicGrallocBufferHandle) {
|
||||
bufferKey = aHandle.get_MagicGrallocBufferHandle().mRef.mKey;
|
||||
} else if (aHandle.type() == mozilla::layers::MaybeMagicGrallocBufferHandle::TGrallocBufferRef) {
|
||||
bufferKey = aHandle.get_GrallocBufferRef().mKey;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
MutexAutoLock lock(mBufferMutex);
|
||||
NS_ASSERTION(mBuffers.count(bufferKey) != 0, "No such buffer");
|
||||
mBuffers.erase(bufferKey);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SharedBufferManagerChild::RecvDropGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& aHandle)
|
||||
{
|
||||
DropGrallocBuffer(aHandle);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,10 @@ public:
|
|||
void
|
||||
DeallocGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& aBuffer);
|
||||
|
||||
virtual bool RecvDropGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& handle);
|
||||
void
|
||||
DropGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& aHandle);
|
||||
|
||||
virtual bool RecvDropGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& aHandle);
|
||||
|
||||
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
||||
android::sp<android::GraphicBuffer> GetGraphicBuffer(int64_t key);
|
||||
|
|
|
@ -47,9 +47,11 @@ GrallocTextureClientOGL::GrallocTextureClientOGL(ISurfaceAllocator* aAllocator,
|
|||
GrallocTextureClientOGL::~GrallocTextureClientOGL()
|
||||
{
|
||||
MOZ_COUNT_DTOR(GrallocTextureClientOGL);
|
||||
if (ShouldDeallocateInDestructor()) {
|
||||
ISurfaceAllocator* allocator = GetAllocator();
|
||||
ISurfaceAllocator* allocator = GetAllocator();
|
||||
if (ShouldDeallocateInDestructor()) {
|
||||
allocator->DeallocGrallocBuffer(&mGrallocHandle);
|
||||
} else {
|
||||
allocator->DropGrallocBuffer(&mGrallocHandle);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче