Bug 1569110 - Add ClientLayerManager::Initialize() r=nical

Some initialization handlings of ClientLayerManager exists in nsBaseWidget::CreateCompositor(). It is not good. Move them to ClientLayerManager::Initialize().

Differential Revision: https://phabricator.services.mozilla.com/D39476

--HG--
extra : moz-landing-system : lando
This commit is contained in:
sotaro 2019-07-26 09:31:57 +00:00
Родитель c62fb857b1
Коммит d8d05ff21a
3 изменённых файлов: 45 добавлений и 34 удалений

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

@ -83,6 +83,36 @@ ClientLayerManager::~ClientLayerManager() {
MOZ_COUNT_DTOR(ClientLayerManager);
}
bool ClientLayerManager::Initialize(
PCompositorBridgeChild* aCBChild, bool aShouldAccelerate,
TextureFactoryIdentifier* aTextureFactoryIdentifier) {
MOZ_ASSERT(mForwarder);
MOZ_ASSERT(aTextureFactoryIdentifier);
nsTArray<LayersBackend> backendHints;
gfxPlatform::GetPlatform()->GetCompositorBackends(aShouldAccelerate,
backendHints);
if (backendHints.IsEmpty()) {
gfxCriticalNote << "Failed to get backend hints.";
return false;
}
PLayerTransactionChild* shadowManager =
aCBChild->SendPLayerTransactionConstructor(backendHints, LayersId{0});
TextureFactoryIdentifier textureFactoryIdentifier;
shadowManager->SendGetTextureFactoryIdentifier(&textureFactoryIdentifier);
if (textureFactoryIdentifier.mParentBackend == LayersBackend::LAYERS_NONE) {
gfxCriticalNote << "Failed to create an OMT compositor.";
return false;
}
mForwarder->SetShadowManager(shadowManager);
UpdateTextureFactoryIdentifier(textureFactoryIdentifier);
*aTextureFactoryIdentifier = textureFactoryIdentifier;
return true;
}
void ClientLayerManager::Destroy() {
MOZ_DIAGNOSTIC_ASSERT(!mNotifyingWidgetListener,
"Try to avoid destroying widgets and layer managers "

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

@ -53,7 +53,8 @@ class ClientLayerManager final : public LayerManager,
public:
explicit ClientLayerManager(nsIWidget* aWidget);
bool Initialize(PCompositorBridgeChild* aCBChild, bool aShouldAccelerate,
TextureFactoryIdentifier* aTextureFactoryIdentifier);
void Destroy() override;
protected:

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

@ -1307,6 +1307,16 @@ already_AddRefed<LayerManager> nsBaseWidget::CreateCompositorSession(
gfx::GPUProcessManager::Get()->DisableWebRender(
wr::WebRenderError::INITIALIZE);
}
} else if (lm->AsClientLayerManager() && mCompositorSession) {
bool shouldAccelerate = ComputeShouldAccelerate();
TextureFactoryIdentifier textureFactoryIdentifier;
lm->AsClientLayerManager()->Initialize(
mCompositorSession->GetCompositorBridgeChild(), shouldAccelerate,
&textureFactoryIdentifier);
if (textureFactoryIdentifier.mParentBackend ==
LayersBackend::LAYERS_NONE) {
DestroyCompositor();
}
}
// We need to retry in a loop because the act of failing to create the
@ -1374,39 +1384,9 @@ void nsBaseWidget::CreateCompositor(int aWidth, int aHeight) {
LayersBackend::LAYERS_WR);
ImageBridgeChild::IdentifyCompositorTextureHost(textureFactoryIdentifier);
gfx::VRManagerChild::IdentifyTextureHost(textureFactoryIdentifier);
}
ShadowLayerForwarder* lf = lm->AsShadowForwarder();
if (lf) {
// lf is non-null if we are creating a ClientLayerManager above
TextureFactoryIdentifier textureFactoryIdentifier;
PLayerTransactionChild* shadowManager = nullptr;
nsTArray<LayersBackend> backendHints;
gfxPlatform::GetPlatform()->GetCompositorBackends(ComputeShouldAccelerate(),
backendHints);
bool success = false;
if (!backendHints.IsEmpty()) {
shadowManager = mCompositorBridgeChild->SendPLayerTransactionConstructor(
backendHints, LayersId{0});
if (shadowManager->SendGetTextureFactoryIdentifier(
&textureFactoryIdentifier) &&
textureFactoryIdentifier.mParentBackend !=
LayersBackend::LAYERS_NONE) {
success = true;
}
}
if (!success) {
NS_WARNING("Failed to create an OMT compositor.");
DestroyCompositor();
mLayerManager = nullptr;
return;
}
lf->SetShadowManager(shadowManager);
lm->UpdateTextureFactoryIdentifier(textureFactoryIdentifier);
} else if (lm->AsClientLayerManager()) {
TextureFactoryIdentifier textureFactoryIdentifier =
lm->GetTextureFactoryIdentifier();
// Some popup or transparent widgets may use a different backend than the
// compositors used with ImageBridge and VR (and more generally web
// content).