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

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

Issue 1299323005: blink: Add backdrop-filter support (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: one more Created 5 years, 3 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(CSSPropertyWeb kitFilter));
119 const bool affectsBackdropFilter = effectToAdd.affects(PropertyHandle(CSSPro pertyBackdropFilter));
chrishtr 2015/09/26 00:50:33 Should we support compositor animations of backgro
119 120
120 if (!targetElement.hasAnimations()) 121 if (!targetElement.hasAnimations())
121 return false; 122 return false;
122 123
123 ElementAnimations* elementAnimations = targetElement.elementAnimations(); 124 ElementAnimations* elementAnimations = targetElement.elementAnimations();
124 ASSERT(elementAnimations); 125 ASSERT(elementAnimations);
125 126
126 for (const auto& entry : elementAnimations->animations()) { 127 for (const auto& entry : elementAnimations->animations()) {
127 const Animation* attachedAnimation = entry.key; 128 const Animation* attachedAnimation = entry.key;
128 if (!considerAnimationAsIncompatible(*attachedAnimation, animationToAdd) ) 129 if (!considerAnimationAsIncompatible(*attachedAnimation, animationToAdd) )
129 continue; 130 continue;
130 131
131 if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSProp ertyOpacity)) 132 if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSProp ertyOpacity))
132 || (affectsTransform && isTransformRelatedAnimation(targetElement, a ttachedAnimation)) 133 || (affectsTransform && isTransformRelatedAnimation(targetElement, a ttachedAnimation))
133 || (affectsFilter && attachedAnimation->affects(targetElement, CSSPr opertyWebkitFilter))) 134 || (affectsFilter && attachedAnimation->affects(targetElement, CSSPr opertyWebkitFilter))
135 || (affectsBackdropFilter && attachedAnimation->affects(targetElemen t, CSSPropertyBackdropFilter)))
134 return true; 136 return true;
135 } 137 }
136 138
137 return false; 139 return false;
138 } 140 }
139 141
140 } 142 }
141 143
142 CompositorAnimations::CompositorAnimations() 144 CompositorAnimations::CompositorAnimations()
143 { 145 {
(...skipping 10 matching lines...) Expand all
154 156
155 bool CompositorAnimations::isCompositableProperty(CSSPropertyID property) 157 bool CompositorAnimations::isCompositableProperty(CSSPropertyID property)
156 { 158 {
157 for (CSSPropertyID id : compositableProperties) { 159 for (CSSPropertyID id : compositableProperties) {
158 if (property == id) 160 if (property == id)
159 return true; 161 return true;
160 } 162 }
161 return false; 163 return false;
162 } 164 }
163 165
164 const CSSPropertyID CompositorAnimations::compositableProperties[6] = { 166 const CSSPropertyID CompositorAnimations::compositableProperties[7] = {
165 CSSPropertyOpacity, 167 CSSPropertyOpacity,
166 CSSPropertyRotate, 168 CSSPropertyRotate,
167 CSSPropertyScale, 169 CSSPropertyScale,
168 CSSPropertyTransform, 170 CSSPropertyTransform,
169 CSSPropertyTranslate, 171 CSSPropertyTranslate,
170 CSSPropertyWebkitFilter 172 CSSPropertyWebkitFilter,
173 CSSPropertyBackdropFilter
171 }; 174 };
172 175
173 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
174 { 177 {
175 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef fect); 178 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef fect);
176 179
177 PropertyHandleSet properties = keyframeEffect.properties(); 180 PropertyHandleSet properties = keyframeEffect.properties();
178 181
179 if (properties.isEmpty()) 182 if (properties.isEmpty())
180 return true; 183 return true;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 switch (property.cssProperty()) { 267 switch (property.cssProperty()) {
265 case CSSPropertyOpacity: 268 case CSSPropertyOpacity:
266 break; 269 break;
267 case CSSPropertyRotate: 270 case CSSPropertyRotate:
268 case CSSPropertyScale: 271 case CSSPropertyScale:
269 case CSSPropertyTranslate: 272 case CSSPropertyTranslate:
270 case CSSPropertyTransform: 273 case CSSPropertyTransform:
271 if (toAnimatableTransform(keyframe->getAnimatableValue().get())- >transformOperations().dependsOnBoxSize()) 274 if (toAnimatableTransform(keyframe->getAnimatableValue().get())- >transformOperations().dependsOnBoxSize())
272 return false; 275 return false;
273 break; 276 break;
274 case CSSPropertyWebkitFilter: { 277 case CSSPropertyWebkitFilter:
278 case CSSPropertyBackdropFilter: {
275 const FilterOperations& operations = toAnimatableFilterOperation s(keyframe->getAnimatableValue().get())->operations(); 279 const FilterOperations& operations = toAnimatableFilterOperation s(keyframe->getAnimatableValue().get())->operations();
276 if (operations.hasFilterThatMovesPixels()) 280 if (operations.hasFilterThatMovesPixels())
277 return false; 281 return false;
278 break; 282 break;
279 } 283 }
280 default: 284 default:
281 // any other types are not allowed to run on compositor. 285 // any other types are not allowed to run on compositor.
282 return false; 286 return false;
283 } 287 }
284 } 288 }
285 } 289 }
286 290
287 // TODO: Support multiple transform property animations on the compositor 291 // TODO: Support multiple transform property animations on the compositor
288 if (transformPropertyCount > 1) 292 if (transformPropertyCount > 1)
289 return false; 293 return false;
290 294
291 if (animationToAdd && hasIncompatibleAnimations(targetElement, *animationToA dd, effect)) 295 if (animationToAdd && hasIncompatibleAnimations(targetElement, *animationToA dd, effect))
292 return false; 296 return false;
293 297
294 CompositorAnimationsImpl::CompositorTiming out; 298 CompositorAnimationsImpl::CompositorTiming out;
295 if (!CompositorAnimationsImpl::convertTimingForCompositor(timing, 0, out, an imationPlaybackRate)) 299 if (!CompositorAnimationsImpl::convertTimingForCompositor(timing, 0, out, an imationPlaybackRate))
296 return false; 300 return false;
297 301
298 return true; 302 return true;
299 } 303 }
300 304
301 void CompositorAnimations::cancelIncompatibleAnimationsOnCompositor(const Elemen t& targetElement, const Animation& animationToAdd, const EffectModel& effectToAd d) 305 void CompositorAnimations::cancelIncompatibleAnimationsOnCompositor(const Elemen t& targetElement, const Animation& animationToAdd, const EffectModel& effectToAd d)
302 { 306 {
303 const bool affectsOpacity = effectToAdd.affects(PropertyHandle(CSSPropertyOp acity)); 307 const bool affectsOpacity = effectToAdd.affects(PropertyHandle(CSSPropertyOp acity));
304 const bool affectsTransform = effectToAdd.isTransformRelatedEffect(); 308 const bool affectsTransform = effectToAdd.isTransformRelatedEffect();
305 const bool affectsFilter = effectToAdd.affects(PropertyHandle(CSSPropertyWeb kitFilter)); 309 const bool affectsFilter = effectToAdd.affects(PropertyHandle(CSSPropertyWeb kitFilter));
310 const bool affectsBackdropFilter = effectToAdd.affects(PropertyHandle(CSSPro pertyBackdropFilter));
306 311
307 if (!targetElement.hasAnimations()) 312 if (!targetElement.hasAnimations())
308 return; 313 return;
309 314
310 ElementAnimations* elementAnimations = targetElement.elementAnimations(); 315 ElementAnimations* elementAnimations = targetElement.elementAnimations();
311 ASSERT(elementAnimations); 316 ASSERT(elementAnimations);
312 317
313 for (const auto& entry : elementAnimations->animations()) { 318 for (const auto& entry : elementAnimations->animations()) {
314 Animation* attachedAnimation = entry.key; 319 Animation* attachedAnimation = entry.key;
315 if (!considerAnimationAsIncompatible(*attachedAnimation, animationToAdd) ) 320 if (!considerAnimationAsIncompatible(*attachedAnimation, animationToAdd) )
316 continue; 321 continue;
317 322
318 if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSProp ertyOpacity)) 323 if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSProp ertyOpacity))
319 || (affectsTransform && isTransformRelatedAnimation(targetElement, a ttachedAnimation)) 324 || (affectsTransform && isTransformRelatedAnimation(targetElement, a ttachedAnimation))
320 || (affectsFilter && attachedAnimation->affects(targetElement, CSSPr opertyWebkitFilter))) 325 || (affectsFilter && attachedAnimation->affects(targetElement, CSSPr opertyWebkitFilter))
326 || (affectsBackdropFilter && attachedAnimation->affects(targetElemen t, CSSPropertyBackdropFilter)))
321 attachedAnimation->cancelAnimationOnCompositor(); 327 attachedAnimation->cancelAnimationOnCompositor();
322 } 328 }
323 } 329 }
324 330
325 bool CompositorAnimations::canStartAnimationOnCompositor(const Element& element) 331 bool CompositorAnimations::canStartAnimationOnCompositor(const Element& element)
326 { 332 {
327 if (!Platform::current()->isThreadedAnimationEnabled()) 333 if (!Platform::current()->isThreadedAnimationEnabled())
328 return false; 334 return false;
329 return element.layoutObject() && element.layoutObject()->compositingState() == PaintsIntoOwnBacking; 335 return element.layoutObject() && element.layoutObject()->compositingState() == PaintsIntoOwnBacking;
330 } 336 }
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 switch (property.cssProperty()) { 679 switch (property.cssProperty()) {
674 case CSSPropertyOpacity: { 680 case CSSPropertyOpacity: {
675 targetProperty = WebCompositorAnimation::TargetPropertyOpacity; 681 targetProperty = WebCompositorAnimation::TargetPropertyOpacity;
676 682
677 WebFloatAnimationCurve* floatCurve = Platform::current()->compositor Support()->createFloatAnimationCurve(); 683 WebFloatAnimationCurve* floatCurve = Platform::current()->compositor Support()->createFloatAnimationCurve();
678 addKeyframesToCurve(*floatCurve, values, timing); 684 addKeyframesToCurve(*floatCurve, values, timing);
679 setTimingFunctionOnCurve(*floatCurve, timing.timingFunction.get()); 685 setTimingFunctionOnCurve(*floatCurve, timing.timingFunction.get());
680 curve = adoptPtr(floatCurve); 686 curve = adoptPtr(floatCurve);
681 break; 687 break;
682 } 688 }
683 case CSSPropertyWebkitFilter: { 689 case CSSPropertyWebkitFilter:
690 case CSSPropertyBackdropFilter: {
684 targetProperty = WebCompositorAnimation::TargetPropertyFilter; 691 targetProperty = WebCompositorAnimation::TargetPropertyFilter;
685 WebFilterAnimationCurve* filterCurve = Platform::current()->composit orSupport()->createFilterAnimationCurve(); 692 WebFilterAnimationCurve* filterCurve = Platform::current()->composit orSupport()->createFilterAnimationCurve();
686 addKeyframesToCurve(*filterCurve, values, timing); 693 addKeyframesToCurve(*filterCurve, values, timing);
687 setTimingFunctionOnCurve(*filterCurve, timing.timingFunction.get()); 694 setTimingFunctionOnCurve(*filterCurve, timing.timingFunction.get());
688 curve = adoptPtr(filterCurve); 695 curve = adoptPtr(filterCurve);
689 break; 696 break;
690 } 697 }
691 case CSSPropertyRotate: 698 case CSSPropertyRotate:
692 case CSSPropertyScale: 699 case CSSPropertyScale:
693 case CSSPropertyTranslate: 700 case CSSPropertyTranslate:
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 break; 754 break;
748 default: 755 default:
749 ASSERT_NOT_REACHED(); 756 ASSERT_NOT_REACHED();
750 } 757 }
751 animations.append(animation.release()); 758 animations.append(animation.release());
752 } 759 }
753 ASSERT(!animations.isEmpty()); 760 ASSERT(!animations.isEmpty());
754 } 761 }
755 762
756 } // namespace blink 763 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/animation/CompositorAnimations.h ('k') | Source/core/animation/DeferredLegacyStyleInterpolationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698