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

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

Issue 812013002: Define step timing function for the cc animation framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Codereview fixes Created 6 years 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef fect); 138 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef fect);
139 139
140 PropertySet properties = keyframeEffect.properties(); 140 PropertySet properties = keyframeEffect.properties();
141 141
142 if (properties.isEmpty()) 142 if (properties.isEmpty())
143 return false; 143 return false;
144 144
145 for (const auto& property : properties) { 145 for (const auto& property : properties) {
146 const PropertySpecificKeyframeVector& keyframes = keyframeEffect.getProp ertySpecificKeyframes(property); 146 const PropertySpecificKeyframeVector& keyframes = keyframeEffect.getProp ertySpecificKeyframes(property);
147 ASSERT(keyframes.size() >= 2); 147 ASSERT(keyframes.size() >= 2);
148 auto* lastKeyframe = keyframes.last().get();
149 for (const auto& keyframe : keyframes) { 148 for (const auto& keyframe : keyframes) {
150 // FIXME: Determine candidacy based on the CSSValue instead of a sna pshot AnimatableValue. 149 // FIXME: Determine candidacy based on the CSSValue instead of a sna pshot AnimatableValue.
151 if (keyframe->composite() != AnimationEffect::CompositeReplace || !k eyframe->getAnimatableValue()) 150 if (keyframe->composite() != AnimationEffect::CompositeReplace || !k eyframe->getAnimatableValue())
152 return false; 151 return false;
153 152
154 switch (property) { 153 switch (property) {
155 case CSSPropertyOpacity: 154 case CSSPropertyOpacity:
156 break; 155 break;
157 case CSSPropertyTransform: 156 case CSSPropertyTransform:
158 if (toAnimatableTransform(keyframe->getAnimatableValue().get())- >transformOperations().dependsOnBoxSize()) 157 if (toAnimatableTransform(keyframe->getAnimatableValue().get())- >transformOperations().dependsOnBoxSize())
159 return false; 158 return false;
160 break; 159 break;
161 case CSSPropertyWebkitFilter: { 160 case CSSPropertyWebkitFilter: {
162 const FilterOperations& operations = toAnimatableFilterOperation s(keyframe->getAnimatableValue().get())->operations(); 161 const FilterOperations& operations = toAnimatableFilterOperation s(keyframe->getAnimatableValue().get())->operations();
163 if (operations.hasFilterThatMovesPixels()) 162 if (operations.hasFilterThatMovesPixels())
164 return false; 163 return false;
165 break; 164 break;
166 } 165 }
167 default: 166 default:
168 return false; 167 return false;
169 } 168 }
170
171 // FIXME: Remove this check when crbug.com/229405 is resolved
172 if (keyframe != lastKeyframe && keyframe->easing().type() == TimingF unction::StepsFunction)
173 return false;
174 } 169 }
175 } 170 }
176 171
177 CompositorAnimationsImpl::CompositorTiming out; 172 CompositorAnimationsImpl::CompositorTiming out;
178 if (!CompositorAnimationsImpl::convertTimingForCompositor(timing, 0, out, pl ayerPlaybackRate)) 173 if (!CompositorAnimationsImpl::convertTimingForCompositor(timing, 0, out, pl ayerPlaybackRate))
179 return false; 174 return false;
180 175
181 if (timing.timingFunction->type() != TimingFunction::LinearFunction) { 176 if (timing.timingFunction->type() != TimingFunction::LinearFunction) {
182 // Checks the of size of KeyframeVector instead of PropertySpecificKeyfr ameVector. 177 // Checks the of size of KeyframeVector instead of PropertySpecificKeyfr ameVector.
183 const KeyframeVector& keyframes = keyframeEffect.getFrames(); 178 const KeyframeVector& keyframes = keyframeEffect.getFrames();
184 if (keyframes.size() == 2 && keyframes.first()->easing().type() == Timin gFunction::LinearFunction && timing.timingFunction->type() != TimingFunction::St epsFunction) 179 if (keyframes.size() == 2 && keyframes.first()->easing().type() == Timin gFunction::LinearFunction)
185 return true; 180 return true;
186 181
187 // FIXME: Support non-linear timing functions in the compositor for 182 // FIXME: Support non-linear timing functions in the compositor for
188 // more than two keyframes and step timing functions in the compositor. 183 // more than two keyframes.
189 return false; 184 return false;
190 } 185 }
191 186
192 return true; 187 return true;
193 } 188 }
194 189
195 bool CompositorAnimations::canStartAnimationOnCompositor(const Element& element) 190 bool CompositorAnimations::canStartAnimationOnCompositor(const Element& element)
196 { 191 {
197 return element.renderer() && element.renderer()->compositingState() == Paint sIntoOwnBacking; 192 return element.renderer() && element.renderer()->compositingState() == Paint sIntoOwnBacking;
198 } 193 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 ASSERT_NOT_REACHED(); 318 ASSERT_NOT_REACHED();
324 return; 319 return;
325 } 320 }
326 321
327 curve.add(keyframe, easeType); 322 curve.add(keyframe, easeType);
328 } 323 }
329 return; 324 return;
330 } 325 }
331 326
332 case TimingFunction::StepsFunction: 327 case TimingFunction::StepsFunction:
333 default: 328 const StepsTimingFunction* steps = toStepsTimingFunction(timingFunction) ;
334 ASSERT_NOT_REACHED(); 329
330 float stepsStartOffset;
331 switch (steps->stepAtPosition()) {
332 case StepsTimingFunction::Start:
333 stepsStartOffset = 1;
334 break;
335 case StepsTimingFunction::Middle:
336 stepsStartOffset = 0.5;
337 break;
338 case StepsTimingFunction::End:
339 stepsStartOffset = 0;
340 break;
341 default:
342 ASSERT_NOT_REACHED();
343 return;
344 }
345 curve.add(keyframe, steps->numberOfSteps(), stepsStartOffset);
335 return; 346 return;
336 } 347 }
337 } 348 }
338 349
339 } // namespace anoymous 350 } // namespace anoymous
340 351
341 void CompositorAnimationsImpl::addKeyframesToCurve(WebCompositorAnimationCurve& curve, const PropertySpecificKeyframeVector& keyframes, const Timing& timing) 352 void CompositorAnimationsImpl::addKeyframesToCurve(WebCompositorAnimationCurve& curve, const PropertySpecificKeyframeVector& keyframes, const Timing& timing)
342 { 353 {
343 auto* lastKeyframe = keyframes.last().get(); 354 auto* lastKeyframe = keyframes.last().get();
344 for (const auto& keyframe : keyframes) { 355 for (const auto& keyframe : keyframes) {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 break; 483 break;
473 default: 484 default:
474 ASSERT_NOT_REACHED(); 485 ASSERT_NOT_REACHED();
475 } 486 }
476 animations.append(animation.release()); 487 animations.append(animation.release());
477 } 488 }
478 ASSERT(!animations.isEmpty()); 489 ASSERT(!animations.isEmpty());
479 } 490 }
480 491
481 } // namespace blink 492 } // namespace blink
OLDNEW
« no previous file with comments | « ManualTests/animation/compositor-animation-steps.html ('k') | Source/core/animation/CompositorAnimationsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698