From bce40231eacba55a6d0dbdf222ff482b5b1fbc71 Mon Sep 17 00:00:00 2001 From: sotaro Date: Fri, 3 Nov 2017 16:38:34 +0900 Subject: [PATCH] Bug 1390741 - Use BasicCompositor if widget type does not support acceleration r=aosmond,kats --- dom/ipc/TabChild.cpp | 10 +++++++++- dom/ipc/TabChild.h | 1 + gfx/layers/ipc/CompositorBridgeParent.cpp | 1 + gfx/layers/ipc/LayerTransactionParent.cpp | 4 ++++ gfx/layers/wr/WebRenderBridgeParent.cpp | 13 ++++++++++++- widget/PuppetWidget.cpp | 2 +- widget/nsBaseWidget.cpp | 11 ++++------- 7 files changed, 32 insertions(+), 10 deletions(-) diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 9d091474ed47..2cd11e8c97c5 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -465,6 +465,14 @@ TabChild::TabChild(nsIContentChild* aManager, } } +const CompositorOptions& +TabChild::GetCompositorOptions() const +{ + // If you're calling this before mCompositorOptions is set, well.. don't. + MOZ_ASSERT(mCompositorOptions); + return mCompositorOptions.ref(); +} + bool TabChild::AsyncPanZoomEnabled() const { @@ -2950,7 +2958,7 @@ TabChild::CreateRemoteLayerManager(mozilla::layers::PCompositorBridgeChild* aCom MOZ_ASSERT(aCompositorChild); bool success = false; - if (gfxVars::UseWebRender()) { + if (mCompositorOptions->UseWebRender()) { success = mPuppetWidget->CreateRemoteLayerManager([&] (LayerManager* aLayerManager) -> bool { MOZ_ASSERT(aLayerManager->AsWebRenderLayerManager()); return aLayerManager->AsWebRenderLayerManager()->Initialize(aCompositorChild, diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index efaca3d8d0ee..479393a4f719 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -685,6 +685,7 @@ public: return mParentIsActive; } + const mozilla::layers::CompositorOptions& GetCompositorOptions() const; bool AsyncPanZoomEnabled() const; virtual ScreenIntSize GetInnerSize() override; diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index d6e779ab9416..3eca62d62c67 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -1477,6 +1477,7 @@ CompositorBridgeParent::NewCompositor(const nsTArray& aBackendHin #endif } nsCString failureReason; + MOZ_ASSERT(!gfxVars::UseWebRender() || aBackendHints[i] == LayersBackend::LAYERS_BASIC); if (compositor && compositor->Initialize(&failureReason)) { if (failureReason.IsEmpty()){ failureReason = "SUCCESS"; diff --git a/gfx/layers/ipc/LayerTransactionParent.cpp b/gfx/layers/ipc/LayerTransactionParent.cpp index bf2f4124f599..f41791eeec85 100644 --- a/gfx/layers/ipc/LayerTransactionParent.cpp +++ b/gfx/layers/ipc/LayerTransactionParent.cpp @@ -877,6 +877,10 @@ LayerTransactionParent::Attach(Layer* aLayer, TextureSourceProvider* provider = static_cast(aLayer->Manager())->GetTextureSourceProvider(); + MOZ_ASSERT(!aCompositable->AsWebRenderImageHost()); + if (aCompositable->AsWebRenderImageHost()) { + gfxCriticalNote << "Use WebRenderImageHost at LayerTransactionParent."; + } if (!layer->SetCompositableHost(aCompositable)) { // not all layer types accept a compositable, see bug 967824 return false; diff --git a/gfx/layers/wr/WebRenderBridgeParent.cpp b/gfx/layers/wr/WebRenderBridgeParent.cpp index a957b9996278..d3896495bdf9 100644 --- a/gfx/layers/wr/WebRenderBridgeParent.cpp +++ b/gfx/layers/wr/WebRenderBridgeParent.cpp @@ -800,8 +800,13 @@ WebRenderBridgeParent::RecvAddPipelineIdForCompositable(const wr::PipelineId& aP if (!host) { return IPC_FAIL_NO_REASON(this); } - MOZ_ASSERT(host->AsWebRenderImageHost()); + WebRenderImageHost* wrHost = host->AsWebRenderImageHost(); + MOZ_ASSERT(wrHost); + if (!wrHost) { + gfxCriticalNote << "Incompatible CompositableHost at WebRenderBridgeParent."; + } + if (!wrHost) { return IPC_OK(); } @@ -843,6 +848,12 @@ WebRenderBridgeParent::RecvAddExternalImageIdForCompositable(const ExternalImage RefPtr host = FindCompositable(aHandle); WebRenderImageHost* wrHost = host->AsWebRenderImageHost(); + + MOZ_ASSERT(wrHost); + if (!wrHost) { + gfxCriticalNote << "Incompatible CompositableHost for external image at WebRenderBridgeParent."; + } + if (!wrHost) { return IPC_OK(); } diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index 73fbd307a36e..0784e750978c 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -612,7 +612,7 @@ PuppetWidget::CreateRemoteLayerManager(const std::function& { RefPtr lm; MOZ_ASSERT(mTabChild); - if (gfxVars::UseWebRender()) { + if (mTabChild->GetCompositorOptions().UseWebRender()) { lm = new WebRenderLayerManager(this); } else { lm = new ClientLayerManager(this); diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 3ffa16d17daa..c0694714c69d 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -1255,11 +1255,10 @@ nsBaseWidget::CreateCompositorSession(int aWidth, do { CreateCompositorVsyncDispatcher(); - bool enableWR = gfx::gfxVars::UseWebRender(); - if (enableWR && !WidgetTypeSupportsAcceleration()) { - // fall back to basic - break; - } + // If widget type does not supports acceleration, we use ClientLayerManager + // even when gfxVars::UseWebRender() is true. WebRender could coexist only + // with BasicCompositor. + bool enableWR = gfx::gfxVars::UseWebRender() && WidgetTypeSupportsAcceleration(); bool enableAPZ = UseAPZ(); CompositorOptions options(enableAPZ, enableWR); @@ -1303,8 +1302,6 @@ nsBaseWidget::CreateCompositorSession(int aWidth, return lm.forget(); } } while (true); - - return nullptr; } void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)