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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 return animation->affects(targetElement, CSSPropertyTransform) | 107 return animation->affects(targetElement, CSSPropertyTransform) |
108 || animation->affects(targetElement, CSSPropertyRotate) | 108 || animation->affects(targetElement, CSSPropertyRotate) |
109 || animation->affects(targetElement, CSSPropertyScale) | 109 || animation->affects(targetElement, CSSPropertyScale) |
110 || animation->affects(targetElement, CSSPropertyTranslate); | 110 || animation->affects(targetElement, CSSPropertyTranslate); |
111 } | 111 } |
112 | 112 |
113 bool hasIncompatibleAnimations(const Element& targetElement, const Animation& an
imationToAdd, const EffectModel& effectToAdd) | 113 bool hasIncompatibleAnimations(const Element& targetElement, const Animation& an
imationToAdd, const EffectModel& effectToAdd) |
114 { | 114 { |
115 const bool affectsOpacity = effectToAdd.affects(PropertyHandle(CSSPropertyOp
acity)); | 115 const bool affectsOpacity = effectToAdd.affects(PropertyHandle(CSSPropertyOp
acity)); |
116 const bool affectsTransform = effectToAdd.isTransformRelatedEffect(); | 116 const bool affectsTransform = effectToAdd.isTransformRelatedEffect(); |
117 const bool affectsFilter = effectToAdd.affects(PropertyHandle(CSSPropertyWeb
kitFilter)); | 117 const bool affectsFilter = effectToAdd.affects(PropertyHandle(CSSPropertyFil
ter)); |
118 const bool affectsBackdropFilter = effectToAdd.affects(PropertyHandle(CSSPro
pertyBackdropFilter)); | 118 const bool affectsBackdropFilter = effectToAdd.affects(PropertyHandle(CSSPro
pertyBackdropFilter)); |
119 | 119 |
120 if (!targetElement.hasAnimations()) | 120 if (!targetElement.hasAnimations()) |
121 return false; | 121 return false; |
122 | 122 |
123 ElementAnimations* elementAnimations = targetElement.elementAnimations(); | 123 ElementAnimations* elementAnimations = targetElement.elementAnimations(); |
124 ASSERT(elementAnimations); | 124 ASSERT(elementAnimations); |
125 | 125 |
126 for (const auto& entry : elementAnimations->animations()) { | 126 for (const auto& entry : elementAnimations->animations()) { |
127 const Animation* attachedAnimation = entry.key; | 127 const Animation* attachedAnimation = entry.key; |
128 if (!considerAnimationAsIncompatible(*attachedAnimation, animationToAdd)
) | 128 if (!considerAnimationAsIncompatible(*attachedAnimation, animationToAdd)
) |
129 continue; | 129 continue; |
130 | 130 |
131 if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSProp
ertyOpacity)) | 131 if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSProp
ertyOpacity)) |
132 || (affectsTransform && isTransformRelatedAnimation(targetElement, a
ttachedAnimation)) | 132 || (affectsTransform && isTransformRelatedAnimation(targetElement, a
ttachedAnimation)) |
133 || (affectsFilter && attachedAnimation->affects(targetElement, CSSPr
opertyWebkitFilter)) | 133 || (affectsFilter && attachedAnimation->affects(targetElement, CSSPr
opertyFilter)) |
134 || (affectsBackdropFilter && attachedAnimation->affects(targetElemen
t, CSSPropertyBackdropFilter))) | 134 || (affectsBackdropFilter && attachedAnimation->affects(targetElemen
t, CSSPropertyBackdropFilter))) |
135 return true; | 135 return true; |
136 } | 136 } |
137 | 137 |
138 return false; | 138 return false; |
139 } | 139 } |
140 | 140 |
141 } // namespace | 141 } // namespace |
142 | 142 |
143 bool CompositorAnimations::isCompositableProperty(CSSPropertyID property) | 143 bool CompositorAnimations::isCompositableProperty(CSSPropertyID property) |
144 { | 144 { |
145 for (CSSPropertyID id : compositableProperties) { | 145 for (CSSPropertyID id : compositableProperties) { |
146 if (property == id) | 146 if (property == id) |
147 return true; | 147 return true; |
148 } | 148 } |
149 return false; | 149 return false; |
150 } | 150 } |
151 | 151 |
152 const CSSPropertyID CompositorAnimations::compositableProperties[7] = { | 152 const CSSPropertyID CompositorAnimations::compositableProperties[7] = { |
153 CSSPropertyOpacity, | 153 CSSPropertyOpacity, |
154 CSSPropertyRotate, | 154 CSSPropertyRotate, |
155 CSSPropertyScale, | 155 CSSPropertyScale, |
156 CSSPropertyTransform, | 156 CSSPropertyTransform, |
157 CSSPropertyTranslate, | 157 CSSPropertyTranslate, |
158 CSSPropertyWebkitFilter, | 158 CSSPropertyFilter, |
159 CSSPropertyBackdropFilter | 159 CSSPropertyBackdropFilter |
160 }; | 160 }; |
161 | 161 |
162 bool CompositorAnimations::getAnimatedBoundingBox(FloatBox& box, const EffectMod
el& effect, double minValue, double maxValue) | 162 bool CompositorAnimations::getAnimatedBoundingBox(FloatBox& box, const EffectMod
el& effect, double minValue, double maxValue) |
163 { | 163 { |
164 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef
fect); | 164 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef
fect); |
165 | 165 |
166 PropertyHandleSet properties = keyframeEffect.properties(); | 166 PropertyHandleSet properties = keyframeEffect.properties(); |
167 | 167 |
168 if (properties.isEmpty()) | 168 if (properties.isEmpty()) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 switch (property.cssProperty()) { | 257 switch (property.cssProperty()) { |
258 case CSSPropertyOpacity: | 258 case CSSPropertyOpacity: |
259 break; | 259 break; |
260 case CSSPropertyRotate: | 260 case CSSPropertyRotate: |
261 case CSSPropertyScale: | 261 case CSSPropertyScale: |
262 case CSSPropertyTranslate: | 262 case CSSPropertyTranslate: |
263 case CSSPropertyTransform: | 263 case CSSPropertyTransform: |
264 if (toAnimatableTransform(keyframe->getAnimatableValue().get())-
>transformOperations().dependsOnBoxSize()) | 264 if (toAnimatableTransform(keyframe->getAnimatableValue().get())-
>transformOperations().dependsOnBoxSize()) |
265 return false; | 265 return false; |
266 break; | 266 break; |
267 case CSSPropertyWebkitFilter: | 267 case CSSPropertyFilter: |
268 case CSSPropertyBackdropFilter: { | 268 case CSSPropertyBackdropFilter: { |
269 const FilterOperations& operations = toAnimatableFilterOperation
s(keyframe->getAnimatableValue().get())->operations(); | 269 const FilterOperations& operations = toAnimatableFilterOperation
s(keyframe->getAnimatableValue().get())->operations(); |
270 if (operations.hasFilterThatMovesPixels()) | 270 if (operations.hasFilterThatMovesPixels()) |
271 return false; | 271 return false; |
272 break; | 272 break; |
273 } | 273 } |
274 default: | 274 default: |
275 // any other types are not allowed to run on compositor. | 275 // any other types are not allowed to run on compositor. |
276 return false; | 276 return false; |
277 } | 277 } |
(...skipping 11 matching lines...) Expand all Loading... |
289 if (!convertTimingForCompositor(timing, 0, out, animationPlaybackRate)) | 289 if (!convertTimingForCompositor(timing, 0, out, animationPlaybackRate)) |
290 return false; | 290 return false; |
291 | 291 |
292 return true; | 292 return true; |
293 } | 293 } |
294 | 294 |
295 void CompositorAnimations::cancelIncompatibleAnimationsOnCompositor(const Elemen
t& targetElement, const Animation& animationToAdd, const EffectModel& effectToAd
d) | 295 void CompositorAnimations::cancelIncompatibleAnimationsOnCompositor(const Elemen
t& targetElement, const Animation& animationToAdd, const EffectModel& effectToAd
d) |
296 { | 296 { |
297 const bool affectsOpacity = effectToAdd.affects(PropertyHandle(CSSPropertyOp
acity)); | 297 const bool affectsOpacity = effectToAdd.affects(PropertyHandle(CSSPropertyOp
acity)); |
298 const bool affectsTransform = effectToAdd.isTransformRelatedEffect(); | 298 const bool affectsTransform = effectToAdd.isTransformRelatedEffect(); |
299 const bool affectsFilter = effectToAdd.affects(PropertyHandle(CSSPropertyWeb
kitFilter)); | 299 const bool affectsFilter = effectToAdd.affects(PropertyHandle(CSSPropertyFil
ter)); |
300 const bool affectsBackdropFilter = effectToAdd.affects(PropertyHandle(CSSPro
pertyBackdropFilter)); | 300 const bool affectsBackdropFilter = effectToAdd.affects(PropertyHandle(CSSPro
pertyBackdropFilter)); |
301 | 301 |
302 if (!targetElement.hasAnimations()) | 302 if (!targetElement.hasAnimations()) |
303 return; | 303 return; |
304 | 304 |
305 ElementAnimations* elementAnimations = targetElement.elementAnimations(); | 305 ElementAnimations* elementAnimations = targetElement.elementAnimations(); |
306 ASSERT(elementAnimations); | 306 ASSERT(elementAnimations); |
307 | 307 |
308 for (const auto& entry : elementAnimations->animations()) { | 308 for (const auto& entry : elementAnimations->animations()) { |
309 Animation* attachedAnimation = entry.key; | 309 Animation* attachedAnimation = entry.key; |
310 if (!considerAnimationAsIncompatible(*attachedAnimation, animationToAdd)
) | 310 if (!considerAnimationAsIncompatible(*attachedAnimation, animationToAdd)
) |
311 continue; | 311 continue; |
312 | 312 |
313 if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSProp
ertyOpacity)) | 313 if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSProp
ertyOpacity)) |
314 || (affectsTransform && isTransformRelatedAnimation(targetElement, a
ttachedAnimation)) | 314 || (affectsTransform && isTransformRelatedAnimation(targetElement, a
ttachedAnimation)) |
315 || (affectsFilter && attachedAnimation->affects(targetElement, CSSPr
opertyWebkitFilter)) | 315 || (affectsFilter && attachedAnimation->affects(targetElement, CSSPr
opertyFilter)) |
316 || (affectsBackdropFilter && attachedAnimation->affects(targetElemen
t, CSSPropertyBackdropFilter))) | 316 || (affectsBackdropFilter && attachedAnimation->affects(targetElemen
t, CSSPropertyBackdropFilter))) |
317 attachedAnimation->cancelAnimationOnCompositor(); | 317 attachedAnimation->cancelAnimationOnCompositor(); |
318 } | 318 } |
319 } | 319 } |
320 | 320 |
321 bool CompositorAnimations::canStartAnimationOnCompositor(const Element& element) | 321 bool CompositorAnimations::canStartAnimationOnCompositor(const Element& element) |
322 { | 322 { |
323 if (!Platform::current()->isThreadedAnimationEnabled()) | 323 if (!Platform::current()->isThreadedAnimationEnabled()) |
324 return false; | 324 return false; |
325 return element.layoutObject() && element.layoutObject()->compositingState()
== PaintsIntoOwnBacking; | 325 return element.layoutObject() && element.layoutObject()->compositingState()
== PaintsIntoOwnBacking; |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 std::unique_ptr<CompositorAnimationCurve> curve; | 580 std::unique_ptr<CompositorAnimationCurve> curve; |
581 switch (property.cssProperty()) { | 581 switch (property.cssProperty()) { |
582 case CSSPropertyOpacity: { | 582 case CSSPropertyOpacity: { |
583 targetProperty = CompositorTargetProperty::OPACITY; | 583 targetProperty = CompositorTargetProperty::OPACITY; |
584 std::unique_ptr<CompositorFloatAnimationCurve> floatCurve = Composit
orFloatAnimationCurve::create(); | 584 std::unique_ptr<CompositorFloatAnimationCurve> floatCurve = Composit
orFloatAnimationCurve::create(); |
585 addKeyframesToCurve(*floatCurve, values); | 585 addKeyframesToCurve(*floatCurve, values); |
586 setTimingFunctionOnCurve(*floatCurve, timing.timingFunction.get()); | 586 setTimingFunctionOnCurve(*floatCurve, timing.timingFunction.get()); |
587 curve = std::move(floatCurve); | 587 curve = std::move(floatCurve); |
588 break; | 588 break; |
589 } | 589 } |
590 case CSSPropertyWebkitFilter: | 590 case CSSPropertyFilter: |
591 case CSSPropertyBackdropFilter: { | 591 case CSSPropertyBackdropFilter: { |
592 targetProperty = CompositorTargetProperty::FILTER; | 592 targetProperty = CompositorTargetProperty::FILTER; |
593 std::unique_ptr<CompositorFilterAnimationCurve> filterCurve = Compos
itorFilterAnimationCurve::create(); | 593 std::unique_ptr<CompositorFilterAnimationCurve> filterCurve = Compos
itorFilterAnimationCurve::create(); |
594 addKeyframesToCurve(*filterCurve, values); | 594 addKeyframesToCurve(*filterCurve, values); |
595 setTimingFunctionOnCurve(*filterCurve, timing.timingFunction.get()); | 595 setTimingFunctionOnCurve(*filterCurve, timing.timingFunction.get()); |
596 curve = std::move(filterCurve); | 596 curve = std::move(filterCurve); |
597 break; | 597 break; |
598 } | 598 } |
599 case CSSPropertyRotate: | 599 case CSSPropertyRotate: |
600 case CSSPropertyScale: | 600 case CSSPropertyScale: |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 break; | 655 break; |
656 default: | 656 default: |
657 ASSERT_NOT_REACHED(); | 657 ASSERT_NOT_REACHED(); |
658 } | 658 } |
659 animations.append(std::move(animation)); | 659 animations.append(std::move(animation)); |
660 } | 660 } |
661 ASSERT(!animations.isEmpty()); | 661 ASSERT(!animations.isEmpty()); |
662 } | 662 } |
663 | 663 |
664 } // namespace blink | 664 } // namespace blink |
OLD | NEW |