Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Unified Diff: Source/core/animation/CompositorAnimations.cpp

Issue 1218943002: Compositor animations for Independent CSS Transform Properties (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add Manual Tests and fix bug with cancel tests Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/animation/CompositorAnimations.h ('k') | Source/core/animation/DocumentAnimations.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/CompositorAnimations.cpp
diff --git a/Source/core/animation/CompositorAnimations.cpp b/Source/core/animation/CompositorAnimations.cpp
index facbd8e3830f7bd242d0cf3f6969089c3e5f277c..e21b719580a4683fa4f56fd34604c433230d249b 100644
--- a/Source/core/animation/CompositorAnimations.cpp
+++ b/Source/core/animation/CompositorAnimations.cpp
@@ -93,10 +93,28 @@ bool considerAnimationAsIncompatible(const Animation& animation, const Animation
}
}
+bool isTransformRelatedCSSProperty(const PropertyHandle property)
+{
+ return property.isCSSProperty()
+ && (property.cssProperty() == CSSPropertyRotate
+ || property.cssProperty() == CSSPropertyScale
+ || property.cssProperty() == CSSPropertyTransform
+ || property.cssProperty() == CSSPropertyTranslate);
+}
+
+
+bool isTransformRelatedAnimation(const Element& targetElement, const Animation* animation)
+{
+ return animation->affects(targetElement, CSSPropertyTransform)
+ || animation->affects(targetElement, CSSPropertyRotate)
+ || animation->affects(targetElement, CSSPropertyScale)
+ || animation->affects(targetElement, CSSPropertyTranslate);
+}
+
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.isTransformRelatedEffect();
const bool affectsFilter = effectToAdd.affects(PropertyHandle(CSSPropertyWebkitFilter));
if (!targetElement.hasAnimations())
@@ -111,7 +129,7 @@ bool hasIncompatibleAnimations(const Element& targetElement, const Animation& an
continue;
if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSPropertyOpacity))
- || (affectsTransform && attachedAnimation->affects(targetElement, CSSPropertyTransform))
+ || (affectsTransform && isTransformRelatedAnimation(targetElement, attachedAnimation))
|| (affectsFilter && attachedAnimation->affects(targetElement, CSSPropertyWebkitFilter)))
return true;
}
@@ -121,8 +139,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 +174,7 @@ 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 (!isTransformRelatedCSSProperty(property))
continue;
const PropertySpecificKeyframeVector& frames = keyframeEffect.getPropertySpecificKeyframes(property);
@@ -200,10 +232,14 @@ bool CompositorAnimations::isCandidateForAnimationOnCompositor(const Timing& tim
if (properties.isEmpty())
return false;
+ unsigned transformPropertyCount = 0;
for (const auto& property : properties) {
if (!property.isCSSProperty())
return false;
+ if (isTransformRelatedCSSProperty(property))
+ transformPropertyCount++;
+
const PropertySpecificKeyframeVector& keyframes = keyframeEffect.getPropertySpecificKeyframes(property);
ASSERT(keyframes.size() >= 2);
for (const auto& keyframe : keyframes) {
@@ -215,6 +251,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 +271,10 @@ bool CompositorAnimations::isCandidateForAnimationOnCompositor(const Timing& tim
}
}
+ // TODO: Support multiple transform property animations on the compositor
+ if (transformPropertyCount > 1)
+ return false;
+
if (animationToAdd && hasIncompatibleAnimations(targetElement, *animationToAdd, effect))
return false;
@@ -245,7 +288,7 @@ 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.isTransformRelatedEffect();
const bool affectsFilter = effectToAdd.affects(PropertyHandle(CSSPropertyWebkitFilter));
if (!targetElement.hasAnimations())
@@ -260,7 +303,7 @@ void CompositorAnimations::cancelIncompatibleAnimationsOnCompositor(const Elemen
continue;
if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSPropertyOpacity))
- || (affectsTransform && attachedAnimation->affects(targetElement, CSSPropertyTransform))
+ || (affectsTransform && isTransformRelatedAnimation(targetElement, attachedAnimation))
|| (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();
« no previous file with comments | « Source/core/animation/CompositorAnimations.h ('k') | Source/core/animation/DocumentAnimations.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698