Chromium Code Reviews| Index: Source/core/animation/CompositorAnimations.cpp |
| diff --git a/Source/core/animation/CompositorAnimations.cpp b/Source/core/animation/CompositorAnimations.cpp |
| index facbd8e3830f7bd242d0cf3f6969089c3e5f277c..3f6086d68dba5c86746095fd971806f044e7b935 100644 |
| --- a/Source/core/animation/CompositorAnimations.cpp |
| +++ b/Source/core/animation/CompositorAnimations.cpp |
| @@ -96,7 +96,10 @@ bool considerAnimationAsIncompatible(const Animation& animation, const Animation |
| bool hasIncompatibleAnimations(const Element& targetElement, const Animation& animationToAdd, const EffectModel& effectToAdd) |
| { |
| const bool affectsOpacity = effectToAdd.affects(PropertyHandle(CSSPropertyOpacity)); |
| - const bool affectsTransform = effectToAdd.affects(PropertyHandle(CSSPropertyTransform)); |
| + const bool affectsTransform = effectToAdd.affects(PropertyHandle(CSSPropertyRotate)) |
| + || effectToAdd.affects(PropertyHandle(CSSPropertyScale)) |
| + || effectToAdd.affects(PropertyHandle(CSSPropertyTransform)) |
|
dstockwell
2015/07/03 01:53:23
transform should be first (as most common)
soonm
2015/07/03 06:34:29
Done.
|
| + || effectToAdd.affects(PropertyHandle(CSSPropertyTranslate)); |
| const bool affectsFilter = effectToAdd.affects(PropertyHandle(CSSPropertyWebkitFilter)); |
| if (!targetElement.hasAnimations()) |
| @@ -111,7 +114,10 @@ bool hasIncompatibleAnimations(const Element& targetElement, const Animation& an |
| continue; |
| if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSPropertyOpacity)) |
| + || (affectsTransform && attachedAnimation->affects(targetElement, CSSPropertyRotate)) |
| + || (affectsTransform && attachedAnimation->affects(targetElement, CSSPropertyScale)) |
| || (affectsTransform && attachedAnimation->affects(targetElement, CSSPropertyTransform)) |
|
dstockwell
2015/07/03 01:53:23
transform should come first
soonm
2015/07/03 06:34:29
Done - As well for the same code below.
|
| + || (affectsTransform && attachedAnimation->affects(targetElement, CSSPropertyTranslate)) |
| || (affectsFilter && attachedAnimation->affects(targetElement, CSSPropertyWebkitFilter))) |
| return true; |
| } |
| @@ -121,8 +127,22 @@ bool hasIncompatibleAnimations(const Element& targetElement, const Animation& an |
| } |
| -CSSPropertyID CompositorAnimations::CompositableProperties[3] = { |
| - CSSPropertyOpacity, CSSPropertyTransform, CSSPropertyWebkitFilter |
| +bool CompositorAnimations::isCompositableProperty(CSSPropertyID property) |
| +{ |
| + for (CSSPropertyID id : compositableProperties) { |
| + if (property == id) |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| +const CSSPropertyID CompositorAnimations::compositableProperties[6] = { |
| + CSSPropertyOpacity, |
| + CSSPropertyRotate, |
| + CSSPropertyScale, |
| + CSSPropertyTransform, |
| + CSSPropertyTranslate, |
| + CSSPropertyWebkitFilter |
| }; |
| bool CompositorAnimations::getAnimatedBoundingBox(FloatBox& box, const EffectModel& effect, double minValue, double maxValue) const |
| @@ -142,7 +162,10 @@ bool CompositorAnimations::getAnimatedBoundingBox(FloatBox& box, const EffectMod |
| continue; |
| // TODO: Add the ability to get expanded bounds for filters as well. |
| - if (property.cssProperty() != CSSPropertyTransform) |
| + if (property.cssProperty() != CSSPropertyRotate |
| + && property.cssProperty() != CSSPropertyScale |
| + && property.cssProperty() != CSSPropertyTransform |
| + && property.cssProperty() != CSSPropertyTranslate) |
| continue; |
| const PropertySpecificKeyframeVector& frames = keyframeEffect.getPropertySpecificKeyframes(property); |
| @@ -200,10 +223,17 @@ bool CompositorAnimations::isCandidateForAnimationOnCompositor(const Timing& tim |
| if (properties.isEmpty()) |
| return false; |
| + unsigned transformOperationsCount = 0; |
|
dstockwell
2015/07/03 01:58:40
transformPropertyCount?
soonm
2015/07/03 06:34:29
Yep that sounds better.
|
| for (const auto& property : properties) { |
| if (!property.isCSSProperty()) |
| return false; |
| + if (property.cssProperty() == CSSPropertyRotate |
|
loyso (OOO)
2015/07/03 03:50:07
You have similar patterns repeated everywhere. Cou
soonm
2015/07/03 06:34:29
Did some clean up and abstracted out common checks
|
| + || property.cssProperty() == CSSPropertyScale |
| + || property.cssProperty() == CSSPropertyTransform |
| + || property.cssProperty() == CSSPropertyTranslate) |
| + transformOperationsCount++; |
| + |
| const PropertySpecificKeyframeVector& keyframes = keyframeEffect.getPropertySpecificKeyframes(property); |
| ASSERT(keyframes.size() >= 2); |
| for (const auto& keyframe : keyframes) { |
| @@ -215,6 +245,9 @@ bool CompositorAnimations::isCandidateForAnimationOnCompositor(const Timing& tim |
| switch (property.cssProperty()) { |
| case CSSPropertyOpacity: |
| break; |
| + case CSSPropertyRotate: |
| + case CSSPropertyScale: |
| + case CSSPropertyTranslate: |
| case CSSPropertyTransform: |
| if (toAnimatableTransform(keyframe->getAnimatableValue().get())->transformOperations().dependsOnBoxSize()) |
| return false; |
| @@ -232,6 +265,10 @@ bool CompositorAnimations::isCandidateForAnimationOnCompositor(const Timing& tim |
| } |
| } |
| + // TODO: Support multiple transform property animations on the compositor |
| + if (transformOperationsCount > 1) |
| + return false; |
| + |
| if (animationToAdd && hasIncompatibleAnimations(targetElement, *animationToAdd, effect)) |
| return false; |
| @@ -245,7 +282,10 @@ bool CompositorAnimations::isCandidateForAnimationOnCompositor(const Timing& tim |
| void CompositorAnimations::cancelIncompatibleAnimationsOnCompositor(const Element& targetElement, const Animation& animationToAdd, const EffectModel& effectToAdd) |
| { |
| const bool affectsOpacity = effectToAdd.affects(PropertyHandle(CSSPropertyOpacity)); |
| - const bool affectsTransform = effectToAdd.affects(PropertyHandle(CSSPropertyTransform)); |
| + const bool affectsTransform = effectToAdd.affects(PropertyHandle(CSSPropertyRotate)) |
| + || effectToAdd.affects(PropertyHandle(CSSPropertyScale)) |
| + || effectToAdd.affects(PropertyHandle(CSSPropertyTransform)) |
|
dstockwell
2015/07/03 01:58:40
transform first
soonm
2015/07/03 06:34:29
Done.
|
| + || effectToAdd.affects(PropertyHandle(CSSPropertyTranslate)); |
| const bool affectsFilter = effectToAdd.affects(PropertyHandle(CSSPropertyWebkitFilter)); |
| if (!targetElement.hasAnimations()) |
| @@ -260,7 +300,10 @@ void CompositorAnimations::cancelIncompatibleAnimationsOnCompositor(const Elemen |
| continue; |
| if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSPropertyOpacity)) |
| + || (affectsTransform && attachedAnimation->affects(targetElement, CSSPropertyRotate)) |
| + || (affectsTransform && attachedAnimation->affects(targetElement, CSSPropertyScale)) |
| || (affectsTransform && attachedAnimation->affects(targetElement, CSSPropertyTransform)) |
|
dstockwell
2015/07/03 01:58:40
transform first
soonm
2015/07/03 06:34:29
Done.
|
| + || (affectsTransform && attachedAnimation->affects(targetElement, CSSPropertyTranslate)) |
| || (affectsFilter && attachedAnimation->affects(targetElement, CSSPropertyWebkitFilter))) |
| attachedAnimation->cancelAnimationOnCompositor(); |
| } |
| @@ -630,6 +673,9 @@ void CompositorAnimationsImpl::getAnimationOnCompositor(const Timing& timing, in |
| curve = adoptPtr(filterCurve); |
| break; |
| } |
| + case CSSPropertyRotate: |
| + case CSSPropertyScale: |
| + case CSSPropertyTranslate: |
| case CSSPropertyTransform: { |
| targetProperty = WebCompositorAnimation::TargetPropertyTransform; |
| WebTransformAnimationCurve* transformCurve = Platform::current()->compositorSupport()->createTransformAnimationCurve(); |