OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 return animation->affects(targetElement, CSSPropertyTransform) | 108 return animation->affects(targetElement, CSSPropertyTransform) |
109 || animation->affects(targetElement, CSSPropertyRotate) | 109 || animation->affects(targetElement, CSSPropertyRotate) |
110 || animation->affects(targetElement, CSSPropertyScale) | 110 || animation->affects(targetElement, CSSPropertyScale) |
111 || animation->affects(targetElement, CSSPropertyTranslate); | 111 || animation->affects(targetElement, CSSPropertyTranslate); |
112 } | 112 } |
113 | 113 |
114 bool hasIncompatibleAnimations(const Element& targetElement, const Animation& an
imationToAdd, const EffectModel& effectToAdd) | 114 bool hasIncompatibleAnimations(const Element& targetElement, const Animation& an
imationToAdd, const EffectModel& effectToAdd) |
115 { | 115 { |
116 const bool affectsOpacity = effectToAdd.affects(PropertyHandle(CSSPropertyOp
acity)); | 116 const bool affectsOpacity = effectToAdd.affects(PropertyHandle(CSSPropertyOp
acity)); |
117 const bool affectsTransform = effectToAdd.isTransformRelatedEffect(); | 117 const bool affectsTransform = effectToAdd.isTransformRelatedEffect(); |
118 const bool affectsFilter = effectToAdd.affects(PropertyHandle(CSSPropertyWeb
kitFilter)); | 118 const bool affectsFilter = effectToAdd.affects(PropertyHandle(CSSPropertyFil
ter)); |
119 const bool affectsBackdropFilter = effectToAdd.affects(PropertyHandle(CSSPro
pertyBackdropFilter)); | 119 const bool affectsBackdropFilter = effectToAdd.affects(PropertyHandle(CSSPro
pertyBackdropFilter)); |
120 | 120 |
121 if (!targetElement.hasAnimations()) | 121 if (!targetElement.hasAnimations()) |
122 return false; | 122 return false; |
123 | 123 |
124 ElementAnimations* elementAnimations = targetElement.elementAnimations(); | 124 ElementAnimations* elementAnimations = targetElement.elementAnimations(); |
125 ASSERT(elementAnimations); | 125 ASSERT(elementAnimations); |
126 | 126 |
127 for (const auto& entry : elementAnimations->animations()) { | 127 for (const auto& entry : elementAnimations->animations()) { |
128 const Animation* attachedAnimation = entry.key; | 128 const Animation* attachedAnimation = entry.key; |
129 if (!considerAnimationAsIncompatible(*attachedAnimation, animationToAdd)
) | 129 if (!considerAnimationAsIncompatible(*attachedAnimation, animationToAdd)
) |
130 continue; | 130 continue; |
131 | 131 |
132 if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSProp
ertyOpacity)) | 132 if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSProp
ertyOpacity)) |
133 || (affectsTransform && isTransformRelatedAnimation(targetElement, a
ttachedAnimation)) | 133 || (affectsTransform && isTransformRelatedAnimation(targetElement, a
ttachedAnimation)) |
134 || (affectsFilter && attachedAnimation->affects(targetElement, CSSPr
opertyWebkitFilter)) | 134 || (affectsFilter && attachedAnimation->affects(targetElement, CSSPr
opertyFilter)) |
135 || (affectsBackdropFilter && attachedAnimation->affects(targetElemen
t, CSSPropertyBackdropFilter))) | 135 || (affectsBackdropFilter && attachedAnimation->affects(targetElemen
t, CSSPropertyBackdropFilter))) |
136 return true; | 136 return true; |
137 } | 137 } |
138 | 138 |
139 return false; | 139 return false; |
140 } | 140 } |
141 | 141 |
142 } // namespace | 142 } // namespace |
143 | 143 |
144 CompositorAnimations::CompositorAnimations() | 144 CompositorAnimations::CompositorAnimations() |
(...skipping 17 matching lines...) Expand all Loading... |
162 } | 162 } |
163 return false; | 163 return false; |
164 } | 164 } |
165 | 165 |
166 const CSSPropertyID CompositorAnimations::compositableProperties[7] = { | 166 const CSSPropertyID CompositorAnimations::compositableProperties[7] = { |
167 CSSPropertyOpacity, | 167 CSSPropertyOpacity, |
168 CSSPropertyRotate, | 168 CSSPropertyRotate, |
169 CSSPropertyScale, | 169 CSSPropertyScale, |
170 CSSPropertyTransform, | 170 CSSPropertyTransform, |
171 CSSPropertyTranslate, | 171 CSSPropertyTranslate, |
172 CSSPropertyWebkitFilter, | 172 CSSPropertyFilter, |
173 CSSPropertyBackdropFilter | 173 CSSPropertyBackdropFilter |
174 }; | 174 }; |
175 | 175 |
176 bool CompositorAnimations::getAnimatedBoundingBox(FloatBox& box, const EffectMod
el& effect, double minValue, double maxValue) const | 176 bool CompositorAnimations::getAnimatedBoundingBox(FloatBox& box, const EffectMod
el& effect, double minValue, double maxValue) const |
177 { | 177 { |
178 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef
fect); | 178 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef
fect); |
179 | 179 |
180 PropertyHandleSet properties = keyframeEffect.properties(); | 180 PropertyHandleSet properties = keyframeEffect.properties(); |
181 | 181 |
182 if (properties.isEmpty()) | 182 if (properties.isEmpty()) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 switch (property.cssProperty()) { | 271 switch (property.cssProperty()) { |
272 case CSSPropertyOpacity: | 272 case CSSPropertyOpacity: |
273 break; | 273 break; |
274 case CSSPropertyRotate: | 274 case CSSPropertyRotate: |
275 case CSSPropertyScale: | 275 case CSSPropertyScale: |
276 case CSSPropertyTranslate: | 276 case CSSPropertyTranslate: |
277 case CSSPropertyTransform: | 277 case CSSPropertyTransform: |
278 if (toAnimatableTransform(keyframe->getAnimatableValue().get())-
>transformOperations().dependsOnBoxSize()) | 278 if (toAnimatableTransform(keyframe->getAnimatableValue().get())-
>transformOperations().dependsOnBoxSize()) |
279 return false; | 279 return false; |
280 break; | 280 break; |
281 case CSSPropertyWebkitFilter: | 281 case CSSPropertyFilter: |
282 case CSSPropertyBackdropFilter: { | 282 case CSSPropertyBackdropFilter: { |
283 const FilterOperations& operations = toAnimatableFilterOperation
s(keyframe->getAnimatableValue().get())->operations(); | 283 const FilterOperations& operations = toAnimatableFilterOperation
s(keyframe->getAnimatableValue().get())->operations(); |
284 if (operations.hasFilterThatMovesPixels()) | 284 if (operations.hasFilterThatMovesPixels()) |
285 return false; | 285 return false; |
286 break; | 286 break; |
287 } | 287 } |
288 default: | 288 default: |
289 // any other types are not allowed to run on compositor. | 289 // any other types are not allowed to run on compositor. |
290 return false; | 290 return false; |
291 } | 291 } |
(...skipping 11 matching lines...) Expand all Loading... |
303 if (!CompositorAnimationsImpl::convertTimingForCompositor(timing, 0, out, an
imationPlaybackRate)) | 303 if (!CompositorAnimationsImpl::convertTimingForCompositor(timing, 0, out, an
imationPlaybackRate)) |
304 return false; | 304 return false; |
305 | 305 |
306 return true; | 306 return true; |
307 } | 307 } |
308 | 308 |
309 void CompositorAnimations::cancelIncompatibleAnimationsOnCompositor(const Elemen
t& targetElement, const Animation& animationToAdd, const EffectModel& effectToAd
d) | 309 void CompositorAnimations::cancelIncompatibleAnimationsOnCompositor(const Elemen
t& targetElement, const Animation& animationToAdd, const EffectModel& effectToAd
d) |
310 { | 310 { |
311 const bool affectsOpacity = effectToAdd.affects(PropertyHandle(CSSPropertyOp
acity)); | 311 const bool affectsOpacity = effectToAdd.affects(PropertyHandle(CSSPropertyOp
acity)); |
312 const bool affectsTransform = effectToAdd.isTransformRelatedEffect(); | 312 const bool affectsTransform = effectToAdd.isTransformRelatedEffect(); |
313 const bool affectsFilter = effectToAdd.affects(PropertyHandle(CSSPropertyWeb
kitFilter)); | 313 const bool affectsFilter = effectToAdd.affects(PropertyHandle(CSSPropertyFil
ter)); |
314 const bool affectsBackdropFilter = effectToAdd.affects(PropertyHandle(CSSPro
pertyBackdropFilter)); | 314 const bool affectsBackdropFilter = effectToAdd.affects(PropertyHandle(CSSPro
pertyBackdropFilter)); |
315 | 315 |
316 if (!targetElement.hasAnimations()) | 316 if (!targetElement.hasAnimations()) |
317 return; | 317 return; |
318 | 318 |
319 ElementAnimations* elementAnimations = targetElement.elementAnimations(); | 319 ElementAnimations* elementAnimations = targetElement.elementAnimations(); |
320 ASSERT(elementAnimations); | 320 ASSERT(elementAnimations); |
321 | 321 |
322 for (const auto& entry : elementAnimations->animations()) { | 322 for (const auto& entry : elementAnimations->animations()) { |
323 Animation* attachedAnimation = entry.key; | 323 Animation* attachedAnimation = entry.key; |
324 if (!considerAnimationAsIncompatible(*attachedAnimation, animationToAdd)
) | 324 if (!considerAnimationAsIncompatible(*attachedAnimation, animationToAdd)
) |
325 continue; | 325 continue; |
326 | 326 |
327 if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSProp
ertyOpacity)) | 327 if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSProp
ertyOpacity)) |
328 || (affectsTransform && isTransformRelatedAnimation(targetElement, a
ttachedAnimation)) | 328 || (affectsTransform && isTransformRelatedAnimation(targetElement, a
ttachedAnimation)) |
329 || (affectsFilter && attachedAnimation->affects(targetElement, CSSPr
opertyWebkitFilter)) | 329 || (affectsFilter && attachedAnimation->affects(targetElement, CSSPr
opertyFilter)) |
330 || (affectsBackdropFilter && attachedAnimation->affects(targetElemen
t, CSSPropertyBackdropFilter))) | 330 || (affectsBackdropFilter && attachedAnimation->affects(targetElemen
t, CSSPropertyBackdropFilter))) |
331 attachedAnimation->cancelAnimationOnCompositor(); | 331 attachedAnimation->cancelAnimationOnCompositor(); |
332 } | 332 } |
333 } | 333 } |
334 | 334 |
335 bool CompositorAnimations::canStartAnimationOnCompositor(const Element& element) | 335 bool CompositorAnimations::canStartAnimationOnCompositor(const Element& element) |
336 { | 336 { |
337 if (!Platform::current()->isThreadedAnimationEnabled()) | 337 if (!Platform::current()->isThreadedAnimationEnabled()) |
338 return false; | 338 return false; |
339 return element.layoutObject() && element.layoutObject()->compositingState()
== PaintsIntoOwnBacking; | 339 return element.layoutObject() && element.layoutObject()->compositingState()
== PaintsIntoOwnBacking; |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 switch (property.cssProperty()) { | 639 switch (property.cssProperty()) { |
640 case CSSPropertyOpacity: { | 640 case CSSPropertyOpacity: { |
641 targetProperty = CompositorTargetProperty::OPACITY; | 641 targetProperty = CompositorTargetProperty::OPACITY; |
642 | 642 |
643 CompositorFloatAnimationCurve* floatCurve = CompositorFactory::curre
nt().createFloatAnimationCurve(); | 643 CompositorFloatAnimationCurve* floatCurve = CompositorFactory::curre
nt().createFloatAnimationCurve(); |
644 addKeyframesToCurve(*floatCurve, values, timing); | 644 addKeyframesToCurve(*floatCurve, values, timing); |
645 setTimingFunctionOnCurve(*floatCurve, timing.timingFunction.get()); | 645 setTimingFunctionOnCurve(*floatCurve, timing.timingFunction.get()); |
646 curve = adoptPtr(floatCurve); | 646 curve = adoptPtr(floatCurve); |
647 break; | 647 break; |
648 } | 648 } |
649 case CSSPropertyWebkitFilter: | 649 case CSSPropertyFilter: |
650 case CSSPropertyBackdropFilter: { | 650 case CSSPropertyBackdropFilter: { |
651 targetProperty = CompositorTargetProperty::FILTER; | 651 targetProperty = CompositorTargetProperty::FILTER; |
652 CompositorFilterAnimationCurve* filterCurve = CompositorFactory::cur
rent().createFilterAnimationCurve(); | 652 CompositorFilterAnimationCurve* filterCurve = CompositorFactory::cur
rent().createFilterAnimationCurve(); |
653 addKeyframesToCurve(*filterCurve, values, timing); | 653 addKeyframesToCurve(*filterCurve, values, timing); |
654 setTimingFunctionOnCurve(*filterCurve, timing.timingFunction.get()); | 654 setTimingFunctionOnCurve(*filterCurve, timing.timingFunction.get()); |
655 curve = adoptPtr(filterCurve); | 655 curve = adoptPtr(filterCurve); |
656 break; | 656 break; |
657 } | 657 } |
658 case CSSPropertyRotate: | 658 case CSSPropertyRotate: |
659 case CSSPropertyScale: | 659 case CSSPropertyScale: |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 break; | 714 break; |
715 default: | 715 default: |
716 ASSERT_NOT_REACHED(); | 716 ASSERT_NOT_REACHED(); |
717 } | 717 } |
718 animations.append(std::move(animation)); | 718 animations.append(std::move(animation)); |
719 } | 719 } |
720 ASSERT(!animations.isEmpty()); | 720 ASSERT(!animations.isEmpty()); |
721 } | 721 } |
722 | 722 |
723 } // namespace blink | 723 } // namespace blink |
OLD | NEW |