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

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

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

Powered by Google App Engine
This is Rietveld 408576698