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

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

Issue 768653002: Revert "Animations: Pass animation timing function through to compositor." (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | Annotate | Revision Log
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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // FIXME: Remove this check when crbug.com/229405 is resolved 171 // FIXME: Remove this check when crbug.com/229405 is resolved
172 if (keyframe != lastKeyframe && keyframe->easing().type() == TimingF unction::StepsFunction) 172 if (keyframe != lastKeyframe && keyframe->easing().type() == TimingF unction::StepsFunction)
173 return false; 173 return false;
174 } 174 }
175 } 175 }
176 176
177 CompositorAnimationsImpl::CompositorTiming out; 177 CompositorAnimationsImpl::CompositorTiming out;
178 if (!CompositorAnimationsImpl::convertTimingForCompositor(timing, 0, out, pl ayerPlaybackRate)) 178 if (!CompositorAnimationsImpl::convertTimingForCompositor(timing, 0, out, pl ayerPlaybackRate))
179 return false; 179 return false;
180 180
181 if (timing.timingFunction->type() == TimingFunction::StepsFunction) { 181 if (timing.timingFunction->type() != TimingFunction::LinearFunction) {
182 // FIXME: Support step timing functions in the compositor. 182 // Checks the of size of KeyframeVector instead of PropertySpecificKeyfr ameVector.
183 const KeyframeVector& keyframes = keyframeEffect.getFrames();
184 if (keyframes.size() == 2 && keyframes.first()->easing().type() == Timin gFunction::LinearFunction && timing.timingFunction->type() != TimingFunction::St epsFunction)
185 return true;
186
187 // FIXME: Support non-linear timing functions in the compositor for
188 // more than two keyframes and step timing functions in the compositor.
183 return false; 189 return false;
184 } 190 }
185 191
186 if (timing.timingFunction->type() == TimingFunction::CubicBezierFunction) {
187 // FIXME: Fix compositor timing functions to accept inputs outside of
188 // [0,1].
189 const CubicBezierTimingFunction& cubic = toCubicBezierTimingFunction(*ti ming.timingFunction);
190 const KeyframeVector& keyframes = keyframeEffect.getFrames();
191 double startRange;
192 double endRange;
193 cubic.range(&startRange, &endRange);
194
195 ASSERT(keyframes.size() >= 2);
196 if ((startRange < 0 || endRange > 1) && (keyframes.first()->easing().typ e() != TimingFunction::LinearFunction || keyframes[keyframes.size()-2]->easing() .type() != TimingFunction::LinearFunction))
197 return false;
198 }
199
200 return true; 192 return true;
201 } 193 }
202 194
203 bool CompositorAnimations::canStartAnimationOnCompositor(const Element& element) 195 bool CompositorAnimations::canStartAnimationOnCompositor(const Element& element)
204 { 196 {
205 return element.renderer() && element.renderer()->compositingState() == Paint sIntoOwnBacking; 197 return element.renderer() && element.renderer()->compositingState() == Paint sIntoOwnBacking;
206 } 198 }
207 199
208 bool CompositorAnimations::startAnimationOnCompositor(const Element& element, do uble startTime, double timeOffset, const Timing& timing, const AnimationEffect& effect, Vector<int>& startedAnimationIds, double playerPlaybackRate) 200 bool CompositorAnimations::startAnimationOnCompositor(const Element& element, do uble startTime, double timeOffset, const Timing& timing, const AnimationEffect& effect, Vector<int>& startedAnimationIds, double playerPlaybackRate)
209 { 201 {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 return; 329 return;
338 } 330 }
339 331
340 case TimingFunction::StepsFunction: 332 case TimingFunction::StepsFunction:
341 default: 333 default:
342 ASSERT_NOT_REACHED(); 334 ASSERT_NOT_REACHED();
343 return; 335 return;
344 } 336 }
345 } 337 }
346 338
347 template <typename PlatformAnimationCurveType>
348 void setTimingFunctionOnCurve(PlatformAnimationCurveType& curve, const Timing& t iming)
349 {
350 switch (timing.timingFunction->type()) {
351 case TimingFunction::LinearFunction:
352 curve.setTimingFunction(WebCompositorAnimationCurve::TimingFunctionTypeL inear);
353 return;
354
355 case TimingFunction::CubicBezierFunction: {
356 const CubicBezierTimingFunction& cubic = toCubicBezierTimingFunction(*ti ming.timingFunction);
357 curve.setTimingFunction(cubic.x1(), cubic.y1(), cubic.x2(), cubic.y2());
358 return;
359 }
360
361 case TimingFunction::StepsFunction:
362 default:
363 ASSERT_NOT_REACHED();
364 return;
365 }
366 }
367
368 } // namespace anoymous 339 } // namespace anoymous
369 340
370 void CompositorAnimationsImpl::addKeyframesToCurve(WebCompositorAnimationCurve& curve, const PropertySpecificKeyframeVector& keyframes, const Timing& timing) 341 void CompositorAnimationsImpl::addKeyframesToCurve(WebCompositorAnimationCurve& curve, const PropertySpecificKeyframeVector& keyframes, const Timing& timing)
371 { 342 {
372 auto* lastKeyframe = keyframes.last().get(); 343 auto* lastKeyframe = keyframes.last().get();
373 for (const auto& keyframe : keyframes) { 344 for (const auto& keyframe : keyframes) {
374 const TimingFunction* keyframeTimingFunction = 0; 345 const TimingFunction* keyframeTimingFunction = 0;
375 if (keyframe != lastKeyframe) { // Ignore timing function of last frame. 346 if (keyframe != lastKeyframe) { // Ignore timing function of last frame.
376 keyframeTimingFunction = &keyframe->easing(); 347 if (keyframes.size() == 2 && keyframes.first()->easing().type() == T imingFunction::LinearFunction)
348 keyframeTimingFunction = timing.timingFunction.get();
349 else
350 keyframeTimingFunction = &keyframe->easing();
377 } 351 }
378 352
379 // FIXME: This relies on StringKeyframes being eagerly evaluated, which will 353 // FIXME: This relies on StringKeyframes being eagerly evaluated, which will
380 // not happen eventually. Instead we should extract the CSSValue here 354 // not happen eventually. Instead we should extract the CSSValue here
381 // and convert using another set of toAnimatableXXXOperations functions. 355 // and convert using another set of toAnimatableXXXOperations functions.
382 const AnimatableValue* value = keyframe->getAnimatableValue().get(); 356 const AnimatableValue* value = keyframe->getAnimatableValue().get();
383 357
384 switch (curve.type()) { 358 switch (curve.type()) {
385 case WebCompositorAnimationCurve::AnimationCurveTypeFilter: { 359 case WebCompositorAnimationCurve::AnimationCurveTypeFilter: {
386 OwnPtr<WebFilterOperations> ops = adoptPtr(Platform::current()->comp ositorSupport()->createFilterOperations()); 360 OwnPtr<WebFilterOperations> ops = adoptPtr(Platform::current()->comp ositorSupport()->createFilterOperations());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 getKeyframeValuesForProperty(&effect, property, compositorTiming.scaledD uration, values); 400 getKeyframeValuesForProperty(&effect, property, compositorTiming.scaledD uration, values);
427 401
428 WebCompositorAnimation::TargetProperty targetProperty; 402 WebCompositorAnimation::TargetProperty targetProperty;
429 OwnPtr<WebCompositorAnimationCurve> curve; 403 OwnPtr<WebCompositorAnimationCurve> curve;
430 switch (property) { 404 switch (property) {
431 case CSSPropertyOpacity: { 405 case CSSPropertyOpacity: {
432 targetProperty = WebCompositorAnimation::TargetPropertyOpacity; 406 targetProperty = WebCompositorAnimation::TargetPropertyOpacity;
433 407
434 WebFloatAnimationCurve* floatCurve = Platform::current()->compositor Support()->createFloatAnimationCurve(); 408 WebFloatAnimationCurve* floatCurve = Platform::current()->compositor Support()->createFloatAnimationCurve();
435 addKeyframesToCurve(*floatCurve, values, timing); 409 addKeyframesToCurve(*floatCurve, values, timing);
436 setTimingFunctionOnCurve(*floatCurve, timing);
437 curve = adoptPtr(floatCurve); 410 curve = adoptPtr(floatCurve);
438 break; 411 break;
439 } 412 }
440 case CSSPropertyWebkitFilter: { 413 case CSSPropertyWebkitFilter: {
441 targetProperty = WebCompositorAnimation::TargetPropertyFilter; 414 targetProperty = WebCompositorAnimation::TargetPropertyFilter;
442 WebFilterAnimationCurve* filterCurve = Platform::current()->composit orSupport()->createFilterAnimationCurve(); 415 WebFilterAnimationCurve* filterCurve = Platform::current()->composit orSupport()->createFilterAnimationCurve();
443 addKeyframesToCurve(*filterCurve, values, timing); 416 addKeyframesToCurve(*filterCurve, values, timing);
444 setTimingFunctionOnCurve(*filterCurve, timing);
445 curve = adoptPtr(filterCurve); 417 curve = adoptPtr(filterCurve);
446 break; 418 break;
447 } 419 }
448 case CSSPropertyTransform: { 420 case CSSPropertyTransform: {
449 targetProperty = WebCompositorAnimation::TargetPropertyTransform; 421 targetProperty = WebCompositorAnimation::TargetPropertyTransform;
450 WebTransformAnimationCurve* transformCurve = Platform::current()->co mpositorSupport()->createTransformAnimationCurve(); 422 WebTransformAnimationCurve* transformCurve = Platform::current()->co mpositorSupport()->createTransformAnimationCurve();
451 addKeyframesToCurve(*transformCurve, values, timing); 423 addKeyframesToCurve(*transformCurve, values, timing);
452 setTimingFunctionOnCurve(*transformCurve, timing);
453 curve = adoptPtr(transformCurve); 424 curve = adoptPtr(transformCurve);
454 break; 425 break;
455 } 426 }
456 default: 427 default:
457 ASSERT_NOT_REACHED(); 428 ASSERT_NOT_REACHED();
458 continue; 429 continue;
459 } 430 }
460 ASSERT(curve.get()); 431 ASSERT(curve.get());
461 432
462 OwnPtr<WebCompositorAnimation> animation = adoptPtr(Platform::current()- >compositorSupport()->createAnimation(*curve, targetProperty)); 433 OwnPtr<WebCompositorAnimation> animation = adoptPtr(Platform::current()- >compositorSupport()->createAnimation(*curve, targetProperty));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 break; 472 break;
502 default: 473 default:
503 ASSERT_NOT_REACHED(); 474 ASSERT_NOT_REACHED();
504 } 475 }
505 animations.append(animation.release()); 476 animations.append(animation.release());
506 } 477 }
507 ASSERT(!animations.isEmpty()); 478 ASSERT(!animations.isEmpty());
508 } 479 }
509 480
510 } // namespace blink 481 } // namespace blink
OLDNEW
« no previous file with comments | « ManualTests/animation/compositor-animation-cubic.html ('k') | Source/core/animation/CompositorAnimationsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698