Bug 1315974 - When creating the widget layer manager, don't assume it will always be a ClientLayerManager. r=mattwoodrow

MozReview-Commit-ID: 8r037jdHJ0E

--HG--
extra : rebase_source : 5f0e406ea6eb497b72f40054ba50cf64a6bd7dfb
This commit is contained in:
Kartikaya Gupta 2016-11-08 10:42:26 -05:00
Родитель c19a47d368
Коммит 7e39a2bc59
3 изменённых файлов: 70 добавлений и 53 удалений

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

@ -2413,8 +2413,9 @@ TabChild::RecvSetDocShellIsActive(const bool& aIsActive,
// We send the current layer observer epoch to the compositor so that
// TabParent knows whether a layer update notification corresponds to the
// latest SetDocShellIsActive request that was made.
ClientLayerManager *manager = mPuppetWidget->GetLayerManager()->AsClientLayerManager();
manager->SetLayerObserverEpoch(aLayerObserverEpoch);
if (ClientLayerManager* clm = mPuppetWidget->GetLayerManager()->AsClientLayerManager()) {
clm->SetLayerObserverEpoch(aLayerObserverEpoch);
}
// docshell is consider prerendered only if not active yet
mIsPrerendered &= !aIsActive;
@ -2588,6 +2589,16 @@ TabChild::InitRenderingState(const TextureFactoryIdentifier& aTextureFactoryIden
PRenderFrameChild::Send__delete__(remoteFrame);
return false;
}
ShadowLayerForwarder* lf =
mPuppetWidget->GetLayerManager(
nullptr, mTextureFactoryIdentifier.mParentBackend)
->AsShadowForwarder();
// As long as we are creating a ClientLayerManager for the puppet widget,
// lf must be non-null here.
MOZ_ASSERT(lf);
if (lf) {
nsTArray<LayersBackend> backends;
backends.AppendElement(mTextureFactoryIdentifier.mParentBackend);
bool success;
@ -2607,15 +2618,11 @@ TabChild::InitRenderingState(const TextureFactoryIdentifier& aTextureFactoryIden
return false;
}
ShadowLayerForwarder* lf =
mPuppetWidget->GetLayerManager(
shadowManager, mTextureFactoryIdentifier.mParentBackend)
->AsShadowForwarder();
MOZ_ASSERT(lf && lf->HasShadowManager(),
"PuppetWidget should have shadow manager");
lf->SetShadowManager(shadowManager);
lf->IdentifyTextureHost(mTextureFactoryIdentifier);
ImageBridgeChild::IdentifyCompositorTextureHost(mTextureFactoryIdentifier);
gfx::VRManagerChild::IdentifyTextureHost(mTextureFactoryIdentifier);
}
mRemoteFrame = remoteFrame;
if (aLayersId != 0) {
@ -2997,6 +3004,7 @@ TabChild::CompositorUpdated(const TextureFactoryIdentifier& aNewIdentifier)
RefPtr<LayerManager> lm = mPuppetWidget->GetLayerManager();
ClientLayerManager* clm = lm->AsClientLayerManager();
MOZ_ASSERT(clm);
mTextureFactoryIdentifier = aNewIdentifier;
clm->UpdateTextureFactoryIdentifier(aNewIdentifier);

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

@ -584,7 +584,7 @@ PuppetWidget::GetLayerManager(PLayerTransactionChild* aShadowManager,
mLayerManager = new ClientLayerManager(this);
}
ShadowLayerForwarder* lf = mLayerManager->AsShadowForwarder();
if (!lf->HasShadowManager() && aShadowManager) {
if (lf && !lf->HasShadowManager() && aShadowManager) {
lf->SetShadowManager(aShadowManager);
}
return mLayerManager;
@ -594,7 +594,9 @@ LayerManager*
PuppetWidget::RecreateLayerManager(PLayerTransactionChild* aShadowManager)
{
mLayerManager = new ClientLayerManager(this);
mLayerManager->AsShadowForwarder()->SetShadowManager(aShadowManager);
if (ShadowLayerForwarder* lf = mLayerManager->AsShadowForwarder()) {
lf->SetShadowManager(aShadowManager);
}
return mLayerManager;
}

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

@ -1331,6 +1331,11 @@ void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
mInitialZoomConstraints.reset();
}
ShadowLayerForwarder* lf = lm->AsShadowForwarder();
// As long as we are creating a ClientLayerManager above lf must be non-null.
MOZ_ASSERT(lf);
if (lf) {
TextureFactoryIdentifier textureFactoryIdentifier;
PLayerTransactionChild* shadowManager = nullptr;
@ -1343,9 +1348,7 @@ void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
backendHints, 0, &textureFactoryIdentifier, &success);
}
ShadowLayerForwarder* lf = lm->AsShadowForwarder();
if (!success || !lf) {
if (!success) {
NS_WARNING("Failed to create an OMT compositor.");
DestroyCompositor();
mLayerManager = nullptr;
@ -1353,13 +1356,17 @@ void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
}
lf->SetShadowManager(shadowManager);
lm->UpdateTextureFactoryIdentifier(textureFactoryIdentifier);
if (ClientLayerManager* clm = lm->AsClientLayerManager()) {
clm->UpdateTextureFactoryIdentifier(textureFactoryIdentifier);
}
// Some popup or transparent widgets may use a different backend than the
// compositors used with ImageBridge and VR (and more generally web content).
if (WidgetTypeSupportsAcceleration()) {
ImageBridgeChild::IdentifyCompositorTextureHost(textureFactoryIdentifier);
gfx::VRManagerChild::IdentifyTextureHost(textureFactoryIdentifier);
}
}
WindowUsesOMTC();
mLayerManager = lm.forget();