Bug 1618925 - Bail out from AddAnimationsForWebRender if there is no animation on the target frame. r=kats,boris

Calling CreateOrRecyleWebRenderUserData is a bit expensive in the case where
there is no animation. The case is pretty common.

Note that even if there is a WebRenderAnimationData having an AnimationInfo,
on the nsIFrame, it's going to be discarded since the WebRenderAnimationData
is not marked as being used.

Differential Revision: https://phabricator.services.mozilla.com/D64853

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Hiroyuki Ikezoe 2020-03-02 22:42:11 +00:00
parent 648749147b
commit bf1bb4a845

View File

@ -872,6 +872,21 @@ static void AddAnimationsForDisplayItem(nsIFrame* aFrame,
static uint64_t AddAnimationsForWebRender(
nsDisplayItem* aItem, mozilla::layers::RenderRootStateManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder, wr::RenderRoot aRenderRoot) {
EffectSet* effects =
EffectSet::GetEffectSetForFrame(aItem->Frame(), aItem->GetType());
if (!effects || effects->IsEmpty()) {
// If there is no animation on the nsIFrame, that means
// 1) we've never created any animations on this frame or
// 2) the frame was reconstruced or
// 3) all animations on the frame have finished
// in such cases we don't need do anything here.
//
// Even if there is a WebRenderAnimationData for the display item type on
// this frame, it's going to be discarded since it's not marked as being
// used.
return 0;
}
RefPtr<WebRenderAnimationData> animationData =
aManager->CommandBuilder()
.CreateOrRecycleWebRenderUserData<WebRenderAnimationData>(