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

Side by Side Diff: third_party/WebKit/Source/core/animation/CompositorAnimations.cpp

Issue 1987943002: [wip] unprefix filter Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
OLDNEW
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
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
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
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
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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 switch (property.cssProperty()) { 640 switch (property.cssProperty()) {
641 case CSSPropertyOpacity: { 641 case CSSPropertyOpacity: {
642 targetProperty = CompositorTargetProperty::OPACITY; 642 targetProperty = CompositorTargetProperty::OPACITY;
643 643
644 CompositorFloatAnimationCurve* floatCurve = CompositorFactory::curre nt().createFloatAnimationCurve(); 644 CompositorFloatAnimationCurve* floatCurve = CompositorFactory::curre nt().createFloatAnimationCurve();
645 addKeyframesToCurve(*floatCurve, values); 645 addKeyframesToCurve(*floatCurve, values);
646 setTimingFunctionOnCurve(*floatCurve, timing.timingFunction.get()); 646 setTimingFunctionOnCurve(*floatCurve, timing.timingFunction.get());
647 curve = adoptPtr(floatCurve); 647 curve = adoptPtr(floatCurve);
648 break; 648 break;
649 } 649 }
650 case CSSPropertyWebkitFilter: 650 case CSSPropertyFilter:
651 case CSSPropertyBackdropFilter: { 651 case CSSPropertyBackdropFilter: {
652 targetProperty = CompositorTargetProperty::FILTER; 652 targetProperty = CompositorTargetProperty::FILTER;
653 CompositorFilterAnimationCurve* filterCurve = CompositorFactory::cur rent().createFilterAnimationCurve(); 653 CompositorFilterAnimationCurve* filterCurve = CompositorFactory::cur rent().createFilterAnimationCurve();
654 addKeyframesToCurve(*filterCurve, values); 654 addKeyframesToCurve(*filterCurve, values);
655 setTimingFunctionOnCurve(*filterCurve, timing.timingFunction.get()); 655 setTimingFunctionOnCurve(*filterCurve, timing.timingFunction.get());
656 curve = adoptPtr(filterCurve); 656 curve = adoptPtr(filterCurve);
657 break; 657 break;
658 } 658 }
659 case CSSPropertyRotate: 659 case CSSPropertyRotate:
660 case CSSPropertyScale: 660 case CSSPropertyScale:
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 break; 715 break;
716 default: 716 default:
717 ASSERT_NOT_REACHED(); 717 ASSERT_NOT_REACHED();
718 } 718 }
719 animations.append(std::move(animation)); 719 animations.append(std::move(animation));
720 } 720 }
721 ASSERT(!animations.isEmpty()); 721 ASSERT(!animations.isEmpty());
722 } 722 }
723 723
724 } // namespace blink 724 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698