Bug 1454550 - Call AnimationHelper::SampleAnimationForEachNode only for layers that have animations. r=kats

This is slightly efficient since we don't need to call
GetBaseAnimationStyle() or we do skip allocating animation data for such case.

MozReview-Commit-ID: BYFNwZsZ1oE

--HG--
extra : rebase_source : 441d7431bd444f1513a32d4da3c206c7df34ed94
This commit is contained in:
Hiroyuki Ikezoe 2018-04-17 13:20:33 +09:00
Родитель f6e88dec70
Коммит e53f74cb86
3 изменённых файлов: 18 добавлений и 20 удалений

Просмотреть файл

@ -134,7 +134,7 @@ CompositorAnimationStorage::SetAnimations(uint64_t aId, const AnimationArray& aV
}
bool
void
AnimationHelper::SampleAnimationForEachNode(
TimeStamp aTime,
AnimationArray& aAnimations,
@ -142,19 +142,13 @@ AnimationHelper::SampleAnimationForEachNode(
AnimationValue& aAnimationValue,
bool& aHasInEffectAnimations)
{
bool activeAnimations = false;
if (aAnimations.IsEmpty()) {
return activeAnimations;
}
MOZ_ASSERT(!aAnimations.IsEmpty(), "Should be called with animations");
// Process in order, since later aAnimations override earlier ones.
for (size_t i = 0, iEnd = aAnimations.Length(); i < iEnd; ++i) {
Animation& animation = aAnimations[i];
AnimData& animData = aAnimationData[i];
activeAnimations = true;
MOZ_ASSERT((!animation.originTime().IsNull() &&
animation.startTime().type() ==
MaybeTimeDuration::TTimeDuration) ||
@ -258,7 +252,6 @@ AnimationHelper::SampleAnimationForEachNode(
"All of members of TransformData should be the same");
}
#endif
return activeAnimations;
}
struct BogusAnimation {};
@ -514,6 +507,10 @@ AnimationHelper::SampleAnimations(CompositorAnimationStorage* aStorage,
!iter.Done(); iter.Next()) {
bool hasInEffectAnimations = false;
AnimationArray* animations = iter.UserData();
if (animations->IsEmpty()) {
continue;
}
AnimationValue animationValue;
InfallibleTArray<AnimData> animationData;
AnimationHelper::SetAnimations(*animations,

Просмотреть файл

@ -196,10 +196,8 @@ public:
/**
* Sample animations based on a given time stamp for a element(layer) with
* its animation data.
* Returns true if there exists compositor animation, and stores corresponding
* animated value in |aAnimationValue|.
*/
static bool
static void
SampleAnimationForEachNode(TimeStamp aTime,
AnimationArray& aAnimations,
InfallibleTArray<AnimData>& aAnimationData,

Просмотреть файл

@ -649,17 +649,20 @@ SampleAnimations(Layer* aLayer,
aLayer,
[&] (Layer* layer)
{
AnimationArray& animations = layer->GetAnimations();
if (animations.IsEmpty()) {
return;
}
isAnimating = true;
bool hasInEffectAnimations = false;
AnimationValue animationValue = layer->GetBaseAnimationStyle();
if (AnimationHelper::SampleAnimationForEachNode(aTime,
layer->GetAnimations(),
layer->GetAnimationData(),
animationValue,
hasInEffectAnimations)) {
isAnimating = true;
}
AnimationHelper::SampleAnimationForEachNode(aTime,
animations,
layer->GetAnimationData(),
animationValue,
hasInEffectAnimations);
if (hasInEffectAnimations) {
Animation& animation = layer->GetAnimations().LastElement();
Animation& animation = animations.LastElement();
ApplyAnimatedValue(layer,
aStorage,
animation.property(),