author | Matt Woodrow <mwoodrow@mozilla.com> |
Sun, 05 Sep 2021 22:36:45 +0000 (6 days ago) | |
changeset 591057 | 1b49e7328ae43c6565d167f4c391430575097fd3 |
parent 591056 | 8f3a50e16abc227d4ec698bf4a4126ea01d7ffc5 |
child 591058 | 63d82db58e2ced524acb4dab5687b273ca57f153 |
child 591061 | d6a45c5373e3e75ca7e4ebde681ca391833a2775 |
push id | 38764 |
push user | imoraru@mozilla.com |
push date | Mon, 06 Sep 2021 03:16:57 +0000 (5 days ago) |
treeherder | mozilla-central@1b49e7328ae4 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jrmuizel |
bugs | 1727682 |
milestone | 93.0a1 |
first release with | nightly linux32
1b49e7328ae4
/
93.0a1
/
20210906031657
/
files
nightly linux64
1b49e7328ae4
/
93.0a1
/
20210906031657
/
files
nightly mac
1b49e7328ae4
/
93.0a1
/
20210906031657
/
files
nightly win32
1b49e7328ae4
/
93.0a1
/
20210906031657
/
files
nightly win64
1b49e7328ae4
/
93.0a1
/
20210906031657
/
files
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
releases | nightly linux32
93.0a1
/
20210906031657
/
pushlog to previous
nightly linux64
93.0a1
/
20210906031657
/
pushlog to previous
nightly mac
93.0a1
/
20210906031657
/
pushlog to previous
nightly win32
93.0a1
/
20210906031657
/
pushlog to previous
nightly win64
93.0a1
/
20210906031657
/
pushlog to previous
|
--- a/dom/ipc/BrowserChild.cpp +++ b/dom/ipc/BrowserChild.cpp @@ -2873,22 +2873,21 @@ void BrowserChild::InitRenderingState( } } bool BrowserChild::CreateRemoteLayerManager( mozilla::layers::PCompositorBridgeChild* aCompositorChild) { MOZ_ASSERT(aCompositorChild); return mPuppetWidget->CreateRemoteLayerManager( - [&](LayerManager* aLayerManager) -> bool { - MOZ_ASSERT(aLayerManager->AsWebRenderLayerManager()); + [&](WebRenderLayerManager* aLayerManager) -> bool { nsCString error; - return aLayerManager->AsWebRenderLayerManager()->Initialize( - aCompositorChild, wr::AsPipelineId(mLayersId), - &mTextureFactoryIdentifier, error); + return aLayerManager->Initialize(aCompositorChild, + wr::AsPipelineId(mLayersId), + &mTextureFactoryIdentifier, error); }); } void BrowserChild::InitAPZState() { if (!mCompositorOptions->UseAPZ()) { return; } auto cbc = CompositorBridgeChild::Get();
--- a/gfx/ipc/GPUProcessManager.cpp +++ b/gfx/ipc/GPUProcessManager.cpp @@ -835,17 +835,17 @@ void GPUProcessManager::DestroyProcess() mVsyncBridge = nullptr; } CrashReporter::AnnotateCrashReport( CrashReporter::Annotation::GPUProcessStatus, "Destroyed"_ns); } already_AddRefed<CompositorSession> GPUProcessManager::CreateTopLevelCompositor( - nsBaseWidget* aWidget, LayerManager* aLayerManager, + nsBaseWidget* aWidget, WebRenderLayerManager* aLayerManager, CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions, bool aUseExternalSurfaceSize, const gfx::IntSize& aSurfaceSize, bool* aRetryOut) { MOZ_ASSERT(aRetryOut); LayersId layerTreeId = AllocateLayerTreeId(); EnsureProtocolsReady(); @@ -877,17 +877,17 @@ already_AddRefed<CompositorSession> GPUP } #endif // defined(MOZ_WIDGET_ANDROID) *aRetryOut = false; return session.forget(); } RefPtr<CompositorSession> GPUProcessManager::CreateRemoteSession( - nsBaseWidget* aWidget, LayerManager* aLayerManager, + nsBaseWidget* aWidget, WebRenderLayerManager* aLayerManager, const LayersId& aRootLayerTreeId, CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions, bool aUseExternalSurfaceSize, const gfx::IntSize& aSurfaceSize) { #ifdef MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING widget::CompositorWidgetInitData initData; aWidget->GetCompositorWidgetInitData(&initData); RefPtr<CompositorBridgeChild> child =
--- a/gfx/ipc/GPUProcessManager.h +++ b/gfx/ipc/GPUProcessManager.h @@ -33,17 +33,17 @@ class CompositorSession; class CompositorUpdateObserver; class PCompositorBridgeChild; class PCompositorManagerChild; class PImageBridgeChild; class PVideoBridgeParent; class RemoteCompositorSession; class InProcessCompositorSession; class UiCompositorControllerChild; -class LayerManager; +class WebRenderLayerManager; } // namespace layers namespace widget { class CompositorWidget; } // namespace widget namespace dom { class ContentParent; class BrowserParent; } // namespace dom @@ -64,17 +64,17 @@ class VsyncIOThreadHolder; class GPUProcessManager final : public GPUProcessHost::Listener { friend class layers::RemoteCompositorSession; friend class layers::InProcessCompositorSession; typedef layers::CompositorOptions CompositorOptions; typedef layers::CompositorSession CompositorSession; typedef layers::CompositorUpdateObserver CompositorUpdateObserver; typedef layers::IAPZCTreeManager IAPZCTreeManager; - typedef layers::LayerManager LayerManager; + typedef layers::WebRenderLayerManager WebRenderLayerManager; typedef layers::LayersId LayersId; typedef layers::PCompositorBridgeChild PCompositorBridgeChild; typedef layers::PCompositorManagerChild PCompositorManagerChild; typedef layers::PImageBridgeChild PImageBridgeChild; typedef layers::PVideoBridgeParent PVideoBridgeParent; typedef layers::RemoteCompositorSession RemoteCompositorSession; typedef layers::InProcessCompositorSession InProcessCompositorSession; typedef layers::UiCompositorControllerChild UiCompositorControllerChild; @@ -91,17 +91,17 @@ class GPUProcessManager final : public G bool IsGPUProcessLaunching(); // Ensure that GPU-bound methods can be used. If no GPU process is being // used, or one is launched and ready, this function returns immediately. // Otherwise it blocks until the GPU process has finished launching. bool EnsureGPUReady(); already_AddRefed<CompositorSession> CreateTopLevelCompositor( - nsBaseWidget* aWidget, LayerManager* aLayerManager, + nsBaseWidget* aWidget, WebRenderLayerManager* aLayerManager, CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions, bool aUseExternalSurfaceSize, const gfx::IntSize& aSurfaceSize, bool* aRetry); bool CreateContentBridges( base::ProcessId aOtherProcess, mozilla::ipc::Endpoint<PCompositorManagerChild>* aOutCompositor, mozilla::ipc::Endpoint<PImageBridgeChild>* aOutImageBridge, @@ -260,17 +260,17 @@ class GPUProcessManager final : public G void EnsureVRManager(); #if defined(MOZ_WIDGET_ANDROID) already_AddRefed<UiCompositorControllerChild> CreateUiCompositorController( nsBaseWidget* aWidget, const LayersId aId); #endif // defined(MOZ_WIDGET_ANDROID) RefPtr<CompositorSession> CreateRemoteSession( - nsBaseWidget* aWidget, LayerManager* aLayerManager, + nsBaseWidget* aWidget, WebRenderLayerManager* aLayerManager, const LayersId& aRootLayerTreeId, CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions, bool aUseExternalSurfaceSize, const gfx::IntSize& aSurfaceSize); DISALLOW_COPY_AND_ASSIGN(GPUProcessManager); class Observer final : public nsIObserver { public:
--- a/gfx/ipc/InProcessCompositorSession.cpp +++ b/gfx/ipc/InProcessCompositorSession.cpp @@ -26,17 +26,17 @@ InProcessCompositorSession::InProcessCom aParent->RootLayerTreeId()), mCompositorBridgeParent(aParent), mCompositorWidget(aCompositorWidget) { gfx::GPUProcessManager::Get()->RegisterInProcessSession(this); } /* static */ RefPtr<InProcessCompositorSession> InProcessCompositorSession::Create( - nsBaseWidget* aWidget, LayerManager* aLayerManager, + nsBaseWidget* aWidget, WebRenderLayerManager* aLayerManager, const LayersId& aRootLayerTreeId, CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions, bool aUseExternalSurfaceSize, const gfx::IntSize& aSurfaceSize, uint32_t aNamespace) { widget::CompositorWidgetInitData initData; aWidget->GetCompositorWidgetInitData(&initData); RefPtr<CompositorWidget> widget = CompositorWidget::CreateLocal(initData, aOptions, aWidget);
--- a/gfx/ipc/InProcessCompositorSession.h +++ b/gfx/ipc/InProcessCompositorSession.h @@ -11,24 +11,24 @@ #include "Units.h" class nsIWidget; namespace mozilla { namespace layers { class CompositorOptions; -class LayerManager; +class WebRenderLayerManager; // A CompositorSession where both the child and parent CompositorBridge reside // in the same process. class InProcessCompositorSession final : public CompositorSession { public: static RefPtr<InProcessCompositorSession> Create( - nsBaseWidget* baseWidget, LayerManager* aLayerManager, + nsBaseWidget* baseWidget, WebRenderLayerManager* aLayerManager, const LayersId& aRootLayerTreeId, CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions, bool aUseExternalSurfaceSize, const gfx::IntSize& aSurfaceSize, uint32_t aNamespace); CompositorBridgeParent* GetInProcessBridge() const override; void SetContentController(GeckoContentController* aController) override; nsIWidget* GetWidget() const; RefPtr<IAPZCTreeManager> GetAPZCTreeManager() const override;
--- a/gfx/layers/AnimationInfo.cpp +++ b/gfx/layers/AnimationInfo.cpp @@ -585,17 +585,17 @@ GroupAnimationsByProperty(const nsTArray } return groupedAnims; } bool AnimationInfo::AddAnimationsForProperty( nsIFrame* aFrame, const EffectSet* aEffects, const nsTArray<RefPtr<dom::Animation>>& aCompositorAnimations, const Maybe<TransformData>& aTransformData, nsCSSPropertyID aProperty, - Send aSendFlag, LayerManager* aLayerManager) { + Send aSendFlag, WebRenderLayerManager* aLayerManager) { bool addedAny = false; // Add from first to last (since last overrides) for (dom::Animation* anim : aCompositorAnimations) { if (!anim->IsRelevant()) { continue; } dom::KeyframeEffect* keyframeEffect = @@ -903,17 +903,17 @@ void AnimationInfo::AddNonAnimatingTrans default: MOZ_ASSERT_UNREACHABLE("Unsupported transform-like properties"); } } } void AnimationInfo::AddAnimationsForDisplayItem( nsIFrame* aFrame, nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem, - DisplayItemType aType, LayerManager* aLayerManager, + DisplayItemType aType, WebRenderLayerManager* aLayerManager, const Maybe<LayoutDevicePoint>& aPosition) { Send sendFlag = !aBuilder ? Send::NextTransaction : Send::Immediate; if (sendFlag == Send::NextTransaction) { ClearAnimationsForNextTransaction(); } else { ClearAnimations(); }
--- a/gfx/layers/AnimationInfo.h +++ b/gfx/layers/AnimationInfo.h @@ -34,17 +34,17 @@ namespace gfx { class Path; } // namespace gfx namespace layers { class Animation; class CompositorAnimations; class Layer; -class LayerManager; +class WebRenderLayerManager; struct CompositorAnimationData; struct PropertyAnimationGroup; class AnimationInfo final { typedef nsTArray<Animation> AnimationArray; public: AnimationInfo(); @@ -113,17 +113,17 @@ class AnimationInfo final { // The enumeration stops if |aCallback| returns false. static void EnumerateGenerationOnFrame( const nsIFrame* aFrame, const nsIContent* aContent, const CompositorAnimatableDisplayItemTypes& aDisplayItemTypes, AnimationGenerationCallback); void AddAnimationsForDisplayItem( nsIFrame* aFrame, nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem, - DisplayItemType aType, LayerManager* aLayerManager, + DisplayItemType aType, WebRenderLayerManager* aLayerManager, const Maybe<LayoutDevicePoint>& aPosition = Nothing()); private: enum class Send { NextTransaction, Immediate, }; void AddAnimationForProperty(nsIFrame* aFrame, @@ -131,17 +131,17 @@ class AnimationInfo final { dom::Animation* aAnimation, const Maybe<TransformData>& aTransformData, Send aSendFlag); bool AddAnimationsForProperty( nsIFrame* aFrame, const EffectSet* aEffects, const nsTArray<RefPtr<dom::Animation>>& aCompositorAnimations, const Maybe<TransformData>& aTransformData, nsCSSPropertyID aProperty, - Send aSendFlag, LayerManager* aLayerManager); + Send aSendFlag, WebRenderLayerManager* aLayerManager); void AddNonAnimatingTransformLikePropertiesStyles( const nsCSSPropertyIDSet& aNonAnimatingProperties, nsIFrame* aFrame, Send aSendFlag); protected: // mAnimations (and mPendingAnimations) are only set on the main thread. //
--- a/gfx/layers/ipc/CompositorBridgeChild.cpp +++ b/gfx/layers/ipc/CompositorBridgeChild.cpp @@ -11,17 +11,17 @@ #include "base/task.h" // for NewRunnableMethod, etc #include "mozilla/StaticPrefs_layers.h" #include "mozilla/layers/CompositorManagerChild.h" #include "mozilla/layers/ImageBridgeChild.h" #include "mozilla/layers/APZChild.h" #include "mozilla/layers/IAPZCTreeManager.h" #include "mozilla/layers/APZCTreeManagerChild.h" #include "mozilla/layers/CanvasChild.h" -#include "mozilla/layers/LayerManager.h" +#include "mozilla/layers/WebRenderLayerManager.h" #include "mozilla/layers/PTextureChild.h" #include "mozilla/layers/TextureClient.h" // for TextureClient #include "mozilla/layers/TextureClientPool.h" // for TextureClientPool #include "mozilla/layers/WebRenderBridgeChild.h" #include "mozilla/layers/SyncObject.h" // for SyncObjectClient #include "mozilla/gfx/gfxVars.h" #include "mozilla/gfx/GPUProcessManager.h" #include "mozilla/gfx/Logging.h" @@ -244,17 +244,17 @@ void CompositorBridgeChild::InitForConte mCanSend = true; mIdNamespace = aNamespace; sCompositorBridge = this; } void CompositorBridgeChild::InitForWidget(uint64_t aProcessToken, - LayerManager* aLayerManager, + WebRenderLayerManager* aLayerManager, uint32_t aNamespace) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aProcessToken); MOZ_ASSERT(aLayerManager); MOZ_ASSERT(aNamespace); mCanSend = true; mProcessToken = aProcessToken; @@ -313,17 +313,17 @@ mozilla::ipc::IPCResult CompositorBridge for (const auto& id : aTransactionIds) { if (mLayerManager) { MOZ_ASSERT(!aId.IsValid()); MOZ_ASSERT(mLayerManager->GetBackendType() == LayersBackend::LAYERS_CLIENT || mLayerManager->GetBackendType() == LayersBackend::LAYERS_WR); // Hold a reference to keep LayerManager alive. See Bug 1242668. - RefPtr<LayerManager> m = mLayerManager; + RefPtr<WebRenderLayerManager> m = mLayerManager; m->DidComposite(id, aCompositeStart, aCompositeEnd); } else if (aId.IsValid()) { RefPtr<dom::BrowserChild> child = dom::BrowserChild::GetFrom(aId); if (child) { child->DidComposite(id, aCompositeStart, aCompositeEnd); } } }
--- a/gfx/layers/ipc/CompositorBridgeChild.h +++ b/gfx/layers/ipc/CompositorBridgeChild.h @@ -40,21 +40,20 @@ class CompositorWidget; namespace layers { using mozilla::dom::BrowserChild; class IAPZCTreeManager; class APZCTreeManagerChild; class CanvasChild; -class ClientLayerManager; class CompositorBridgeParent; class CompositorManagerChild; class CompositorOptions; -class LayerManager; +class WebRenderLayerManager; class TextureClient; class TextureClientPool; struct FrameMetrics; class CompositorBridgeChild final : public PCompositorBridgeChild, public TextureForwarder { typedef nsTArray<AsyncParentMessageData> AsyncParentMessageArray; @@ -65,18 +64,18 @@ class CompositorBridgeChild final : publ explicit CompositorBridgeChild(CompositorManagerChild* aManager); /** * Initialize the singleton compositor bridge for a content process. */ void InitForContent(uint32_t aNamespace); - void InitForWidget(uint64_t aProcessToken, LayerManager* aLayerManager, - uint32_t aNamespace); + void InitForWidget(uint64_t aProcessToken, + WebRenderLayerManager* aLayerManager, uint32_t aNamespace); void Destroy(); static CompositorBridgeChild* Get(); static bool ChildProcessHasCompositorBridge(); // Returns whether the compositor is in the GPU process (false if in the UI @@ -241,17 +240,17 @@ class CompositorBridgeChild final : publ mozilla::ipc::IPCResult RecvCompositorOptionsChanged( const LayersId& aLayersId, const CompositorOptions& aNewOptions); uint64_t GetNextResourceId(); RefPtr<CompositorManagerChild> mCompositorManager; - RefPtr<LayerManager> mLayerManager; + RefPtr<WebRenderLayerManager> mLayerManager; uint32_t mIdNamespace; uint32_t mResourceId; // When not multi-process, hold a reference to the CompositorBridgeParent to // keep it alive. This reference should be null in multi-process. RefPtr<CompositorBridgeParent> mCompositorBridgeParent;
--- a/gfx/layers/ipc/CompositorManagerChild.cpp +++ b/gfx/layers/ipc/CompositorManagerChild.cpp @@ -110,19 +110,20 @@ bool CompositorManagerChild::CreateConte bridge->InitForContent(aNamespace); return true; } /* static */ already_AddRefed<CompositorBridgeChild> CompositorManagerChild::CreateWidgetCompositorBridge( - uint64_t aProcessToken, LayerManager* aLayerManager, uint32_t aNamespace, - CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions, - bool aUseExternalSurfaceSize, const gfx::IntSize& aSurfaceSize) { + uint64_t aProcessToken, WebRenderLayerManager* aLayerManager, + uint32_t aNamespace, CSSToLayoutDeviceScale aScale, + const CompositorOptions& aOptions, bool aUseExternalSurfaceSize, + const gfx::IntSize& aSurfaceSize) { MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); if (NS_WARN_IF(!sInstance || !sInstance->CanSend())) { return nullptr; } TimeDuration vsyncRate = gfxPlatform::GetPlatform() ->GetHardwareVsync() @@ -140,17 +141,17 @@ CompositorManagerChild::CreateWidgetComp bridge->InitForWidget(aProcessToken, aLayerManager, aNamespace); return bridge.forget(); } /* static */ already_AddRefed<CompositorBridgeChild> CompositorManagerChild::CreateSameProcessWidgetCompositorBridge( - LayerManager* aLayerManager, uint32_t aNamespace) { + WebRenderLayerManager* aLayerManager, uint32_t aNamespace) { MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); if (NS_WARN_IF(!sInstance || !sInstance->CanSend())) { return nullptr; } CompositorBridgeOptions options = SameProcessWidgetCompositorOptions();
--- a/gfx/layers/ipc/CompositorManagerChild.h +++ b/gfx/layers/ipc/CompositorManagerChild.h @@ -14,38 +14,39 @@ #include "mozilla/StaticPtr.h" // for StaticRefPtr #include "mozilla/layers/PCompositorManagerChild.h" namespace mozilla { namespace layers { class CompositorBridgeChild; class CompositorManagerParent; -class LayerManager; +class WebRenderLayerManager; class CompositorManagerChild : public PCompositorManagerChild { NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorManagerChild) public: static bool IsInitialized(uint64_t aProcessToken); static void InitSameProcess(uint32_t aNamespace, uint64_t aProcessToken); static bool Init(Endpoint<PCompositorManagerChild>&& aEndpoint, uint32_t aNamespace, uint64_t aProcessToken = 0); static void Shutdown(); static void OnGPUProcessLost(uint64_t aProcessToken); static bool CreateContentCompositorBridge(uint32_t aNamespace); static already_AddRefed<CompositorBridgeChild> CreateWidgetCompositorBridge( - uint64_t aProcessToken, LayerManager* aLayerManager, uint32_t aNamespace, - CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions, - bool aUseExternalSurfaceSize, const gfx::IntSize& aSurfaceSize); + uint64_t aProcessToken, WebRenderLayerManager* aLayerManager, + uint32_t aNamespace, CSSToLayoutDeviceScale aScale, + const CompositorOptions& aOptions, bool aUseExternalSurfaceSize, + const gfx::IntSize& aSurfaceSize); static already_AddRefed<CompositorBridgeChild> - CreateSameProcessWidgetCompositorBridge(LayerManager* aLayerManager, + CreateSameProcessWidgetCompositorBridge(WebRenderLayerManager* aLayerManager, uint32_t aNamespace); static CompositorManagerChild* GetInstance() { MOZ_ASSERT(NS_IsMainThread()); return sInstance; } bool CanSend() const {
--- a/gfx/layers/wr/WebRenderLayerManager.cpp +++ b/gfx/layers/wr/WebRenderLayerManager.cpp @@ -18,32 +18,34 @@ #include "mozilla/layers/StackingContextHelper.h" #include "mozilla/layers/TextureClient.h" #include "mozilla/layers/TransactionIdAllocator.h" #include "mozilla/layers/WebRenderBridgeChild.h" #include "mozilla/layers/UpdateImageHelper.h" #include "nsDisplayList.h" #include "nsLayoutUtils.h" #include "WebRenderCanvasRenderer.h" +#include "LayerUserData.h" #ifdef XP_WIN # include "gfxDWriteFonts.h" #endif namespace mozilla { using namespace gfx; namespace layers { WebRenderLayerManager::WebRenderLayerManager(nsIWidget* aWidget) : mWidget(aWidget), mLatestTransactionId{0}, mNeedsComposite(false), mIsFirstPaint(false), + mDestroyed(false), mTarget(nullptr), mPaintSequenceNumber(0), mWebRenderCommandBuilder(this) { MOZ_COUNT_CTOR(WebRenderLayerManager); mStateManager.mLayerManager = this; if (XRE_IsContentProcess() && StaticPrefs::gfx_webrender_enable_item_cache_AtStartup()) { @@ -132,18 +134,18 @@ void WebRenderLayerManager::Destroy() { void WebRenderLayerManager::DoDestroy(bool aIsSync) { MOZ_ASSERT(NS_IsMainThread()); if (IsDestroyed()) { return; } mDLBuilder = nullptr; - - LayerManager::Destroy(); + mUserData.Destroy(); + mPartialPrerenderedAnimations.Clear(); mStateManager.Destroy(); if (WrBridge()) { WrBridge()->Destroy(aIsSync); } mWebRenderCommandBuilder.Destroy(); @@ -161,16 +163,17 @@ void WebRenderLayerManager::DoDestroy(bo allocator->ClearPendingTransactions(); allocator->NotifyTransactionCompleted(id); }); NS_DispatchToMainThread(task.forget()); } // Forget the widget pointer in case we outlive our owning widget. mWidget = nullptr; + mDestroyed = true; } WebRenderLayerManager::~WebRenderLayerManager() { Destroy(); MOZ_COUNT_DTOR(WebRenderLayerManager); } CompositorBridgeChild* WebRenderLayerManager::GetCompositorBridgeChild() { @@ -315,24 +318,16 @@ bool WebRenderLayerManager::EndEmptyTran mTransactionIdAllocator->GetVsyncStart(), refreshStart, mTransactionStart, mURL); mTransactionStart = TimeStamp(); MakeSnapshotIfRequired(size); return true; } -void WebRenderLayerManager::EndTransaction(DrawPaintedLayerCallback aCallback, - void* aCallbackData, - EndTransactionFlags aFlags) { - // This should never get called, all callers should use - // EndTransactionWithoutLayer instead. - MOZ_ASSERT(false); -} - void WebRenderLayerManager::EndTransactionWithoutLayer( nsDisplayList* aDisplayList, nsDisplayListBuilder* aDisplayListBuilder, WrFiltersHolder&& aFilters, WebRenderBackgroundData* aBackground, const double aGeckoDLBuildTime) { AUTO_PROFILER_TRACING_MARKER("Paint", "RenderLayers", GRAPHICS); // Since we don't do repeat transactions right now, just set the time mAnimationReadyTime = TimeStamp::Now(); @@ -734,47 +729,62 @@ void WebRenderLayerManager::SendInvalidR WrBridge()->SendInvalidateRenderedFrame(); } } void WebRenderLayerManager::ScheduleComposite() { WrBridge()->SendScheduleComposite(); } -void WebRenderLayerManager::SetRoot(Layer* aLayer) { - // This should never get called - MOZ_ASSERT(false); -} - already_AddRefed<PersistentBufferProvider> WebRenderLayerManager::CreatePersistentBufferProvider( const gfx::IntSize& aSize, gfx::SurfaceFormat aFormat) { // Ensure devices initialization for canvas 2d if not remote. The devices are // lazily initialized with WebRender to reduce memory usage. if (!gfxPlatform::UseRemoteCanvas()) { gfxPlatform::GetPlatform()->EnsureDevicesInitialized(); } RefPtr<PersistentBufferProvider> provider = PersistentBufferProviderShared::Create(aSize, aFormat, AsKnowsCompositor()); if (provider) { return provider.forget(); } - return LayerManager::CreatePersistentBufferProvider(aSize, aFormat); + return WindowRenderer::CreatePersistentBufferProvider(aSize, aFormat); } void WebRenderLayerManager::ClearAsyncAnimations() { mStateManager.ClearAsyncAnimations(); } void WebRenderLayerManager::WrReleasedImages( const nsTArray<wr::ExternalImageKeyPair>& aPairs) { mStateManager.WrReleasedImages(aPairs); } void WebRenderLayerManager::GetFrameUniformity(FrameUniformityData* aOutData) { WrBridge()->SendGetFrameUniformity(aOutData); } +/*static*/ +void WebRenderLayerManager::LayerUserDataDestroy(void* data) { + delete static_cast<LayerUserData*>(data); +} + +UniquePtr<LayerUserData> WebRenderLayerManager::RemoveUserData(void* aKey) { + UniquePtr<LayerUserData> d(static_cast<LayerUserData*>( + mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey)))); + return d; +} + +std::unordered_set<ScrollableLayerGuid::ViewID> +WebRenderLayerManager::ClearPendingScrollInfoUpdate() { + std::unordered_set<ScrollableLayerGuid::ViewID> scrollIds( + mPendingScrollUpdates.Keys().cbegin(), + mPendingScrollUpdates.Keys().cend()); + mPendingScrollUpdates.Clear(); + return scrollIds; +} + } // namespace layers } // namespace mozilla
--- a/gfx/layers/wr/WebRenderLayerManager.h +++ b/gfx/layers/wr/WebRenderLayerManager.h @@ -48,108 +48,92 @@ namespace layers { class CompositorBridgeChild; class KnowsCompositor; class Layer; class PCompositorBridgeChild; class WebRenderBridgeChild; class WebRenderParentCommand; -class WebRenderLayerManager final : public LayerManager { +class WebRenderLayerManager final : public WindowRenderer { typedef nsTArray<RefPtr<Layer>> LayerRefArray; typedef nsTHashSet<RefPtr<WebRenderUserData>> WebRenderUserDataRefTable; public: explicit WebRenderLayerManager(nsIWidget* aWidget); bool Initialize(PCompositorBridgeChild* aCBChild, wr::PipelineId aLayersId, TextureFactoryIdentifier* aTextureFactoryIdentifier, nsCString& aError); void Destroy() override; + bool IsDestroyed() { return mDestroyed; } void DoDestroy(bool aIsSync); protected: virtual ~WebRenderLayerManager(); public: KnowsCompositor* AsKnowsCompositor() override; WebRenderLayerManager* AsWebRender() override { return this; } - WebRenderLayerManager* AsWebRenderLayerManager() override { return this; } CompositorBridgeChild* GetCompositorBridgeChild() override; // WebRender can handle images larger than the max texture size via tiling. int32_t GetMaxTextureSize() const override { return INT32_MAX; } - bool BeginTransactionWithTarget(gfxContext* aTarget, - const nsCString& aURL) override; + bool BeginTransactionWithTarget(gfxContext* aTarget, const nsCString& aURL); bool BeginTransaction(const nsCString& aURL) override; bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT) override; void EndTransactionWithoutLayer(nsDisplayList* aDisplayList, nsDisplayListBuilder* aDisplayListBuilder, WrFiltersHolder&& aFilters, WebRenderBackgroundData* aBackground, const double aGeckoDLBuildTime); - void EndTransaction(DrawPaintedLayerCallback aCallback, void* aCallbackData, - EndTransactionFlags aFlags = END_DEFAULT) override; LayersBackend GetBackendType() override { return LayersBackend::LAYERS_WR; } void GetBackendName(nsAString& name) override; - const char* Name() const override { return "WebRender"; } - - void SetRoot(Layer* aLayer) override; - - already_AddRefed<PaintedLayer> CreatePaintedLayer() override { - return nullptr; - } - already_AddRefed<ContainerLayer> CreateContainerLayer() override { - return nullptr; - } - already_AddRefed<ImageLayer> CreateImageLayer() override { return nullptr; } - already_AddRefed<ColorLayer> CreateColorLayer() override { return nullptr; } - already_AddRefed<CanvasLayer> CreateCanvasLayer() override { return nullptr; } bool NeedsWidgetInvalidation() override { return false; } - void SetLayersObserverEpoch(LayersObserverEpoch aEpoch) override; + void SetLayersObserverEpoch(LayersObserverEpoch aEpoch); void DidComposite(TransactionId aTransactionId, const mozilla::TimeStamp& aCompositeStart, - const mozilla::TimeStamp& aCompositeEnd) override; + const mozilla::TimeStamp& aCompositeEnd); - void ClearCachedResources(Layer* aSubtree = nullptr) override; + void ClearCachedResources(Layer* aSubtree = nullptr); void UpdateTextureFactoryIdentifier( - const TextureFactoryIdentifier& aNewIdentifier) override; - TextureFactoryIdentifier GetTextureFactoryIdentifier() override; + const TextureFactoryIdentifier& aNewIdentifier); + TextureFactoryIdentifier GetTextureFactoryIdentifier(); - void SetTransactionIdAllocator(TransactionIdAllocator* aAllocator) override; - TransactionId GetLastTransactionId() override; + void SetTransactionIdAllocator(TransactionIdAllocator* aAllocator); + TransactionId GetLastTransactionId(); - void AddDidCompositeObserver(DidCompositeObserver* aObserver) override; - void RemoveDidCompositeObserver(DidCompositeObserver* aObserver) override; + void AddDidCompositeObserver(DidCompositeObserver* aObserver); + void RemoveDidCompositeObserver(DidCompositeObserver* aObserver); void FlushRendering() override; void WaitOnTransactionProcessed() override; - void SendInvalidRegion(const nsIntRegion& aRegion) override; + void SendInvalidRegion(const nsIntRegion& aRegion); - void ScheduleComposite() override; + void ScheduleComposite(); - void SetNeedsComposite(bool aNeedsComposite) override { + void SetNeedsComposite(bool aNeedsComposite) { mNeedsComposite = aNeedsComposite; } - bool NeedsComposite() const override { return mNeedsComposite; } - void SetIsFirstPaint() override { mIsFirstPaint = true; } - bool GetIsFirstPaint() const override { return mIsFirstPaint; } - void SetFocusTarget(const FocusTarget& aFocusTarget) override; + bool NeedsComposite() const { return mNeedsComposite; } + void SetIsFirstPaint() { mIsFirstPaint = true; } + bool GetIsFirstPaint() const { return mIsFirstPaint; } + void SetFocusTarget(const FocusTarget& aFocusTarget); already_AddRefed<PersistentBufferProvider> CreatePersistentBufferProvider( const gfx::IntSize& aSize, gfx::SurfaceFormat aFormat) override; - bool AsyncPanZoomEnabled() const override; + bool AsyncPanZoomEnabled() const; // adds an imagekey to a list of keys that will be discarded on the next // transaction or destruction void DiscardImages(); void DiscardLocalImages(); void ClearAsyncAnimations(); void WrReleasedImages(const nsTArray<wr::ExternalImageKeyPair>& aPairs); @@ -192,16 +176,48 @@ class WebRenderLayerManager final : publ void GetFrameUniformity(FrameUniformityData* aOutData) override; void RegisterPayloads(const nsTArray<CompositionPayload>& aPayload) { mPayload.AppendElements(aPayload); MOZ_ASSERT(mPayload.Length() < 10000); } + static void LayerUserDataDestroy(void* data); + /** + * This setter can be used anytime. The user data for all keys is + * initially null. Ownership pases to the layer manager. + */ + void SetUserData(void* aKey, LayerUserData* aData) { + mUserData.Add(static_cast<gfx::UserDataKey*>(aKey), aData, + LayerUserDataDestroy); + } + /** + * This can be used anytime. Ownership passes to the caller! + */ + UniquePtr<LayerUserData> RemoveUserData(void* aKey); + + /** + * This getter can be used anytime. + */ + bool HasUserData(void* aKey) { + return mUserData.Has(static_cast<gfx::UserDataKey*>(aKey)); + } + /** + * This getter can be used anytime. Ownership is retained by the layer + * manager. + */ + LayerUserData* GetUserData(void* aKey) const { + return static_cast<LayerUserData*>( + mUserData.Get(static_cast<gfx::UserDataKey*>(aKey))); + } + + std::unordered_set<ScrollableLayerGuid::ViewID> + ClearPendingScrollInfoUpdate(); + private: /** * Take a snapshot of the parent context, and copy * it into mTarget. */ void MakeSnapshotIfRequired(LayoutDeviceIntSize aSize); private: @@ -209,22 +225,25 @@ class WebRenderLayerManager final : publ RefPtr<WebRenderBridgeChild> mWrChild; RefPtr<TransactionIdAllocator> mTransactionIdAllocator; TransactionId mLatestTransactionId; nsTArray<DidCompositeObserver*> mDidCompositeObservers; + gfx::UserData mUserData; + // This holds the scroll data that we need to send to the compositor for // APZ to do it's job WebRenderScrollData mScrollData; bool mNeedsComposite; bool mIsFirstPaint; + bool mDestroyed; FocusTarget mFocusTarget; // The payload associated with currently pending painting work, for // client layer managers that typically means payload that is part of the // 'upcoming transaction', for HostLayerManagers this typically means // what has been included in received transactions to be presented on the // next composite. // IMPORTANT: Clients should take care to clear this or risk it slowly @@ -247,14 +266,16 @@ class WebRenderLayerManager final : publ TimeStamp mTransactionStart; nsCString mURL; WebRenderCommandBuilder mWebRenderCommandBuilder; RenderRootStateManager mStateManager; DisplayItemCache mDisplayItemCache; UniquePtr<wr::DisplayListBuilder> mDLBuilder; + + ScrollUpdatesMap mPendingScrollUpdates; }; } // namespace layers } // namespace mozilla #endif /* GFX_WEBRENDERLAYERMANAGER_H */
--- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -5038,18 +5038,18 @@ already_AddRefed<SourceSurface> PresShel for (const UniquePtr<RangePaintInfo>& rangeInfo : aItems) { // the display lists paint relative to the offset from the reference // frame, so account for that translation too: gfxPoint rootOffset = nsLayoutUtils::PointToGfxPoint( rangeInfo->mRootOffset, pc->AppUnitsPerDevPixel()); ctx->SetMatrixDouble(initialTM.PreTranslate(rootOffset)); aArea.MoveBy(-rangeInfo->mRootOffset.x, -rangeInfo->mRootOffset.y); nsRegion visible(aArea); - RefPtr<LayerManager> layerManager = rangeInfo->mList.PaintRoot( - &rangeInfo->mBuilder, ctx, nsDisplayList::PAINT_DEFAULT, Nothing()); + rangeInfo->mList.PaintRoot(&rangeInfo->mBuilder, ctx, + nsDisplayList::PAINT_DEFAULT, Nothing()); aArea.MoveBy(rangeInfo->mRootOffset.x, rangeInfo->mRootOffset.y); } // restore the old selection display state frameSelection->SetDisplaySelection(oldDisplaySelection); return dt->Snapshot(); } @@ -6370,18 +6370,18 @@ void PresShell::Paint(nsView* aViewToPai if (renderer->GetBackendType() == layers::LayersBackend::LAYERS_WR) { LayoutDeviceRect bounds = LayoutDeviceRect::FromAppUnits( presContext->GetVisibleArea(), presContext->AppUnitsPerDevPixel()); WebRenderBackgroundData data(wr::ToLayoutRect(bounds), wr::ToColorF(ToDeviceColor(bgcolor))); WrFiltersHolder wrFilters; layerManager->SetTransactionIdAllocator(presContext->RefreshDriver()); - layerManager->AsWebRenderLayerManager()->EndTransactionWithoutLayer( - nullptr, nullptr, std::move(wrFilters), &data, 0); + layerManager->EndTransactionWithoutLayer(nullptr, nullptr, + std::move(wrFilters), &data, 0); return; } FallbackRenderer* fallback = renderer->AsFallback(); MOZ_ASSERT(fallback); if (aFlags & PaintFlags::PaintComposite) { nsIntRect bounds = presContext->GetVisibleArea().ToOutsidePixels(
--- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -1063,32 +1063,17 @@ static void DoApplyRenderingChangeToTree } } if ((aChange & nsChangeHint_UpdateTransformLayer) && aFrame->IsTransformed()) { // Note: All the transform-like properties should map to the same // layer activity index, so does the restyle count. Therefore, using // eCSSProperty_transform should be fine. ActiveLayerTracker::NotifyRestyle(aFrame, eCSSProperty_transform); - // If we're not already going to do an invalidating paint, see - // if we can get away with only updating the transform on a - // layer for this frame, and not scheduling an invalidating - // paint. - if (!needInvalidatingPaint) { - nsDisplayItem::Layer* layer; - needInvalidatingPaint |= !aFrame->TryUpdateTransformOnly(&layer); - - if (!needInvalidatingPaint) { - // Since we're not going to paint, we need to resend animation - // data to the layer. - MOZ_ASSERT(layer, "this can't happen if there's no layer"); - nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer( - layer, nullptr, nullptr, aFrame, DisplayItemType::TYPE_TRANSFORM); - } - } + needInvalidatingPaint = true; } if (aChange & nsChangeHint_ChildrenOnlyTransform) { needInvalidatingPaint = true; nsIFrame* childFrame = GetFrameForChildrenOnlyTransformHint(aFrame) ->PrincipalChildList() .FirstChild(); for (; childFrame; childFrame = childFrame->GetNextSibling()) { // Note: All the transform-like properties should map to the same
--- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -2981,49 +2981,16 @@ static void ApplyEffectsUpdates( const nsTHashMap<nsPtrHashKey<RemoteBrowser>, EffectsInfo>& aUpdates) { for (const auto& entry : aUpdates) { auto* browser = entry.GetKey(); const auto& update = entry.GetData(); browser->UpdateEffects(update); } } -static void LogPaintedPixelCount(LayerManager* aLayerManager, - const TimeStamp aPaintStart) { - static std::vector<std::pair<TimeStamp, uint32_t>> history; - - const TimeStamp now = TimeStamp::Now(); - const double rasterizeTime = (now - aPaintStart).ToMilliseconds(); - - const uint32_t pixelCount = aLayerManager->GetAndClearPaintedPixelCount(); - if (pixelCount) { - history.push_back(std::make_pair(now, pixelCount)); - } - - uint32_t paintedInLastSecond = 0; - for (auto i = history.begin(); i != history.end(); i++) { - if ((now - i->first).ToMilliseconds() > 1000.0f) { - // more than 1000ms ago, don't count it - continue; - } - - if (paintedInLastSecond == 0) { - // This is the first one in the last 1000ms, so drop everything earlier - history.erase(history.begin(), i); - i = history.begin(); - } - - paintedInLastSecond += i->second; - MOZ_ASSERT(paintedInLastSecond); // all historical pixel counts are > 0 - } - - printf_stderr("Painted %u pixels in %fms (%u in the last 1000ms)\n", - pixelCount, rasterizeTime, paintedInLastSecond); -} - static void DumpBeforePaintDisplayList(UniquePtr<std::stringstream>& aStream, nsDisplayListBuilder* aBuilder, nsDisplayList* aList, const nsRect& aVisibleRect) { #ifdef MOZ_DUMP_PAINTING if (gfxEnv::DumpPaintToFile()) { nsCString string("dump-"); // Include the process ID in the dump file name, to make sure that in an @@ -3064,18 +3031,17 @@ static void DumpBeforePaintDisplayList(U // messages dumped by PaintRoot below. fprint_stderr(gfxUtils::sDumpPaintFile, *aStream); aStream = MakeUnique<std::stringstream>(); } } static void DumpAfterPaintDisplayList(UniquePtr<std::stringstream>& aStream, nsDisplayListBuilder* aBuilder, - nsDisplayList* aList, - LayerManager* aManager) { + nsDisplayList* aList) { *aStream << "Painting --- after optimization:\n"; nsIFrame::PrintDisplayList(aBuilder, *aList, *aStream, gfxEnv::DumpPaintToFile()); fprint_stderr(gfxUtils::sDumpPaintFile, *aStream); #ifdef MOZ_DUMP_PAINTING if (gfxEnv::DumpPaintToFile()) { @@ -3083,19 +3049,16 @@ static void DumpAfterPaintDisplayList(Un } if (gfxEnv::DumpPaintToFile()) { fclose(gfxUtils::sDumpPaintFile); } #endif std::stringstream lsStream; nsIFrame::PrintDisplayList(aBuilder, *aList, lsStream); - if (aManager && aManager->GetRoot()) { - aManager->GetRoot()->SetDisplayListLog(lsStream.str().c_str()); - } } struct TemporaryDisplayListBuilder { TemporaryDisplayListBuilder(nsIFrame* aFrame, nsDisplayListBuilderMode aBuilderMode, const bool aBuildCaret) : mBuilder(aFrame, aBuilderMode, aBuildCaret) {} @@ -3472,31 +3435,26 @@ void nsLayoutUtils::PaintFrame(gfxContex #ifdef PRINT_HITTESTINFO_STATS if (XRE_IsContentProcess()) { PrintHitTestInfoStats(list); } #endif TimeStamp paintStart = TimeStamp::Now(); - RefPtr<LayerManager> layerManager = list->PaintRoot( - builder, aRenderingContext, flags, Some(geckoDLBuildTime)); + list->PaintRoot(builder, aRenderingContext, flags, Some(geckoDLBuildTime)); Telemetry::AccumulateTimeDelta(Telemetry::PAINT_RASTERIZE_TIME, paintStart); if (builder->IsPaintingToWindow()) { presShell->EndPaint(); } builder->Check(); - if (StaticPrefs::gfx_logging_painted_pixel_count_enabled()) { - LogPaintedPixelCount(layerManager, paintStart); - } - if (consoleNeedsDisplayList) { - DumpAfterPaintDisplayList(ss, builder, list, layerManager); + DumpAfterPaintDisplayList(ss, builder, list); } #ifdef MOZ_DUMP_PAINTING gfxUtils::sDumpPaintFile = savedDumpFile; #endif // Update the widget's opaque region information. This sets // glass boundaries on Windows. Also set up the window dragging region. @@ -8380,24 +8338,22 @@ nsRect nsLayoutUtils::CalculateExpandedS scrollableRect.y = std::max( 0, scrollableRect.y - (compSize.height - scrollableRect.height)); scrollableRect.height = compSize.height; } return scrollableRect; } /* static */ -void nsLayoutUtils::DoLogTestDataForPaint(LayerManager* aManager, +void nsLayoutUtils::DoLogTestDataForPaint(WebRenderLayerManager* aManager, ViewID aScrollId, const std::string& aKey, const std::string& aValue) { MOZ_ASSERT(nsLayoutUtils::IsAPZTestLoggingEnabled(), "don't call me"); - if (WebRenderLayerManager* wrlm = aManager->AsWebRenderLayerManager()) { - wrlm->LogTestDataForCurrentPaint(aScrollId, aKey, aValue); - } + aManager->LogTestDataForCurrentPaint(aScrollId, aKey, aValue); } void nsLayoutUtils::LogAdditionalTestData(nsDisplayListBuilder* aBuilder, const std::string& aKey, const std::string& aValue) { WebRenderLayerManager* manager = aBuilder->GetWidgetLayerManager(nullptr); if (!manager) { return; @@ -8580,17 +8536,17 @@ bool nsLayoutUtils::CanScrollOriginClobb return true; } } /* static */ ScrollMetadata nsLayoutUtils::ComputeScrollMetadata( const nsIFrame* aForFrame, const nsIFrame* aScrollFrame, nsIContent* aContent, const nsIFrame* aReferenceFrame, - LayerManager* aLayerManager, ViewID aScrollParentId, + WebRenderLayerManager* aLayerManager, ViewID aScrollParentId, const nsSize& aScrollPortSize, const Maybe<nsRect>& aClipRect, bool aIsRootContent) { const nsPresContext* presContext = aForFrame->PresContext(); int32_t auPerDevPixel = presContext->AppUnitsPerDevPixel(); PresShell* presShell = presContext->GetPresShell(); ScrollMetadata metadata; FrameMetrics& metrics = metadata.GetMetrics(); @@ -8953,17 +8909,17 @@ ScrollMetadata nsLayoutUtils::ComputeScr metadata.SetPrefersReducedMotion( Gecko_MediaFeatures_PrefersReducedMotion(document)); return metadata; } /*static*/ Maybe<ScrollMetadata> nsLayoutUtils::GetRootMetadata( - nsDisplayListBuilder* aBuilder, LayerManager* aLayerManager, + nsDisplayListBuilder* aBuilder, WebRenderLayerManager* aLayerManager, const std::function<bool(ViewID& aScrollId)>& aCallback) { nsIFrame* frame = aBuilder->RootReferenceFrame(); nsPresContext* presContext = frame->PresContext(); PresShell* presShell = presContext->PresShell(); Document* document = presShell->GetDocument(); // There is one case where we want the root container layer to have metrics. // If the parent process is using XUL windows, there is no root scrollframe,
--- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -107,16 +107,17 @@ class ImageIntRegion; struct Resolution; } // namespace image namespace layers { struct FrameMetrics; struct ScrollMetadata; class Image; class StackingContextHelper; class Layer; +class WebRenderLayerManager; } // namespace layers } // namespace mozilla // Flags to customize the behavior of nsLayoutUtils::DrawString. enum class DrawStringFlags { Default = 0x0, ForceHorizontal = 0x1 // Forces the text to be drawn horizontally. @@ -2700,31 +2701,31 @@ class nsLayoutUtils { /** * Log a key/value pair for APZ testing during a paint. * @param aManager The data will be written to the APZTestData associated * with this layer manager. * @param aScrollId Identifies the scroll frame to which the data pertains. * @param aKey The key under which to log the data. * @param aValue The value of the data to be logged. */ - static void LogTestDataForPaint(mozilla::layers::LayerManager* aManager, - ViewID aScrollId, const std::string& aKey, - const std::string& aValue) { + static void LogTestDataForPaint( + mozilla::layers::WebRenderLayerManager* aManager, ViewID aScrollId, + const std::string& aKey, const std::string& aValue) { DoLogTestDataForPaint(aManager, aScrollId, aKey, aValue); } /** * A convenience overload of LogTestDataForPaint() that accepts any type * as the value, and passes it through mozilla::ToString() to obtain a string * value. The type passed must support streaming to an std::ostream. */ template <typename Value> - static void LogTestDataForPaint(mozilla::layers::LayerManager* aManager, - ViewID aScrollId, const std::string& aKey, - const Value& aValue) { + static void LogTestDataForPaint( + mozilla::layers::WebRenderLayerManager* aManager, ViewID aScrollId, + const std::string& aKey, const Value& aValue) { DoLogTestDataForPaint(aManager, aScrollId, aKey, mozilla::ToString(aValue)); } /** * Calculate a basic FrameMetrics with enough fields set to perform some * layout calculations. The fields set are dev-to-css ratio, pres shell * resolution, cumulative resolution, zoom, composition size, root * composition size, scroll offset and scrollable rect. @@ -2755,28 +2756,28 @@ class nsLayoutUtils { * returns true for those, and returns false for other origins like APZ * itself, or scroll position updates from the history restore code. */ static bool CanScrollOriginClobberApz(ScrollOrigin aScrollOrigin); static ScrollMetadata ComputeScrollMetadata( const nsIFrame* aForFrame, const nsIFrame* aScrollFrame, nsIContent* aContent, const nsIFrame* aReferenceFrame, - mozilla::layers::LayerManager* aLayerManager, ViewID aScrollParentId, - const nsSize& aScrollPortSize, const mozilla::Maybe<nsRect>& aClipRect, - bool aIsRoot); + mozilla::layers::WebRenderLayerManager* aLayerManager, + ViewID aScrollParentId, const nsSize& aScrollPortSize, + const mozilla::Maybe<nsRect>& aClipRect, bool aIsRoot); /** * Returns the metadata to put onto the root layer of a layer tree, if one is * needed. The last argument is a callback function to check if the caller * already has a metadata for a given scroll id. */ static mozilla::Maybe<ScrollMetadata> GetRootMetadata( nsDisplayListBuilder* aBuilder, - mozilla::layers::LayerManager* aLayerManager, + mozilla::layers::WebRenderLayerManager* aLayerManager, const std::function<bool(ViewID& aScrollId)>& aCallback); /** * If the given scroll frame needs an area excluded from its composition * bounds due to scrollbars, return that area, otherwise return an empty * margin. * There is no need to exclude scrollbars in the following cases: * - If the scroll frame is not the RCD-RSF; in that case, the composition @@ -3004,19 +3005,19 @@ class nsLayoutUtils { * Note CSS clip or clip-path isn't accounted for. **/ static nsIFrame* GetNearestOverflowClipFrame(nsIFrame* aFrame); private: /** * Helper function for LogTestDataForPaint(). */ - static void DoLogTestDataForPaint(mozilla::layers::LayerManager* aManager, - ViewID aScrollId, const std::string& aKey, - const std::string& aValue); + static void DoLogTestDataForPaint( + mozilla::layers::WebRenderLayerManager* aManager, ViewID aScrollId, + const std::string& aKey, const std::string& aValue); static bool IsAPZTestLoggingEnabled(); static void ConstrainToCoordValues(gfxFloat& aStart, gfxFloat& aSize); static void ConstrainToCoordValues(float& aStart, float& aSize); }; MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(nsLayoutUtils::PaintFrameFlags)
--- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -4493,17 +4493,18 @@ void ScrollFrameHelper::NotifyApzTransac mApzAnimationRequested = IsLastScrollUpdateAnimating(); mScrollUpdates.Clear(); if (mIsRoot) { mOuter->PresShell()->SetResolutionUpdated(false); } } Maybe<ScrollMetadata> ScrollFrameHelper::ComputeScrollMetadata( - LayerManager* aLayerManager, const nsIFrame* aContainerReferenceFrame, + WebRenderLayerManager* aLayerManager, + const nsIFrame* aContainerReferenceFrame, const DisplayItemClip* aClip) const { if (!mWillBuildScrollableLayer) { return Nothing(); } Maybe<nsRect> parentLayerClip; if (aClip && mAddClipRectToLayer) { parentLayerClip = Some(aClip->GetClipRect());
--- a/layout/generic/nsGfxScrollFrame.h +++ b/layout/generic/nsGfxScrollFrame.h @@ -33,32 +33,32 @@ class nsIContent; class nsAtom; class nsIScrollPositionListener; namespace mozilla { class PresShell; struct ScrollReflowInput; namespace layers { class Layer; -class LayerManager; +class WebRenderLayerManager; } // namespace layers namespace layout { class ScrollbarActivity; } // namespace layout class ScrollFrameHelper : public nsIReflowCallback { public: typedef nsIFrame::Sides Sides; typedef mozilla::CSSIntPoint CSSIntPoint; typedef mozilla::layout::ScrollbarActivity ScrollbarActivity; typedef mozilla::layers::FrameMetrics FrameMetrics; typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid; typedef mozilla::layers::ScrollSnapInfo ScrollSnapInfo; typedef mozilla::layers::Layer Layer; - typedef mozilla::layers::LayerManager LayerManager; + typedef mozilla::layers::WebRenderLayerManager WebRenderLayerManager; typedef mozilla::layout::ScrollAnchorContainer ScrollAnchorContainer; using Element = mozilla::dom::Element; class AsyncScroll; class AsyncSmoothMSDScroll; ScrollFrameHelper(nsContainerFrame* aOuter, bool aIsRoot); ~ScrollFrameHelper(); @@ -479,17 +479,18 @@ class ScrollFrameHelper : public nsIRefl bool IsLastScrollUpdateAnimating() const; using IncludeApzAnimation = nsIScrollableFrame::IncludeApzAnimation; bool IsScrollAnimating(IncludeApzAnimation = IncludeApzAnimation::Yes) const; void ResetScrollInfoIfNeeded(const ScrollGeneration& aGeneration, bool aApzAnimationInProgress); bool WantAsyncScroll() const; Maybe<mozilla::layers::ScrollMetadata> ComputeScrollMetadata( - LayerManager* aLayerManager, const nsIFrame* aContainerReferenceFrame, + WebRenderLayerManager* aLayerManager, + const nsIFrame* aContainerReferenceFrame, const mozilla::DisplayItemClip* aClip) const; // nsIScrollbarMediator void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection, nsIScrollbarMediator::ScrollSnapMode aSnap = nsIScrollbarMediator::DISABLE_SNAP); void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection, nsIScrollbarMediator::ScrollSnapMode aSnap = nsIScrollbarMediator::DISABLE_SNAP); @@ -1078,17 +1079,18 @@ class nsHTMLScrollFrame : public nsConta } bool HasScrollUpdates() const final { return mHelper.HasScrollUpdates(); } void ResetScrollInfoIfNeeded(const mozilla::ScrollGeneration& aGeneration, bool aApzAnimationInProgress) final { mHelper.ResetScrollInfoIfNeeded(aGeneration, aApzAnimationInProgress); } bool WantAsyncScroll() const final { return mHelper.WantAsyncScroll(); } mozilla::Maybe<mozilla::layers::ScrollMetadata> ComputeScrollMetadata( - LayerManager* aLayerManager, const nsIFrame* aContainerReferenceFrame, + mozilla::layers::WebRenderLayerManager* aLayerManager, + const nsIFrame* aContainerReferenceFrame, const mozilla::DisplayItemClip* aClip) const final { return mHelper.ComputeScrollMetadata(aLayerManager, aContainerReferenceFrame, aClip); } void MarkScrollbarsDirtyForReflow() const final { mHelper.MarkScrollbarsDirtyForReflow(); } void InvalidateVerticalScrollbar() const final { @@ -1555,17 +1557,18 @@ class nsXULScrollFrame final : public ns } bool HasScrollUpdates() const final { return mHelper.HasScrollUpdates(); } void ResetScrollInfoIfNeeded(const mozilla::ScrollGeneration& aGeneration, bool aApzAnimationInProgress) final { mHelper.ResetScrollInfoIfNeeded(aGeneration, aApzAnimationInProgress); } bool WantAsyncScroll() const final { return mHelper.WantAsyncScroll(); } mozilla::Maybe<mozilla::layers::ScrollMetadata> ComputeScrollMetadata( - LayerManager* aLayerManager, const nsIFrame* aContainerReferenceFrame, + mozilla::layers::WebRenderLayerManager* aLayerManager, + const nsIFrame* aContainerReferenceFrame, const mozilla::DisplayItemClip* aClip) const final { return mHelper.ComputeScrollMetadata(aLayerManager, aContainerReferenceFrame, aClip); } void MarkScrollbarsDirtyForReflow() const final { mHelper.MarkScrollbarsDirtyForReflow(); } void InvalidateVerticalScrollbar() const final {
--- a/layout/generic/nsIFrame.cpp +++ b/layout/generic/nsIFrame.cpp @@ -7347,18 +7347,16 @@ void nsIFrame::InvalidateFrameWithRect(c } *rect = rect->Union(aRect); } /*static*/ uint8_t nsIFrame::sLayerIsPrerenderedDataKey; -bool nsIFrame::TryUpdateTransformOnly(Layer** aLayerResult) { return false; } - bool nsIFrame::IsInvalid(nsRect& aRect) { if (!HasAnyStateBits(NS_FRAME_NEEDS_PAINT)) { return false; } if (HasAnyStateBits(NS_FRAME_HAS_INVALID_RECT)) { nsRect* rect = GetProperty(InvalidationRect()); NS_ASSERTION(
--- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -3496,26 +3496,16 @@ class nsIFrame : public nsQueryFrame { * layer(s). */ static void* LayerIsPrerenderedDataKey() { return &sLayerIsPrerenderedDataKey; } static uint8_t sLayerIsPrerenderedDataKey; /** - * Try to update this frame's transform without invalidating any - * content. Return true iff successful. If unsuccessful, the - * caller is responsible for scheduling an invalidating paint. - * - * If the result is true, aLayerResult will be filled in with the - * transform layer for the frame. - */ - bool TryUpdateTransformOnly(Layer** aLayerResult); - - /** * Checks if a frame has had InvalidateFrame() called on it since the * last paint. * * If true, then the invalid rect is returned in aRect, with an * empty rect meaning all pixels drawn by this frame should be * invalidated. * If false, aRect is left unchanged. */
--- a/layout/generic/nsIScrollableFrame.h +++ b/layout/generic/nsIScrollableFrame.h @@ -35,17 +35,17 @@ class nsIContent; namespace mozilla { class DisplayItemClip; class nsDisplayListBuilder; namespace layers { struct ScrollMetadata; class Layer; -class LayerManager; +class WebRenderLayerManager; } // namespace layers namespace layout { class ScrollAnchorContainer; } // namespace layout } // namespace mozilla /** * Interface for frames that are scrollable. This interface exposes @@ -470,17 +470,17 @@ class nsIScrollableFrame : public nsIScr * Determine whether it is desirable to be able to asynchronously scroll this * scroll frame. */ virtual bool WantAsyncScroll() const = 0; /** * Returns the ScrollMetadata contributed by this frame, if there is one. */ virtual mozilla::Maybe<mozilla::layers::ScrollMetadata> ComputeScrollMetadata( - mozilla::layers::LayerManager* aLayerManager, + mozilla::layers::WebRenderLayerManager* aLayerManager, const nsIFrame* aContainerReferenceFrame, const mozilla::DisplayItemClip* aClip) const = 0; /** * Mark the scrollbar frames for reflow. */ virtual void MarkScrollbarsDirtyForReflow() const = 0;
--- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -327,43 +327,16 @@ static bool GenerateAndPushTextMask(nsIF RefPtr<SourceSurface> maskSurface = maskDT->Snapshot(); sourceCtx->PushGroupForBlendBack(gfxContentType::COLOR_ALPHA, 1.0, maskSurface, invCurrentMatrix); return true; } -/* static */ -void nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer( - Layer* aLayer, nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem, - nsIFrame* aFrame, DisplayItemType aType) { - // This function can be called in two ways: from - // nsDisplay*::BuildLayer while constructing a layer (with all - // pointers non-null), or from RestyleManager's handling of - // UpdateOpacityLayer/UpdateTransformLayer hints. - MOZ_ASSERT(!aBuilder == !aItem, - "should only be called in two configurations, with both " - "aBuilder and aItem, or with neither"); - MOZ_ASSERT(!aItem || aFrame == aItem->Frame(), "frame mismatch"); - - // Only send animations to a layer that is actually using - // off-main-thread compositing. - LayersBackend backend = aLayer->Manager()->GetBackendType(); - if (!(backend == LayersBackend::LAYERS_CLIENT || - backend == LayersBackend::LAYERS_WR)) { - return; - } - - AnimationInfo& animationInfo = aLayer->GetAnimationInfo(); - animationInfo.AddAnimationsForDisplayItem(aFrame, aBuilder, aItem, aType, - aLayer->Manager()); - animationInfo.TransferMutatedFlagToLayer(aLayer); -} - nsDisplayWrapList* nsDisplayListBuilder::MergeItems( nsTArray<nsDisplayWrapList*>& aItems) { // For merging, we create a temporary item by cloning the last item of the // mergeable items list. This ensures that the temporary item will have the // correct frame and bounds. nsDisplayWrapList* merged = nullptr; for (nsDisplayWrapList* item : Reversed(aItems)) { @@ -2323,19 +2296,19 @@ void nsDisplayList::Paint(nsDisplayListB } } /** * We paint by executing a layer manager transaction, constructing a * single layer representing the display list, and then making it the * root of the layer manager, drawing into the PaintedLayers. */ -already_AddRefed<LayerManager> nsDisplayList::PaintRoot( - nsDisplayListBuilder* aBuilder, gfxContext* aCtx, uint32_t aFlags, - Maybe<double> aDisplayListBuildTime) { +void nsDisplayList::PaintRoot(nsDisplayListBuilder* aBuilder, gfxContext* aCtx, + uint32_t aFlags, + Maybe<double> aDisplayListBuildTime) { AUTO_PROFILER_LABEL("nsDisplayList::PaintRoot", GRAPHICS); RefPtr<WebRenderLayerManager> layerManager; WindowRenderer* renderer = nullptr; bool widgetTransaction = false; bool doBeginTransaction = true; nsView* view = nullptr; if (aFlags & PAINT_USE_WIDGET_LAYERS) { @@ -2357,39 +2330,39 @@ already_AddRefed<LayerManager> nsDisplay nsIFrame* frame = aBuilder->RootReferenceFrame(); nsPresContext* presContext = frame->PresContext(); PresShell* presShell = presContext->PresShell(); Document* document = presShell->GetDocument(); if (!renderer) { if (!aCtx) { NS_WARNING("Nowhere to paint into"); - return nullptr; + return; } bool prevIsCompositingCheap = aBuilder->SetIsCompositingCheap(false); Paint(aBuilder, aCtx, presContext->AppUnitsPerDevPixel()); if (document && document->IsBeingUsedAsImage()) { frame->ClearInvalidationStateBits(); } aBuilder->SetIsCompositingCheap(prevIsCompositingCheap); - return nullptr; + return; } if (renderer->GetBackendType() == LayersBackend::LAYERS_WR) { MOZ_ASSERT(layerManager); if (doBeginTransaction) { if (aCtx) { if (!layerManager->BeginTransactionWithTarget(aCtx, nsCString())) { - return nullptr; + return; } } else { if (!layerManager->BeginTransaction(nsCString())) { - return nullptr; + return; } } } bool prevIsCompositingCheap = aBuilder->SetIsCompositingCheap(true); layerManager->SetTransactionIdAllocator(presContext->RefreshDriver()); bool sent = false; @@ -2431,26 +2404,26 @@ already_AddRefed<LayerManager> nsDisplay layerManager->GetAnimationReadyTime()); } if (presContext->RefreshDriver()->HasScheduleFlush()) { presContext->NotifyInvalidation(layerManager->GetLastTransactionId(), frame->GetRect()); } - return layerManager.forget(); + return; } FallbackRenderer* fallback = renderer->AsFallback(); MOZ_ASSERT(fallback); if (doBeginTransaction) { MOZ_ASSERT(!aCtx); if (!fallback->BeginTransaction()) { - return nullptr; + return; } } bool temp = aBuilder->SetIsCompositingCheap(renderer->IsCompositingCheap()); LayerManager::EndTransactionFlags flags = LayerManager::END_DEFAULT; if (renderer->NeedsWidgetInvalidation() && (aFlags & PAINT_NO_COMPOSITE)) { flags = LayerManager::END_NO_COMPOSITE; } @@ -2477,17 +2450,17 @@ already_AddRefed<LayerManager> nsDisplay if (shouldInvalidate) { // If we're the fallback renderer, then we don't need to invalidate // as we've just drawn directly to the window and don't need to do // anything else. NS_ASSERTION(!(aFlags & PAINT_NO_COMPOSITE), "Must be compositing during fallback"); } } - return nullptr; + return; } nsDisplayItem* nsDisplayList::RemoveBottom() { nsDisplayItem* item = mSentinel.mAbove; if (!item) { return nullptr; } mSentinel.mAbove = item->mAbove; @@ -6169,17 +6142,17 @@ nsDisplayScrollInfoLayer::nsDisplayScrol mHitInfo(aHitInfo), mHitArea(aHitArea) { #ifdef NS_BUILD_REFCNT_LOGGING MOZ_COUNT_CTOR(nsDisplayScrollInfoLayer); #endif } UniquePtr<ScrollMetadata> nsDisplayScrollInfoLayer::ComputeScrollMetadata( - nsDisplayListBuilder* aBuilder, LayerManager* aLayerManager) { + nsDisplayListBuilder* aBuilder, WebRenderLayerManager* aLayerManager) { ScrollMetadata metadata = nsLayoutUtils::ComputeScrollMetadata( mScrolledFrame, mScrollFrame, mScrollFrame->GetContent(), ReferenceFrame(), aLayerManager, mScrollParentId, mScrollFrame->GetSize(), Nothing(), false); metadata.GetMetrics().SetIsScrollInfoLayer(true); nsIScrollableFrame* scrollableFrame = mScrollFrame->GetScrollTargetFrame(); if (scrollableFrame) { aBuilder->AddScrollFrameToNotify(scrollableFrame);
--- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -1044,29 +1044,16 @@ class nsDisplayListBuilder { * If there is no clip, returns nullptr. */ const DisplayItemClipChain* FuseClipChainUpTo( const DisplayItemClipChain* aClipChain, const ActiveScrolledRoot* aASR); const ActiveScrolledRoot* GetFilterASR() const { return mFilterASR; } /** - * Transfer off main thread animations to the layer. May be called - * with aBuilder and aItem both null, but only if the caller has - * already checked that off main thread animations should be sent to - * the layer. When they are both null, the animations are added to - * the layer as pending animations. - */ - static void AddAnimationsAndTransitionsToLayer(layers::Layer* aLayer, - nsDisplayListBuilder* aBuilder, - nsDisplayItem* aItem, - nsIFrame* aFrame, - DisplayItemType aType); - - /** * Merges the display items in |aMergedItems| and returns a new temporary * display item. * The display items in |aMergedItems| have to be mergeable with each other. */ nsDisplayWrapList* MergeItems(nsTArray<nsDisplayWrapList*>& aItems); /** * A helper class used to temporarily set nsDisplayListBuilder properties for @@ -3455,19 +3442,18 @@ class nsDisplayList { enum { PAINT_DEFAULT = 0, PAINT_USE_WIDGET_LAYERS = 0x01, PAINT_EXISTING_TRANSACTION = 0x04, PAINT_NO_COMPOSITE = 0x08, PAINT_COMPRESSED = 0x10, PAINT_IDENTICAL_DISPLAY_LIST = 0x20 }; - already_AddRefed<layers::LayerManager> PaintRoot( - nsDisplayListBuilder* aBuilder, gfxContext* aCtx, uint32_t aFlags, - Maybe<double> aDisplayListBuildTime); + void PaintRoot(nsDisplayListBuilder* aBuilder, gfxContext* aCtx, + uint32_t aFlags, Maybe<double> aDisplayListBuildTime); void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx, int32_t aAppUnitsPerDevPixel); /** * Get the bounds. Takes the union of the bounds of all children. * The result is not cached. */ @@ -5890,17 +5876,18 @@ class nsDisplayScrollInfoLayer : public } bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) override { return false; } void WriteDebugInfo(std::stringstream& aStream) override; UniquePtr<layers::ScrollMetadata> ComputeScrollMetadata( - nsDisplayListBuilder* aBuilder, LayerManager* aLayerManager); + nsDisplayListBuilder* aBuilder, + layers::WebRenderLayerManager* aLayerManager); bool UpdateScrollData(layers::WebRenderScrollData* aData, layers::WebRenderLayerScrollData* aLayerData) override; bool CreateWebRenderCommands( wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override;
--- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -611,18 +611,18 @@ WindowRenderer* PuppetWidget::GetWindowR mBrowserChild->IsLayersConnected() != Some(true)); mWindowRenderer = CreateBasicLayerManager(); } return mWindowRenderer; } bool PuppetWidget::CreateRemoteLayerManager( - const std::function<bool(LayerManager*)>& aInitializeFunc) { - RefPtr<LayerManager> lm = new WebRenderLayerManager(this); + const std::function<bool(WebRenderLayerManager*)>& aInitializeFunc) { + RefPtr<WebRenderLayerManager> lm = new WebRenderLayerManager(this); MOZ_ASSERT(mBrowserChild); if (!aInitializeFunc(lm)) { return false; } // Force the old LM to self destruct, otherwise if the reference dangles we // could fail to revoke the most recent transaction. We only want to replace
--- a/widget/PuppetWidget.h +++ b/widget/PuppetWidget.h @@ -29,26 +29,31 @@ #include "mozilla/layers/MemoryPressureObserver.h" namespace mozilla { namespace dom { class BrowserChild; } // namespace dom +namespace layers { +class WebRenderLayerManager; +} // namespace layers + namespace widget { struct AutoCacheNativeKeyCommands; class PuppetWidget : public nsBaseWidget, public TextEventDispatcherListener, public layers::MemoryPressureListener { typedef mozilla::CSSRect CSSRect; typedef mozilla::dom::BrowserChild BrowserChild; typedef mozilla::gfx::DrawTarget DrawTarget; + typedef mozilla::layers::WebRenderLayerManager WebRenderLayerManager; // Avoiding to make compiler confused between mozilla::widget and nsIWidget. typedef mozilla::widget::TextEventDispatcher TextEventDispatcher; typedef mozilla::widget::TextEventDispatcherListener TextEventDispatcherListener; typedef nsBaseWidget Base; @@ -174,17 +179,17 @@ class PuppetWidget : public nsBaseWidget virtual WindowRenderer* GetWindowRenderer() override; // This is used for creating remote layer managers and for re-creating // them after a compositor reset. The lambda aInitializeFunc is used to // perform any caller-required initialization for the newly created layer // manager; in the event of a failure, return false and it will destroy the // new layer manager without changing the state of the widget. bool CreateRemoteLayerManager( - const std::function<bool(LayerManager*)>& aInitializeFunc); + const std::function<bool(WebRenderLayerManager*)>& aInitializeFunc); bool HasLayerManager() { return !!mWindowRenderer; } virtual void SetInputContext(const InputContext& aContext, const InputContextAction& aAction) override; virtual InputContext GetInputContext() override; virtual NativeIMEContext GetNativeIMEContext() override; TextEventDispatcherListener* GetNativeTextEventDispatcherListener() override {
--- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -1279,17 +1279,17 @@ already_AddRefed<CompositorVsyncDispatch nsBaseWidget::GetCompositorVsyncDispatcher() { MOZ_ASSERT(mCompositorVsyncDispatcherLock.get()); MutexAutoLock lock(*mCompositorVsyncDispatcherLock.get()); RefPtr<CompositorVsyncDispatcher> dispatcher = mCompositorVsyncDispatcher; return dispatcher.forget(); } -already_AddRefed<LayerManager> nsBaseWidget::CreateCompositorSession( +already_AddRefed<WebRenderLayerManager> nsBaseWidget::CreateCompositorSession( int aWidth, int aHeight, CompositorOptions* aOptionsOut) { MOZ_ASSERT(aOptionsOut); do { CreateCompositorVsyncDispatcher(); gfx::GPUProcessManager* gpu = gfx::GPUProcessManager::Get(); // Make sure GPU process is ready for use. @@ -1334,30 +1334,29 @@ already_AddRefed<LayerManager> nsBaseWid #ifdef MOZ_WIDGET_ANDROID if (!GetNativeData(NS_JAVA_SURFACE)) { options.SetInitiallyPaused(true); } #else options.SetInitiallyPaused(CompositorInitiallyPaused()); #endif - RefPtr<LayerManager> lm = new WebRenderLayerManager(this); + RefPtr<WebRenderLayerManager> lm = new WebRenderLayerManager(this); bool retry = false; mCompositorSession = gpu->CreateTopLevelCompositor( this, lm, GetDefaultScale(), options, UseExternalCompositingSurface(), gfx::IntSize(aWidth, aHeight), &retry); if (mCompositorSession) { TextureFactoryIdentifier textureFactoryIdentifier; nsCString error; - lm->AsWebRenderLayerManager()->Initialize( - mCompositorSession->GetCompositorBridgeChild(), - wr::AsPipelineId(mCompositorSession->RootLayerTreeId()), - &textureFactoryIdentifier, error); + lm->Initialize(mCompositorSession->GetCompositorBridgeChild(), + wr::AsPipelineId(mCompositorSession->RootLayerTreeId()), + &textureFactoryIdentifier, error); if (textureFactoryIdentifier.mParentBackend != LayersBackend::LAYERS_WR) { retry = true; DestroyCompositor(); // gfxVars::UseDoubleBufferingWithCompositor() is also disabled. gfx::GPUProcessManager::Get()->DisableWebRender( wr::WebRenderError::INITIALIZE, error); } } @@ -1391,17 +1390,18 @@ void nsBaseWidget::CreateCompositor(int // If we've already received a shutdown notification, don't try // create a new compositor. if (!mShutdownObserver) { return; } CompositorOptions options; - RefPtr<LayerManager> lm = CreateCompositorSession(aWidth, aHeight, &options); + RefPtr<WebRenderLayerManager> lm = + CreateCompositorSession(aWidth, aHeight, &options); if (!lm) { return; } MOZ_ASSERT(mCompositorSession); mCompositorBridgeChild = mCompositorSession->GetCompositorBridgeChild(); SetCompositorWidgetDelegate( mCompositorSession->GetCompositorWidgetDelegate()); @@ -1415,24 +1415,22 @@ void nsBaseWidget::CreateCompositor(int if (mInitialZoomConstraints) { UpdateZoomConstraints(mInitialZoomConstraints->mPresShellID, mInitialZoomConstraints->mViewID, Some(mInitialZoomConstraints->mConstraints)); mInitialZoomConstraints.reset(); } - if (lm->AsWebRenderLayerManager()) { - TextureFactoryIdentifier textureFactoryIdentifier = - lm->GetTextureFactoryIdentifier(); - MOZ_ASSERT(textureFactoryIdentifier.mParentBackend == - LayersBackend::LAYERS_WR); - ImageBridgeChild::IdentifyCompositorTextureHost(textureFactoryIdentifier); - gfx::VRManagerChild::IdentifyTextureHost(textureFactoryIdentifier); - } + TextureFactoryIdentifier textureFactoryIdentifier = + lm->GetTextureFactoryIdentifier(); + MOZ_ASSERT(textureFactoryIdentifier.mParentBackend == + LayersBackend::LAYERS_WR); + ImageBridgeChild::IdentifyCompositorTextureHost(textureFactoryIdentifier); + gfx::VRManagerChild::IdentifyTextureHost(textureFactoryIdentifier); WindowUsesOMTC(); mWindowRenderer = std::move(lm); // Only track compositors for top-level windows, since other window types // may use the basic compositor. Except on the OS X - see bug 1306383 #if defined(XP_MACOSX)
--- a/widget/nsBaseWidget.h +++ b/widget/nsBaseWidget.h @@ -60,16 +60,17 @@ namespace layers { class CompositorBridgeChild; class CompositorBridgeParent; class IAPZCTreeManager; class GeckoContentController; class APZEventState; struct APZEventResult; class CompositorSession; class ImageContainer; +class WebRenderLayerManager; struct ScrollableLayerGuid; class RemoteCompositorSession; } // namespace layers namespace widget { class CompositorWidgetDelegate; class InProcessCompositorWidget; class WidgetRenderingContext; @@ -782,13 +783,14 @@ class nsBaseWidget : public nsIWidget, p static void debug_DumpPaintEvent(FILE* aFileOut, nsIWidget* aWidget, const nsIntRegion& aPaintEvent, const char* aWidgetName, int32_t aWindowID); static bool debug_GetCachedBoolPref(const char* aPrefName); #endif private: - already_AddRefed<LayerManager> CreateCompositorSession( - int aWidth, int aHeight, mozilla::layers::CompositorOptions* aOptionsOut); + already_AddRefed<mozilla::layers::WebRenderLayerManager> + CreateCompositorSession(int aWidth, int aHeight, + mozilla::layers::CompositorOptions* aOptionsOut); }; #endif // nsBaseWidget_h__