Bug 1418869 - Do not try to share the fallback images. r=aosmond

The flag of force update is only for fallback items. Fallback items can't share the images with other items.
So I replace 'aForceUpdate' with 'aFallback' and remove some unnecessary checks.

MozReview-Commit-ID: Dcu95FZXlUz

--HG--
extra : rebase_source : 1ec96e0b5d39cc5760b4b5490c5ca9ccbc1933c6
This commit is contained in:
Ethan Lin 2017-11-20 10:36:14 +08:00
parent 04927bc058
commit a661b32865
4 changed files with 23 additions and 27 deletions

View File

@ -92,7 +92,6 @@ public:
wr::ImageKey UpdateKey(WebRenderLayerManager* aManager,
wr::IpcResourceUpdateQueue& aResources,
bool aForceUpdate,
uint32_t aGenerationId)
{
MOZ_ASSERT(aManager);
@ -114,7 +113,7 @@ public:
mKeys.RemoveElementAt(i);
} else if (entry.mManager == aManager) {
found = true;
if (aForceUpdate || entry.mGenerationId != aGenerationId) {
if (entry.mGenerationId != aGenerationId) {
aManager->AddImageKeyForDiscard(entry.mImageKey);
entry.mGenerationId = aGenerationId;
entry.mImageKey = aManager->WrBridge()->GetNextImageKey();
@ -151,7 +150,6 @@ SharedSurfacesChild::DestroySharedUserData(void* aClosure)
SharedSurfacesChild::Share(SourceSurfaceSharedData* aSurface,
WebRenderLayerManager* aManager,
wr::IpcResourceUpdateQueue& aResources,
bool aForceUpdate,
uint32_t aGenerationId,
wr::ImageKey& aKey)
{
@ -176,7 +174,7 @@ SharedSurfacesChild::Share(SourceSurfaceSharedData* aSurface,
data->SetId(manager->GetNextExternalImageId());
} else if (data->IsShared()) {
// It has already been shared with the GPU process, reuse the id.
aKey = data->UpdateKey(aManager, aResources, aForceUpdate, aGenerationId);
aKey = data->UpdateKey(aManager, aResources, aGenerationId);
return NS_OK;
}
@ -194,7 +192,7 @@ SharedSurfacesChild::Share(SourceSurfaceSharedData* aSurface,
if (pid == base::GetCurrentProcId()) {
SharedSurfacesParent::AddSameProcess(data->Id(), aSurface);
data->MarkShared();
aKey = data->UpdateKey(aManager, aResources, aForceUpdate, aGenerationId);
aKey = data->UpdateKey(aManager, aResources, aGenerationId);
return NS_OK;
}
@ -229,7 +227,7 @@ SharedSurfacesChild::Share(SourceSurfaceSharedData* aSurface,
SurfaceDescriptorShared(aSurface->GetSize(),
aSurface->Stride(),
format, handle));
aKey = data->UpdateKey(aManager, aResources, aForceUpdate, aGenerationId);
aKey = data->UpdateKey(aManager, aResources, aGenerationId);
return NS_OK;
}
@ -237,7 +235,6 @@ SharedSurfacesChild::Share(SourceSurfaceSharedData* aSurface,
SharedSurfacesChild::Share(ImageContainer* aContainer,
WebRenderLayerManager* aManager,
wr::IpcResourceUpdateQueue& aResources,
bool aForceUpdate,
wr::ImageKey& aKey)
{
MOZ_ASSERT(NS_IsMainThread());
@ -266,7 +263,7 @@ SharedSurfacesChild::Share(ImageContainer* aContainer,
auto sharedSurface = static_cast<SourceSurfaceSharedData*>(surface.get());
return Share(sharedSurface, aManager, aResources,
aForceUpdate, generation, aKey);
generation, aKey);
}
/* static */ void

View File

@ -33,14 +33,12 @@ public:
static nsresult Share(gfx::SourceSurfaceSharedData* aSurface,
WebRenderLayerManager* aManager,
wr::IpcResourceUpdateQueue& aResources,
bool aForceUpdate,
uint32_t aGenerationId,
wr::ImageKey& aKey);
static nsresult Share(ImageContainer* aContainer,
WebRenderLayerManager* aManager,
wr::IpcResourceUpdateQueue& aResources,
bool aForceUpdate,
wr::ImageKey& aKey);
private:

View File

@ -93,7 +93,7 @@ WebRenderImageData::ClearCachedResources()
Maybe<wr::ImageKey>
WebRenderImageData::UpdateImageKey(ImageContainer* aContainer,
wr::IpcResourceUpdateQueue& aResources,
bool aForceUpdate)
bool aFallback)
{
MOZ_ASSERT(aContainer);
@ -102,21 +102,22 @@ WebRenderImageData::UpdateImageKey(ImageContainer* aContainer,
}
wr::WrImageKey key;
nsresult rv = SharedSurfacesChild::Share(aContainer, mWRManager, aResources,
aForceUpdate, key);
if (NS_SUCCEEDED(rv)) {
// Ensure that any previously owned keys are released before replacing. We
// don't own this key, the surface itself owns it, so that it can be shared
// across multiple elements.
ClearImageKey();
mKey = Some(key);
return mKey;
}
if (!aFallback) {
nsresult rv = SharedSurfacesChild::Share(aContainer, mWRManager, aResources, key);
if (NS_SUCCEEDED(rv)) {
// Ensure that any previously owned keys are released before replacing. We
// don't own this key, the surface itself owns it, so that it can be shared
// across multiple elements.
ClearImageKey();
mKey = Some(key);
return mKey;
}
if (rv != NS_ERROR_NOT_IMPLEMENTED) {
// We should be using the shared surface but somehow sharing it failed.
ClearImageKey();
return Nothing();
if (rv != NS_ERROR_NOT_IMPLEMENTED) {
// We should be using the shared surface but somehow sharing it failed.
ClearImageKey();
return Nothing();
}
}
CreateImageClientIfNeeded();
@ -139,7 +140,7 @@ WebRenderImageData::UpdateImageKey(ImageContainer* aContainer,
}
// Reuse old key if generation is not updated.
if (!aForceUpdate && oldCounter == imageClient->GetLastUpdateGenerationCounter() && mKey) {
if (!aFallback && oldCounter == imageClient->GetLastUpdateGenerationCounter() && mKey) {
return mKey;
}

View File

@ -85,7 +85,7 @@ public:
Maybe<wr::ImageKey> UpdateImageKey(ImageContainer* aContainer,
wr::IpcResourceUpdateQueue& aResources,
bool aForceUpdate = false);
bool aFallback = false);
void CreateAsyncImageWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
ImageContainer* aContainer,