Bug 1027088 - Ensure fence delivery for TiledContentClient on gonk r=nical

This commit is contained in:
Sotaro Ikeda 2014-06-19 19:41:36 -07:00
Родитель ed828581ec
Коммит 0555dff07f
3 изменённых файлов: 58 добавлений и 7 удалений

Просмотреть файл

@ -377,6 +377,7 @@ TileClient::TileClient()
, mFrontBuffer(nullptr)
, mBackLock(nullptr)
, mFrontLock(nullptr)
, mCompositableClient(nullptr)
{
}
@ -386,6 +387,7 @@ TileClient::TileClient(const TileClient& o)
mFrontBuffer = o.mFrontBuffer;
mBackLock = o.mBackLock;
mFrontLock = o.mFrontLock;
mCompositableClient = nullptr;
#ifdef GFX_TILEDLAYER_DEBUG_OVERLAY
mLastUpdate = o.mLastUpdate;
#endif
@ -402,6 +404,7 @@ TileClient::operator=(const TileClient& o)
mFrontBuffer = o.mFrontBuffer;
mBackLock = o.mBackLock;
mFrontLock = o.mFrontLock;
mCompositableClient = nullptr;
#ifdef GFX_TILEDLAYER_DEBUG_OVERLAY
mLastUpdate = o.mLastUpdate;
#endif
@ -415,6 +418,20 @@ TileClient::operator=(const TileClient& o)
void
TileClient::Flip()
{
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
if (mFrontBuffer && mFrontBuffer->GetIPDLActor() &&
mCompositableClient && mCompositableClient->GetIPDLActor()) {
// remove old buffer from CompositableHost
RefPtr<AsyncTransactionTracker> tracker = new RemoveTextureFromCompositableTracker();
// Hold TextureClient until transaction complete.
tracker->SetTextureClient(mFrontBuffer);
mFrontBuffer->SetRemoveFromCompositableTracker(tracker);
// RemoveTextureFromCompositableAsync() expects CompositorChild's presence.
mManager->AsShadowForwarder()->RemoveTextureFromCompositableAsync(tracker,
mCompositableClient,
mFrontBuffer);
}
#endif
RefPtr<TextureClient> frontBuffer = mFrontBuffer;
mFrontBuffer = mBackBuffer;
mBackBuffer = frontBuffer;
@ -481,6 +498,20 @@ TileClient::DiscardFrontBuffer()
{
if (mFrontBuffer) {
MOZ_ASSERT(mFrontLock);
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
if (mFrontBuffer->GetIPDLActor() &&
mCompositableClient && mCompositableClient->GetIPDLActor()) {
// remove old buffer from CompositableHost
RefPtr<AsyncTransactionTracker> tracker = new RemoveTextureFromCompositableTracker();
// Hold TextureClient until transaction complete.
tracker->SetTextureClient(mFrontBuffer);
mFrontBuffer->SetRemoveFromCompositableTracker(tracker);
// RemoveTextureFromCompositableAsync() expects CompositorChild's presence.
mManager->AsShadowForwarder()->RemoveTextureFromCompositableAsync(tracker,
mCompositableClient,
mFrontBuffer);
}
#endif
mManager->GetTexturePool(mFrontBuffer->GetFormat())->ReturnTextureClientDeferred(mFrontBuffer);
mFrontLock->ReadUnlock();
mFrontBuffer = nullptr;
@ -499,7 +530,25 @@ TileClient::DiscardBackBuffer()
// this case we just want to drop it and not return it to the pool.
mManager->GetTexturePool(mBackBuffer->GetFormat())->ReportClientLost();
} else {
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
if (mBackBuffer->GetIPDLActor() &&
mCompositableClient && mCompositableClient->GetIPDLActor()) {
// remove old buffer from CompositableHost
RefPtr<AsyncTransactionTracker> tracker = new RemoveTextureFromCompositableTracker();
// Hold TextureClient until transaction complete.
tracker->SetTextureClient(mBackBuffer);
mBackBuffer->SetRemoveFromCompositableTracker(tracker);
// RemoveTextureFromCompositableAsync() expects CompositorChild's presence.
mManager->AsShadowForwarder()->RemoveTextureFromCompositableAsync(tracker,
mCompositableClient,
mBackBuffer);
}
// TextureClient can be reused after transaction complete,
// when RemoveTextureFromCompositableTracker is used.
mManager->GetTexturePool(mBackBuffer->GetFormat())->ReturnTextureClientDeferred(mBackBuffer);
#else
mManager->GetTexturePool(mBackBuffer->GetFormat())->ReturnTextureClient(mBackBuffer);
#endif
}
mBackLock->ReadUnlock();
mBackBuffer = nullptr;
@ -751,6 +800,7 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile,
if (aTile.IsPlaceholderTile()) {
aTile.SetLayerManager(mManager);
}
aTile.SetCompositableClient(mCompositableClient);
// Discard our front and backbuffers if our contents changed. In this case
// the calling code will already have taken care of invalidating the entire
@ -873,8 +923,6 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile,
backBuffer->Unlock();
aTile.Flip();
if (createdTextureClient) {
if (!mCompositableClient->AddTextureClient(backBuffer)) {
NS_WARNING("Failed to add tile TextureClient.");
@ -884,6 +932,8 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile,
}
}
aTile.Flip();
// Note, we don't call UpdatedTexture. The Updated function is called manually
// by the TiledContentHost before composition.

Просмотреть файл

@ -170,6 +170,11 @@ struct TileClient
mManager = aManager;
}
void SetCompositableClient(CompositableClient* aCompositableClient)
{
mCompositableClient = aCompositableClient;
}
bool IsPlaceholderTile()
{
return mBackBuffer == nullptr && mFrontBuffer == nullptr;
@ -224,6 +229,7 @@ struct TileClient
RefPtr<gfxSharedReadLock> mBackLock;
RefPtr<gfxSharedReadLock> mFrontLock;
RefPtr<ClientLayerManager> mManager;
CompositableClient* mCompositableClient;
#ifdef GFX_TILEDLAYER_DEBUG_OVERLAY
TimeStamp mLastUpdate;
#endif

Просмотреть файл

@ -63,11 +63,6 @@ TiledLayerBufferComposite::TiledLayerBufferComposite(ISurfaceAllocator* aAllocat
switch (tileDesc.type()) {
case TileDescriptor::TTexturedTileDescriptor : {
texture = TextureHost::AsTextureHost(tileDesc.get_TexturedTileDescriptor().textureParent());
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
if (!gfxPrefs::LayersUseSimpleTiles()) {
texture->SetRecycleCallback(RecycleCallback, nullptr);
}
#endif
const TileLock& ipcLock = tileDesc.get_TexturedTileDescriptor().sharedLock();
nsRefPtr<gfxSharedReadLock> sharedLock;
if (ipcLock.type() == TileLock::TShmemSection) {