Bug 1390741 - Use BasicCompositor if widget type does not support acceleration r=aosmond,kats

This commit is contained in:
sotaro 2017-11-03 16:38:34 +09:00
parent b9c6a1d730
commit bce40231ea
7 changed files with 32 additions and 10 deletions

View File

@ -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,

View File

@ -685,6 +685,7 @@ public:
return mParentIsActive;
}
const mozilla::layers::CompositorOptions& GetCompositorOptions() const;
bool AsyncPanZoomEnabled() const;
virtual ScreenIntSize GetInnerSize() override;

View File

@ -1477,6 +1477,7 @@ CompositorBridgeParent::NewCompositor(const nsTArray<LayersBackend>& aBackendHin
#endif
}
nsCString failureReason;
MOZ_ASSERT(!gfxVars::UseWebRender() || aBackendHints[i] == LayersBackend::LAYERS_BASIC);
if (compositor && compositor->Initialize(&failureReason)) {
if (failureReason.IsEmpty()){
failureReason = "SUCCESS";

View File

@ -877,6 +877,10 @@ LayerTransactionParent::Attach(Layer* aLayer,
TextureSourceProvider* provider =
static_cast<HostLayerManager*>(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;

View File

@ -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<CompositableHost> 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();
}

View File

@ -612,7 +612,7 @@ PuppetWidget::CreateRemoteLayerManager(const std::function<bool(LayerManager*)>&
{
RefPtr<LayerManager> lm;
MOZ_ASSERT(mTabChild);
if (gfxVars::UseWebRender()) {
if (mTabChild->GetCompositorOptions().UseWebRender()) {
lm = new WebRenderLayerManager(this);
} else {
lm = new ClientLayerManager(this);

View File

@ -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)