From f0cd943dd99e7476d5ebcfef10c6a56190013420 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Thu, 22 Nov 2018 03:57:21 +0000 Subject: [PATCH] Bug 1508843 - Factor out common processes to send animations to the compositor for WebRender. r=birtles Depends on D12483 Differential Revision: https://phabricator.services.mozilla.com/D12484 --HG-- extra : moz-landing-system : lando --- layout/painting/nsDisplayList.cpp | 112 ++++++++++++++---------------- 1 file changed, 52 insertions(+), 60 deletions(-) diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 07c404011849..3497228809ac 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -731,6 +731,42 @@ AddAnimationsForProperty(nsIFrame* aFrame, } } +static uint64_t +AddAnimationsForWebRender( + nsDisplayItem* aItem, + nsCSSPropertyID aProperty, + mozilla::layers::WebRenderLayerManager* aManager, + nsDisplayListBuilder* aDisplayListBuilder) +{ + RefPtr animationData = + aManager->CommandBuilder() + .CreateOrRecycleWebRenderUserData(aItem); + AnimationInfo& animationInfo = animationData->GetAnimationInfo(); + AddAnimationsForProperty(aItem->Frame(), + aDisplayListBuilder, + aItem, + aProperty, + animationInfo, + Send::Immediate, + layers::LayersBackend::LAYERS_WR); + animationInfo.StartPendingAnimations(aManager->GetAnimationReadyTime()); + + // Note that animationsId can be 0 (uninitialized in AnimationInfo) if there + // are no active animations. + uint64_t animationsId = animationInfo.GetCompositorAnimationsId(); + if (!animationInfo.GetAnimations().IsEmpty()) { + OpAddCompositorAnimations anim( + CompositorAnimations(animationInfo.GetAnimations(), animationsId)); + aManager->WrBridge()->AddWebRenderParentCommand(anim); + aManager->AddActiveCompositorAnimationId(animationsId); + } else if (animationsId) { + aManager->AddCompositorAnimationsIdForDiscard(animationsId); + animationsId = 0; + } + + return animationsId; +} + static bool GenerateAndPushTextMask(nsIFrame* aFrame, gfxContext* aContext, @@ -6744,36 +6780,14 @@ nsDisplayOpacity::CreateWebRenderCommands( { float* opacityForSC = &mOpacity; - RefPtr animationData = - aManager->CommandBuilder() - .CreateOrRecycleWebRenderUserData(this); - AnimationInfo& animationInfo = animationData->GetAnimationInfo(); - AddAnimationsForProperty(Frame(), - aDisplayListBuilder, - this, - eCSSProperty_opacity, - animationInfo, - Send::Immediate, - layers::LayersBackend::LAYERS_WR); - animationInfo.StartPendingAnimations(aManager->GetAnimationReadyTime()); - - // Note that animationsId can be 0 (uninitialized in AnimationInfo) if there - // are no active animations. - uint64_t animationsId = animationInfo.GetCompositorAnimationsId(); - wr::WrAnimationProperty prop; - - if (!animationInfo.GetAnimations().IsEmpty()) { - prop.id = animationsId; - prop.effect_type = wr::WrAnimationType::Opacity; - - OpAddCompositorAnimations anim( - CompositorAnimations(animationInfo.GetAnimations(), animationsId)); - aManager->WrBridge()->AddWebRenderParentCommand(anim); - aManager->AddActiveCompositorAnimationId(animationsId); - } else if (animationsId) { - aManager->AddCompositorAnimationsIdForDiscard(animationsId); - animationsId = 0; - } + uint64_t animationsId = AddAnimationsForWebRender(this, + eCSSProperty_opacity, + aManager, + aDisplayListBuilder); + wr::WrAnimationProperty prop { + wr::WrAnimationType::Opacity, + animationsId, + }; nsTArray filters; StackingContextHelper sc(aSc, @@ -8829,36 +8843,14 @@ nsDisplayTransform::CreateWebRenderCommands( transformForSC = nullptr; } - RefPtr animationData = - aManager->CommandBuilder() - .CreateOrRecycleWebRenderUserData(this); - - AnimationInfo& animationInfo = animationData->GetAnimationInfo(); - AddAnimationsForProperty(Frame(), - aDisplayListBuilder, - this, - eCSSProperty_transform, - animationInfo, - Send::Immediate, - layers::LayersBackend::LAYERS_WR); - animationInfo.StartPendingAnimations(aManager->GetAnimationReadyTime()); - - // Note that animationsId can be 0 (uninitialized in AnimationInfo) if there - // are no active animations. - uint64_t animationsId = animationInfo.GetCompositorAnimationsId(); - wr::WrAnimationProperty prop; - if (!animationInfo.GetAnimations().IsEmpty()) { - prop.id = animationsId; - prop.effect_type = wr::WrAnimationType::Transform; - - OpAddCompositorAnimations anim( - CompositorAnimations(animationInfo.GetAnimations(), animationsId)); - aManager->WrBridge()->AddWebRenderParentCommand(anim); - aManager->AddActiveCompositorAnimationId(animationsId); - } else if (animationsId) { - aManager->AddCompositorAnimationsIdForDiscard(animationsId); - animationsId = 0; - } + uint64_t animationsId = AddAnimationsForWebRender(this, + eCSSProperty_transform, + aManager, + aDisplayListBuilder); + wr::WrAnimationProperty prop { + wr::WrAnimationType::Transform, + animationsId, + }; nsTArray filters; Maybe deferredTransformItem;