From f0bdb9d256d7da9f74cd2a2c3325fc9475c91d29 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Mon, 2 Mar 2020 16:15:26 +0000 Subject: [PATCH] Bug 1619040 - Add a new WebRenderData specific for APZ. r=kats AnimationInfo has a bunch of member variables that are not necessary for APZ. Differential Revision: https://phabricator.services.mozilla.com/D64855 --HG-- extra : moz-landing-system : lando --- gfx/layers/wr/WebRenderUserData.cpp | 6 ++++++ gfx/layers/wr/WebRenderUserData.h | 15 +++++++++++++++ layout/painting/nsDisplayList.cpp | 8 +++----- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/gfx/layers/wr/WebRenderUserData.cpp b/gfx/layers/wr/WebRenderUserData.cpp index 8bdb35de1ac5..fbdfffca99f0 100644 --- a/gfx/layers/wr/WebRenderUserData.cpp +++ b/gfx/layers/wr/WebRenderUserData.cpp @@ -6,6 +6,7 @@ #include "WebRenderUserData.h" +#include "mozilla/layers/AnimationHelper.h" #include "mozilla/layers/CompositorBridgeChild.h" #include "mozilla/layers/ImageClient.h" #include "mozilla/layers/WebRenderBridgeChild.h" @@ -336,6 +337,11 @@ WebRenderImageData* WebRenderFallbackData::PaintIntoImage() { return mImageData.get(); } +WebRenderAPZAnimationData::WebRenderAPZAnimationData( + RenderRootStateManager* aManager, nsDisplayItem* aItem) + : WebRenderUserData(aManager, aItem), + mAnimationId(AnimationHelper::GetNextCompositorAnimationsId()) {} + WebRenderAnimationData::WebRenderAnimationData(RenderRootStateManager* aManager, nsDisplayItem* aItem) : WebRenderUserData(aManager, aItem) {} diff --git a/gfx/layers/wr/WebRenderUserData.h b/gfx/layers/wr/WebRenderUserData.h index c1c2b9f1224a..bfe7bea56357 100644 --- a/gfx/layers/wr/WebRenderUserData.h +++ b/gfx/layers/wr/WebRenderUserData.h @@ -78,6 +78,7 @@ class WebRenderUserData { enum class UserDataType { eImage, eFallback, + eAPZAnimation, eAnimation, eCanvas, eRemote, @@ -220,6 +221,20 @@ class WebRenderFallbackData : public WebRenderUserData { bool mInvalid; }; +class WebRenderAPZAnimationData : public WebRenderUserData { + public: + WebRenderAPZAnimationData(RenderRootStateManager* aManager, + nsDisplayItem* aItem); + virtual ~WebRenderAPZAnimationData() = default; + + UserDataType GetType() override { return UserDataType::eAPZAnimation; } + static UserDataType Type() { return UserDataType::eAPZAnimation; } + uint64_t GetAnimationId() { return mAnimationId; } + + private: + uint64_t mAnimationId; +}; + class WebRenderAnimationData : public WebRenderUserData { public: WebRenderAnimationData(RenderRootStateManager* aManager, diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index beda311d20eb..227d844bc004 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -6942,13 +6942,11 @@ bool nsDisplayOwnLayer::CreateWebRenderCommands( // APZ is enabled and this is a scroll thumb or zooming layer, so we need // to create and set an animation id. That way APZ can adjust the position/ // zoom of this content asynchronously as needed. - RefPtr animationData = + RefPtr animationData = aManager->CommandBuilder() - .CreateOrRecycleWebRenderUserData( + .CreateOrRecycleWebRenderUserData( this, aBuilder.GetRenderRoot()); - AnimationInfo& animationInfo = animationData->GetAnimationInfo(); - animationInfo.EnsureAnimationsId(); - mWrAnimationId = animationInfo.GetCompositorAnimationsId(); + mWrAnimationId = animationData->GetAnimationId(); prop.emplace(); prop->id = mWrAnimationId;