From c9bbaf820c278ea97f60b04cc76a61d303c27a8a Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Fri, 13 Jan 2017 15:16:51 -0500 Subject: [PATCH] Bug 1326421 - Add a compositor option for WebRender being enabled or not. r=dvander MozReview-Commit-ID: LeQRgKSn0Ql --- gfx/ipc/CompositorOptions.h | 7 ++++++- gfx/ipc/GfxMessageUtils.h | 4 +++- widget/nsBaseWidget.cpp | 6 +++--- widget/windows/nsWindow.cpp | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/gfx/ipc/CompositorOptions.h b/gfx/ipc/CompositorOptions.h index aca92f213af8..2d14b3c111f0 100644 --- a/gfx/ipc/CompositorOptions.h +++ b/gfx/ipc/CompositorOptions.h @@ -31,20 +31,25 @@ public: // This constructor needed for IPDL purposes, don't use it anywhere else. CompositorOptions() : mUseAPZ(false) + , mUseWebRender(false) { } - explicit CompositorOptions(bool aUseAPZ) + explicit CompositorOptions(bool aUseAPZ, + bool aUseWebRender) : mUseAPZ(aUseAPZ) + , mUseWebRender(aUseWebRender) { } bool UseAPZ() const { return mUseAPZ; } + bool UseWebRender() const { return mUseWebRender; } friend struct IPC::ParamTraits; private: bool mUseAPZ; + bool mUseWebRender; // Make sure to add new fields to the ParamTraits implementation }; diff --git a/gfx/ipc/GfxMessageUtils.h b/gfx/ipc/GfxMessageUtils.h index 8ec266b0d00c..c2f46296716c 100644 --- a/gfx/ipc/GfxMessageUtils.h +++ b/gfx/ipc/GfxMessageUtils.h @@ -1326,10 +1326,12 @@ struct ParamTraits static void Write(Message* aMsg, const paramType& aParam) { WriteParam(aMsg, aParam.mUseAPZ); + WriteParam(aMsg, aParam.mUseWebRender); } static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { - return ReadParam(aMsg, aIter, &aResult->mUseAPZ); + return ReadParam(aMsg, aIter, &aResult->mUseAPZ) + && ReadParam(aMsg, aIter, &aResult->mUseWebRender); } }; diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 292cba163326..2fc6920e8987 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -1298,15 +1298,15 @@ void nsBaseWidget::CreateCompositor(int aWidth, int aHeight) CreateCompositorVsyncDispatcher(); + CompositorOptions options(UseAPZ(), gfxPrefs::WebRenderEnabled()); + RefPtr lm; - if (gfxPrefs::WebRenderEnabled()) { + if (options.UseWebRender()) { lm = new WebRenderLayerManager(this); } else { lm = new ClientLayerManager(this); } - CompositorOptions options(UseAPZ()); - gfx::GPUProcessManager* gpu = gfx::GPUProcessManager::Get(); mCompositorSession = gpu->CreateTopLevelCompositor( this, diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 4ca37d32a7b8..cdbf9e6ee31c 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -3910,7 +3910,7 @@ nsWindow::GetLayerManager(PLayerTransactionChild* aShadowManager, reinterpret_cast(static_cast(this)), mTransparencyMode); // If we're not using the compositor, the options don't actually matter. - CompositorOptions options(false); + CompositorOptions options(false, false); mBasicLayersSurface = new InProcessWinCompositorWidget(initData, options, this); mCompositorWidgetDelegate = mBasicLayersSurface; mLayerManager = CreateBasicLayerManager();