Bug 1479173 - Check animation generation change in the mProperties loop and drop LayerAnimationInfo::sRecords loop. r=birtles
If mIsRunningOnCompositor is true, the property is effective state because CanThrottle() is called in advance of a restyle for the effect so that we can drop the check and drop skipping in the case of non-effective properties. Depends on D10694 Differential Revision: https://phabricator.services.mozilla.com/D10695
This commit is contained in:
@@ -1242,23 +1242,18 @@ KeyframeEffect::CanThrottle() const
|
||||
return true;
|
||||
}
|
||||
|
||||
EffectSet* effectSet = nullptr;
|
||||
for (const AnimationProperty& property : mProperties) {
|
||||
if (!property.mIsRunningOnCompositor) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
EffectSet* effectSet = nullptr;
|
||||
for (const LayerAnimationInfo::Record& record :
|
||||
LayerAnimationInfo::sRecords) {
|
||||
// Skip properties that are overridden by !important rules.
|
||||
// (GetEffectiveAnimationOfProperty, as called by
|
||||
// HasEffectiveAnimationOfProperty, only returns a property which is
|
||||
// neither overridden by !important rules nor overridden by other
|
||||
// animation.)
|
||||
if (!HasEffectiveAnimationOfProperty(record.mProperty)) {
|
||||
continue;
|
||||
}
|
||||
MOZ_ASSERT(nsCSSPropertyIDSet::CompositorAnimatables()
|
||||
.HasProperty(property.mProperty),
|
||||
"The property should be able to run on the compositor");
|
||||
MOZ_ASSERT(HasEffectiveAnimationOfProperty(property.mProperty),
|
||||
"There should be an effective animation of the property while "
|
||||
"it is marked as being run on the compositor");
|
||||
|
||||
if (!effectSet) {
|
||||
effectSet = EffectSet::GetEffectSet(mTarget->mElement,
|
||||
@@ -1266,10 +1261,14 @@ KeyframeEffect::CanThrottle() const
|
||||
MOZ_ASSERT(effectSet, "CanThrottle should be called on an effect "
|
||||
"associated with a target element");
|
||||
}
|
||||
|
||||
DisplayItemType displayItemType =
|
||||
LayerAnimationInfo::GetDisplayItemTypeForProperty(property.mProperty);
|
||||
|
||||
// Note that AnimationInfo::GetGenarationFromFrame() is supposed to work
|
||||
// with the primary frame instead of the style frame.
|
||||
Maybe<uint64_t> generation = layers::AnimationInfo::GetGenerationFromFrame(
|
||||
GetPrimaryFrame(), record.mDisplayItemType);
|
||||
GetPrimaryFrame(), displayItemType);
|
||||
// Unthrottle if the animation needs to be brought up to date
|
||||
if (!generation || effectSet->GetAnimationGeneration() != *generation) {
|
||||
return false;
|
||||
|
||||
@@ -19,6 +19,20 @@ namespace mozilla {
|
||||
DisplayItemType::TYPE_OPACITY,
|
||||
nsChangeHint_UpdateOpacityLayer } };
|
||||
|
||||
/* static */ DisplayItemType
|
||||
LayerAnimationInfo::GetDisplayItemTypeForProperty(nsCSSPropertyID aProperty)
|
||||
{
|
||||
switch (aProperty) {
|
||||
case eCSSProperty_opacity:
|
||||
return DisplayItemType::TYPE_OPACITY;
|
||||
case eCSSProperty_transform:
|
||||
return DisplayItemType::TYPE_TRANSFORM;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return DisplayItemType::TYPE_ZERO;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* static */ void
|
||||
LayerAnimationInfo::Initialize()
|
||||
@@ -49,6 +63,10 @@ LayerAnimationInfo::Initialize()
|
||||
MOZ_ASSERT(found,
|
||||
"CSS property with the CSSPropFlags::CanAnimateOnCompositor "
|
||||
"flag does not have an entry in LayerAnimationInfo::sRecords");
|
||||
MOZ_ASSERT(GetDisplayItemTypeForProperty(prop) !=
|
||||
DisplayItemType::TYPE_ZERO,
|
||||
"GetDisplayItemTypeForProperty should return a valid display "
|
||||
"item type");
|
||||
}
|
||||
}
|
||||
MOZ_ASSERT(properties.Equals(nsCSSPropertyIDSet::CompositorAnimatables()));
|
||||
|
||||
@@ -26,6 +26,13 @@ struct LayerAnimationInfo {
|
||||
nsChangeHint mChangeHint;
|
||||
};
|
||||
|
||||
// Returns the corresponding display item type for |aProperty| when it is
|
||||
// animated on the compositor.
|
||||
// Returns DisplayItemType::TYPE_ZERO if |aProperty| cannot be animated on the
|
||||
// compositor.
|
||||
static DisplayItemType
|
||||
GetDisplayItemTypeForProperty(nsCSSPropertyID aProperty);
|
||||
|
||||
static const size_t kRecords =
|
||||
nsCSSPropertyIDSet::CompositorAnimatableCount();
|
||||
static const Record sRecords[kRecords];
|
||||
|
||||
Reference in New Issue
Block a user