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

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

Issue 1616653002: CC Animation: Move files from cc_blink to Source/platform/animation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Fix copyrights and years. Created 4 years, 10 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 25 matching lines...) Expand all
36 #include "core/animation/ElementAnimations.h" 36 #include "core/animation/ElementAnimations.h"
37 #include "core/animation/animatable/AnimatableDouble.h" 37 #include "core/animation/animatable/AnimatableDouble.h"
38 #include "core/animation/animatable/AnimatableFilterOperations.h" 38 #include "core/animation/animatable/AnimatableFilterOperations.h"
39 #include "core/animation/animatable/AnimatableTransform.h" 39 #include "core/animation/animatable/AnimatableTransform.h"
40 #include "core/animation/animatable/AnimatableValue.h" 40 #include "core/animation/animatable/AnimatableValue.h"
41 #include "core/layout/LayoutBoxModelObject.h" 41 #include "core/layout/LayoutBoxModelObject.h"
42 #include "core/layout/LayoutObject.h" 42 #include "core/layout/LayoutObject.h"
43 #include "core/layout/compositing/CompositedLayerMapping.h" 43 #include "core/layout/compositing/CompositedLayerMapping.h"
44 #include "core/paint/PaintLayer.h" 44 #include "core/paint/PaintLayer.h"
45 #include "platform/RuntimeEnabledFeatures.h" 45 #include "platform/RuntimeEnabledFeatures.h"
46 #include "platform/animation/CompositorAnimation.h"
47 #include "platform/animation/CompositorAnimationPlayer.h"
48 #include "platform/animation/CompositorFilterAnimationCurve.h"
49 #include "platform/animation/CompositorFilterKeyframe.h"
50 #include "platform/animation/CompositorFloatAnimationCurve.h"
51 #include "platform/animation/CompositorFloatKeyframe.h"
52 #include "platform/animation/CompositorTransformAnimationCurve.h"
53 #include "platform/animation/CompositorTransformKeyframe.h"
46 #include "platform/geometry/FloatBox.h" 54 #include "platform/geometry/FloatBox.h"
55 #include "platform/graphics/CompositorFactory.h"
47 #include "public/platform/Platform.h" 56 #include "public/platform/Platform.h"
48 #include "public/platform/WebCompositorAnimation.h"
49 #include "public/platform/WebCompositorAnimationPlayer.h"
50 #include "public/platform/WebCompositorSupport.h" 57 #include "public/platform/WebCompositorSupport.h"
51 #include "public/platform/WebFilterAnimationCurve.h"
52 #include "public/platform/WebFilterKeyframe.h"
53 #include "public/platform/WebFloatAnimationCurve.h"
54 #include "public/platform/WebFloatKeyframe.h"
55 #include "public/platform/WebTransformAnimationCurve.h"
56 #include "public/platform/WebTransformKeyframe.h"
57 58
58 #include <algorithm> 59 #include <algorithm>
59 #include <cmath> 60 #include <cmath>
60 61
61 namespace blink { 62 namespace blink {
62 63
63 namespace { 64 namespace {
64 65
65 void getKeyframeValuesForProperty(const KeyframeEffectModelBase* effect, Propert yHandle property, double scale, PropertySpecificKeyframeVector& values) 66 void getKeyframeValuesForProperty(const KeyframeEffectModelBase* effect, Propert yHandle property, double scale, PropertySpecificKeyframeVector& values)
66 { 67 {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 { 343 {
343 ASSERT(startedAnimationIds.isEmpty()); 344 ASSERT(startedAnimationIds.isEmpty());
344 ASSERT(isCandidateForAnimationOnCompositor(timing, element, &animation, effe ct, animationPlaybackRate)); 345 ASSERT(isCandidateForAnimationOnCompositor(timing, element, &animation, effe ct, animationPlaybackRate));
345 ASSERT(canStartAnimationOnCompositor(element)); 346 ASSERT(canStartAnimationOnCompositor(element));
346 347
347 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef fect); 348 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef fect);
348 349
349 PaintLayer* layer = toLayoutBoxModelObject(element.layoutObject())->layer(); 350 PaintLayer* layer = toLayoutBoxModelObject(element.layoutObject())->layer();
350 ASSERT(layer); 351 ASSERT(layer);
351 352
352 Vector<OwnPtr<WebCompositorAnimation>> animations; 353 Vector<OwnPtr<CompositorAnimation>> animations;
353 CompositorAnimationsImpl::getAnimationOnCompositor(timing, group, startTime, timeOffset, keyframeEffect, animations, animationPlaybackRate); 354 CompositorAnimationsImpl::getAnimationOnCompositor(timing, group, startTime, timeOffset, keyframeEffect, animations, animationPlaybackRate);
354 ASSERT(!animations.isEmpty()); 355 ASSERT(!animations.isEmpty());
355 for (auto& compositorAnimation : animations) { 356 for (auto& compositorAnimation : animations) {
356 int id = compositorAnimation->id(); 357 int id = compositorAnimation->id();
357 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { 358 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) {
358 WebCompositorAnimationPlayer* compositorPlayer = animation.composito rPlayer(); 359 CompositorAnimationPlayer* compositorPlayer = animation.compositorPl ayer();
359 ASSERT(compositorPlayer); 360 ASSERT(compositorPlayer);
360 compositorPlayer->addAnimation(compositorAnimation.leakPtr()); 361 compositorPlayer->addAnimation(compositorAnimation.leakPtr());
361 } else if (!layer->compositedLayerMapping()->mainGraphicsLayer()->addAni mation(compositorAnimation.release())) { 362 } else if (!layer->compositedLayerMapping()->mainGraphicsLayer()->addAni mation(compositorAnimation.release())) {
362 // FIXME: We should know ahead of time whether these animations can be started. 363 // FIXME: We should know ahead of time whether these animations can be started.
363 for (int startedAnimationId : startedAnimationIds) 364 for (int startedAnimationId : startedAnimationIds)
364 cancelAnimationOnCompositor(element, animation, startedAnimation Id); 365 cancelAnimationOnCompositor(element, animation, startedAnimation Id);
365 startedAnimationIds.clear(); 366 startedAnimationIds.clear();
366 return false; 367 return false;
367 } 368 }
368 startedAnimationIds.append(id); 369 startedAnimationIds.append(id);
369 } 370 }
370 ASSERT(!startedAnimationIds.isEmpty()); 371 ASSERT(!startedAnimationIds.isEmpty());
371 return true; 372 return true;
372 } 373 }
373 374
374 void CompositorAnimations::cancelAnimationOnCompositor(const Element& element, c onst Animation& animation, int id) 375 void CompositorAnimations::cancelAnimationOnCompositor(const Element& element, c onst Animation& animation, int id)
375 { 376 {
376 if (!canStartAnimationOnCompositor(element)) { 377 if (!canStartAnimationOnCompositor(element)) {
377 // When an element is being detached, we cancel any associated 378 // When an element is being detached, we cancel any associated
378 // Animations for CSS animations. But by the time we get 379 // Animations for CSS animations. But by the time we get
379 // here the mapping will have been removed. 380 // here the mapping will have been removed.
380 // FIXME: Defer remove/pause operations until after the 381 // FIXME: Defer remove/pause operations until after the
381 // compositing update. 382 // compositing update.
382 return; 383 return;
383 } 384 }
384 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { 385 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) {
385 WebCompositorAnimationPlayer* compositorPlayer = animation.compositorPla yer(); 386 CompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer ();
386 if (compositorPlayer) 387 if (compositorPlayer)
387 compositorPlayer->removeAnimation(id); 388 compositorPlayer->removeAnimation(id);
388 } else { 389 } else {
389 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedLayer Mapping()->mainGraphicsLayer()->removeAnimation(id); 390 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedLayer Mapping()->mainGraphicsLayer()->removeAnimation(id);
390 } 391 }
391 } 392 }
392 393
393 void CompositorAnimations::pauseAnimationForTestingOnCompositor(const Element& e lement, const Animation& animation, int id, double pauseTime) 394 void CompositorAnimations::pauseAnimationForTestingOnCompositor(const Element& e lement, const Animation& animation, int id, double pauseTime)
394 { 395 {
395 // FIXME: canStartAnimationOnCompositor queries compositingState, which is n ot necessarily up to date. 396 // FIXME: canStartAnimationOnCompositor queries compositingState, which is n ot necessarily up to date.
396 // https://code.google.com/p/chromium/issues/detail?id=339847 397 // https://code.google.com/p/chromium/issues/detail?id=339847
397 DisableCompositingQueryAsserts disabler; 398 DisableCompositingQueryAsserts disabler;
398 399
399 if (!canStartAnimationOnCompositor(element)) { 400 if (!canStartAnimationOnCompositor(element)) {
400 ASSERT_NOT_REACHED(); 401 ASSERT_NOT_REACHED();
401 return; 402 return;
402 } 403 }
403 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { 404 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) {
404 WebCompositorAnimationPlayer* compositorPlayer = animation.compositorPla yer(); 405 CompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer ();
405 ASSERT(compositorPlayer); 406 ASSERT(compositorPlayer);
406 compositorPlayer->pauseAnimation(id, pauseTime); 407 compositorPlayer->pauseAnimation(id, pauseTime);
407 } else { 408 } else {
408 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedLayer Mapping()->mainGraphicsLayer()->pauseAnimation(id, pauseTime); 409 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedLayer Mapping()->mainGraphicsLayer()->pauseAnimation(id, pauseTime);
409 } 410 }
410 } 411 }
411 412
412 bool CompositorAnimations::canAttachCompositedLayers(const Element& element, con st Animation& animation) 413 bool CompositorAnimations::canAttachCompositedLayers(const Element& element, con st Animation& animation)
413 { 414 {
414 if (!RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) 415 if (!RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled())
(...skipping 18 matching lines...) Expand all
433 return true; 434 return true;
434 } 435 }
435 436
436 void CompositorAnimations::attachCompositedLayers(const Element& element, const Animation& animation) 437 void CompositorAnimations::attachCompositedLayers(const Element& element, const Animation& animation)
437 { 438 {
438 ASSERT(element.layoutObject()); 439 ASSERT(element.layoutObject());
439 440
440 PaintLayer* layer = toLayoutBoxModelObject(element.layoutObject())->layer(); 441 PaintLayer* layer = toLayoutBoxModelObject(element.layoutObject())->layer();
441 ASSERT(layer); 442 ASSERT(layer);
442 443
443 WebCompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer( ); 444 CompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer();
444 ASSERT(compositorPlayer); 445 ASSERT(compositorPlayer);
445 446
446 ASSERT(layer->compositedLayerMapping()); 447 ASSERT(layer->compositedLayerMapping());
447 compositorPlayer->attachLayer(layer->compositedLayerMapping()->mainGraphicsL ayer()->platformLayer()); 448 compositorPlayer->attachLayer(layer->compositedLayerMapping()->mainGraphicsL ayer()->platformLayer());
448 } 449 }
449 450
450 // ----------------------------------------------------------------------- 451 // -----------------------------------------------------------------------
451 // CompositorAnimationsImpl 452 // CompositorAnimationsImpl
452 // ----------------------------------------------------------------------- 453 // -----------------------------------------------------------------------
453 454
(...skipping 21 matching lines...) Expand all
475 out.playbackRate = timing.playbackRate * animationPlaybackRate; 476 out.playbackRate = timing.playbackRate * animationPlaybackRate;
476 out.fillMode = timing.fillMode == Timing::FillModeAuto ? Timing::FillModeNon e : timing.fillMode; 477 out.fillMode = timing.fillMode == Timing::FillModeAuto ? Timing::FillModeNon e : timing.fillMode;
477 out.iterationStart = timing.iterationStart; 478 out.iterationStart = timing.iterationStart;
478 out.assertValid(); 479 out.assertValid();
479 return true; 480 return true;
480 } 481 }
481 482
482 namespace { 483 namespace {
483 484
484 void getCubicBezierTimingFunctionParameters(const TimingFunction& timingFunction , bool& outCustom, 485 void getCubicBezierTimingFunctionParameters(const TimingFunction& timingFunction , bool& outCustom,
485 WebCompositorAnimationCurve::TimingFunctionType& outEaseSubType, 486 CompositorAnimationCurve::TimingFunctionType& outEaseSubType,
486 double& outX1, double& outY1, double& outX2, double& outY2) 487 double& outX1, double& outY1, double& outX2, double& outY2)
487 { 488 {
488 const CubicBezierTimingFunction& cubic = toCubicBezierTimingFunction(timingF unction); 489 const CubicBezierTimingFunction& cubic = toCubicBezierTimingFunction(timingF unction);
489 outCustom = false; 490 outCustom = false;
490 491
491 switch (cubic.subType()) { 492 switch (cubic.subType()) {
492 case CubicBezierTimingFunction::Ease: 493 case CubicBezierTimingFunction::Ease:
493 outEaseSubType = WebCompositorAnimationCurve::TimingFunctionTypeEase; 494 outEaseSubType = CompositorAnimationCurve::TimingFunctionTypeEase;
494 break; 495 break;
495 case CubicBezierTimingFunction::EaseIn: 496 case CubicBezierTimingFunction::EaseIn:
496 outEaseSubType = WebCompositorAnimationCurve::TimingFunctionTypeEaseIn; 497 outEaseSubType = CompositorAnimationCurve::TimingFunctionTypeEaseIn;
497 break; 498 break;
498 case CubicBezierTimingFunction::EaseOut: 499 case CubicBezierTimingFunction::EaseOut:
499 outEaseSubType = WebCompositorAnimationCurve::TimingFunctionTypeEaseOut; 500 outEaseSubType = CompositorAnimationCurve::TimingFunctionTypeEaseOut;
500 break; 501 break;
501 case CubicBezierTimingFunction::EaseInOut: 502 case CubicBezierTimingFunction::EaseInOut:
502 outEaseSubType = WebCompositorAnimationCurve::TimingFunctionTypeEaseInOu t; 503 outEaseSubType = CompositorAnimationCurve::TimingFunctionTypeEaseInOut;
503 break; 504 break;
504 case CubicBezierTimingFunction::Custom: 505 case CubicBezierTimingFunction::Custom:
505 outCustom = true; 506 outCustom = true;
506 outX1 = cubic.x1(); 507 outX1 = cubic.x1();
507 outY1 = cubic.y1(); 508 outY1 = cubic.y1();
508 outX2 = cubic.x2(); 509 outX2 = cubic.x2();
509 outY2 = cubic.y2(); 510 outY2 = cubic.y2();
510 break; 511 break;
511 default: 512 default:
512 ASSERT_NOT_REACHED(); 513 ASSERT_NOT_REACHED();
(...skipping 25 matching lines...) Expand all
538 template<typename PlatformAnimationCurveType, typename PlatformAnimationKeyframe Type> 539 template<typename PlatformAnimationCurveType, typename PlatformAnimationKeyframe Type>
539 void addKeyframeWithTimingFunction(PlatformAnimationCurveType& curve, const Plat formAnimationKeyframeType& keyframe, const TimingFunction* timingFunction) 540 void addKeyframeWithTimingFunction(PlatformAnimationCurveType& curve, const Plat formAnimationKeyframeType& keyframe, const TimingFunction* timingFunction)
540 { 541 {
541 if (!timingFunction) { 542 if (!timingFunction) {
542 curve.add(keyframe); 543 curve.add(keyframe);
543 return; 544 return;
544 } 545 }
545 546
546 switch (timingFunction->type()) { 547 switch (timingFunction->type()) {
547 case TimingFunction::LinearFunction: 548 case TimingFunction::LinearFunction:
548 curve.add(keyframe, WebCompositorAnimationCurve::TimingFunctionTypeLinea r); 549 curve.add(keyframe, CompositorAnimationCurve::TimingFunctionTypeLinear);
549 break; 550 break;
550 551
551 case TimingFunction::CubicBezierFunction: { 552 case TimingFunction::CubicBezierFunction: {
552 bool custom; 553 bool custom;
553 WebCompositorAnimationCurve::TimingFunctionType easeSubType; 554 CompositorAnimationCurve::TimingFunctionType easeSubType;
554 double x1, y1; 555 double x1, y1;
555 double x2, y2; 556 double x2, y2;
556 getCubicBezierTimingFunctionParameters(*timingFunction, custom, easeSubT ype, x1, y1, x2, y2); 557 getCubicBezierTimingFunctionParameters(*timingFunction, custom, easeSubT ype, x1, y1, x2, y2);
557 558
558 if (custom) 559 if (custom)
559 curve.add(keyframe, x1, y1, x2, y2); 560 curve.add(keyframe, x1, y1, x2, y2);
560 else 561 else
561 curve.add(keyframe, easeSubType); 562 curve.add(keyframe, easeSubType);
562 break; 563 break;
563 } 564 }
(...skipping 20 matching lines...) Expand all
584 return; 585 return;
585 } 586 }
586 587
587 switch (timingFunction->type()) { 588 switch (timingFunction->type()) {
588 case TimingFunction::LinearFunction: 589 case TimingFunction::LinearFunction:
589 curve.setLinearTimingFunction(); 590 curve.setLinearTimingFunction();
590 break; 591 break;
591 592
592 case TimingFunction::CubicBezierFunction: { 593 case TimingFunction::CubicBezierFunction: {
593 bool custom; 594 bool custom;
594 WebCompositorAnimationCurve::TimingFunctionType easeSubType; 595 CompositorAnimationCurve::TimingFunctionType easeSubType;
595 double x1, y1; 596 double x1, y1;
596 double x2, y2; 597 double x2, y2;
597 getCubicBezierTimingFunctionParameters(*timingFunction, custom, easeSubT ype, x1, y1, x2, y2); 598 getCubicBezierTimingFunctionParameters(*timingFunction, custom, easeSubT ype, x1, y1, x2, y2);
598 599
599 if (custom) 600 if (custom)
600 curve.setCubicBezierTimingFunction(x1, y1, x2, y2); 601 curve.setCubicBezierTimingFunction(x1, y1, x2, y2);
601 else 602 else
602 curve.setCubicBezierTimingFunction(easeSubType); 603 curve.setCubicBezierTimingFunction(easeSubType);
603 break; 604 break;
604 } 605 }
605 606
606 case TimingFunction::StepsFunction: { 607 case TimingFunction::StepsFunction: {
607 int steps; 608 int steps;
608 float stepsStartOffset; 609 float stepsStartOffset;
609 getStepsTimingFunctionParameters(*timingFunction, steps, stepsStartOffse t); 610 getStepsTimingFunctionParameters(*timingFunction, steps, stepsStartOffse t);
610 611
611 curve.setStepsTimingFunction(steps, stepsStartOffset); 612 curve.setStepsTimingFunction(steps, stepsStartOffset);
612 break; 613 break;
613 } 614 }
614 615
615 default: 616 default:
616 ASSERT_NOT_REACHED(); 617 ASSERT_NOT_REACHED();
617 } 618 }
618 } 619 }
619 620
620 } // namespace 621 } // namespace
621 622
622 void CompositorAnimationsImpl::addKeyframesToCurve(WebCompositorAnimationCurve& curve, const PropertySpecificKeyframeVector& keyframes, const Timing& timing) 623 void CompositorAnimationsImpl::addKeyframesToCurve(CompositorAnimationCurve& cur ve, const PropertySpecificKeyframeVector& keyframes, const Timing& timing)
623 { 624 {
624 auto* lastKeyframe = keyframes.last().get(); 625 auto* lastKeyframe = keyframes.last().get();
625 for (const auto& keyframe : keyframes) { 626 for (const auto& keyframe : keyframes) {
626 const TimingFunction* keyframeTimingFunction = 0; 627 const TimingFunction* keyframeTimingFunction = 0;
627 if (keyframe != lastKeyframe) { // Ignore timing function of last frame. 628 if (keyframe != lastKeyframe) { // Ignore timing function of last frame.
628 keyframeTimingFunction = &keyframe->easing(); 629 keyframeTimingFunction = &keyframe->easing();
629 } 630 }
630 631
631 // FIXME: This relies on StringKeyframes being eagerly evaluated, which will 632 // FIXME: This relies on StringKeyframes being eagerly evaluated, which will
632 // not happen eventually. Instead we should extract the CSSValue here 633 // not happen eventually. Instead we should extract the CSSValue here
633 // and convert using another set of toAnimatableXXXOperations functions. 634 // and convert using another set of toAnimatableXXXOperations functions.
634 const AnimatableValue* value = keyframe->getAnimatableValue().get(); 635 const AnimatableValue* value = keyframe->getAnimatableValue().get();
635 636
636 switch (curve.type()) { 637 switch (curve.type()) {
637 case WebCompositorAnimationCurve::AnimationCurveTypeFilter: { 638 case CompositorAnimationCurve::AnimationCurveTypeFilter: {
638 OwnPtr<WebFilterOperations> ops = adoptPtr(Platform::current()->comp ositorSupport()->createFilterOperations()); 639 OwnPtr<CompositorFilterOperations> ops = adoptPtr(CompositorFactory: :current().createFilterOperations());
639 toWebFilterOperations(toAnimatableFilterOperations(value)->operation s(), ops.get()); 640 toCompositorFilterOperations(toAnimatableFilterOperations(value)->op erations(), ops.get());
640 641
641 WebFilterKeyframe filterKeyframe(keyframe->offset(), ops.release()); 642 CompositorFilterKeyframe filterKeyframe(keyframe->offset(), ops.rele ase());
642 WebFilterAnimationCurve* filterCurve = static_cast<WebFilterAnimatio nCurve*>(&curve); 643 CompositorFilterAnimationCurve* filterCurve = static_cast<Compositor FilterAnimationCurve*>(&curve);
643 addKeyframeWithTimingFunction(*filterCurve, filterKeyframe, keyframe TimingFunction); 644 addKeyframeWithTimingFunction(*filterCurve, filterKeyframe, keyframe TimingFunction);
644 break; 645 break;
645 } 646 }
646 case WebCompositorAnimationCurve::AnimationCurveTypeFloat: { 647 case CompositorAnimationCurve::AnimationCurveTypeFloat: {
647 WebFloatKeyframe floatKeyframe(keyframe->offset(), toAnimatableDoubl e(value)->toDouble()); 648 CompositorFloatKeyframe floatKeyframe(keyframe->offset(), toAnimatab leDouble(value)->toDouble());
648 WebFloatAnimationCurve* floatCurve = static_cast<WebFloatAnimationCu rve*>(&curve); 649 CompositorFloatAnimationCurve* floatCurve = static_cast<CompositorFl oatAnimationCurve*>(&curve);
649 addKeyframeWithTimingFunction(*floatCurve, floatKeyframe, keyframeTi mingFunction); 650 addKeyframeWithTimingFunction(*floatCurve, floatKeyframe, keyframeTi mingFunction);
650 break; 651 break;
651 } 652 }
652 case WebCompositorAnimationCurve::AnimationCurveTypeTransform: { 653 case CompositorAnimationCurve::AnimationCurveTypeTransform: {
653 OwnPtr<WebTransformOperations> ops = adoptPtr(Platform::current()->c ompositorSupport()->createTransformOperations()); 654 OwnPtr<CompositorTransformOperations> ops = adoptPtr(CompositorFacto ry::current().createTransformOperations());
654 toWebTransformOperations(toAnimatableTransform(value)->transformOper ations(), ops.get()); 655 toCompositorTransformOperations(toAnimatableTransform(value)->transf ormOperations(), ops.get());
655 656
656 WebTransformKeyframe transformKeyframe(keyframe->offset(), ops.relea se()); 657 CompositorTransformKeyframe transformKeyframe(keyframe->offset(), op s.release());
657 WebTransformAnimationCurve* transformCurve = static_cast<WebTransfor mAnimationCurve*>(&curve); 658 CompositorTransformAnimationCurve* transformCurve = static_cast<Comp ositorTransformAnimationCurve*>(&curve);
658 addKeyframeWithTimingFunction(*transformCurve, transformKeyframe, ke yframeTimingFunction); 659 addKeyframeWithTimingFunction(*transformCurve, transformKeyframe, ke yframeTimingFunction);
659 break; 660 break;
660 } 661 }
661 default: 662 default:
662 ASSERT_NOT_REACHED(); 663 ASSERT_NOT_REACHED();
663 } 664 }
664 } 665 }
665 } 666 }
666 667
667 void CompositorAnimationsImpl::getAnimationOnCompositor(const Timing& timing, in t group, double startTime, double timeOffset, const KeyframeEffectModelBase& eff ect, Vector<OwnPtr<WebCompositorAnimation>>& animations, double animationPlaybac kRate) 668 void CompositorAnimationsImpl::getAnimationOnCompositor(const Timing& timing, in t group, double startTime, double timeOffset, const KeyframeEffectModelBase& eff ect, Vector<OwnPtr<CompositorAnimation>>& animations, double animationPlaybackRa te)
668 { 669 {
669 ASSERT(animations.isEmpty()); 670 ASSERT(animations.isEmpty());
670 CompositorTiming compositorTiming; 671 CompositorTiming compositorTiming;
671 bool timingValid = convertTimingForCompositor(timing, timeOffset, compositor Timing, animationPlaybackRate); 672 bool timingValid = convertTimingForCompositor(timing, timeOffset, compositor Timing, animationPlaybackRate);
672 ASSERT_UNUSED(timingValid, timingValid); 673 ASSERT_UNUSED(timingValid, timingValid);
673 674
674 PropertyHandleSet properties = effect.properties(); 675 PropertyHandleSet properties = effect.properties();
675 ASSERT(!properties.isEmpty()); 676 ASSERT(!properties.isEmpty());
676 for (const auto& property : properties) { 677 for (const auto& property : properties) {
677 PropertySpecificKeyframeVector values; 678 PropertySpecificKeyframeVector values;
678 getKeyframeValuesForProperty(&effect, property, compositorTiming.scaledD uration, values); 679 getKeyframeValuesForProperty(&effect, property, compositorTiming.scaledD uration, values);
679 680
680 WebCompositorAnimation::TargetProperty targetProperty; 681 CompositorAnimation::TargetProperty targetProperty;
681 OwnPtr<WebCompositorAnimationCurve> curve; 682 OwnPtr<CompositorAnimationCurve> curve;
682 switch (property.cssProperty()) { 683 switch (property.cssProperty()) {
683 case CSSPropertyOpacity: { 684 case CSSPropertyOpacity: {
684 targetProperty = WebCompositorAnimation::TargetPropertyOpacity; 685 targetProperty = CompositorAnimation::TargetPropertyOpacity;
685 686
686 WebFloatAnimationCurve* floatCurve = Platform::current()->compositor Support()->createFloatAnimationCurve(); 687 CompositorFloatAnimationCurve* floatCurve = CompositorFactory::curre nt().createFloatAnimationCurve();
687 addKeyframesToCurve(*floatCurve, values, timing); 688 addKeyframesToCurve(*floatCurve, values, timing);
688 setTimingFunctionOnCurve(*floatCurve, timing.timingFunction.get()); 689 setTimingFunctionOnCurve(*floatCurve, timing.timingFunction.get());
689 curve = adoptPtr(floatCurve); 690 curve = adoptPtr(floatCurve);
690 break; 691 break;
691 } 692 }
692 case CSSPropertyWebkitFilter: 693 case CSSPropertyWebkitFilter:
693 case CSSPropertyBackdropFilter: { 694 case CSSPropertyBackdropFilter: {
694 targetProperty = WebCompositorAnimation::TargetPropertyFilter; 695 targetProperty = CompositorAnimation::TargetPropertyFilter;
695 WebFilterAnimationCurve* filterCurve = Platform::current()->composit orSupport()->createFilterAnimationCurve(); 696 CompositorFilterAnimationCurve* filterCurve = CompositorFactory::cur rent().createFilterAnimationCurve();
696 addKeyframesToCurve(*filterCurve, values, timing); 697 addKeyframesToCurve(*filterCurve, values, timing);
697 setTimingFunctionOnCurve(*filterCurve, timing.timingFunction.get()); 698 setTimingFunctionOnCurve(*filterCurve, timing.timingFunction.get());
698 curve = adoptPtr(filterCurve); 699 curve = adoptPtr(filterCurve);
699 break; 700 break;
700 } 701 }
701 case CSSPropertyRotate: 702 case CSSPropertyRotate:
702 case CSSPropertyScale: 703 case CSSPropertyScale:
703 case CSSPropertyTranslate: 704 case CSSPropertyTranslate:
704 case CSSPropertyTransform: { 705 case CSSPropertyTransform: {
705 targetProperty = WebCompositorAnimation::TargetPropertyTransform; 706 targetProperty = CompositorAnimation::TargetPropertyTransform;
706 WebTransformAnimationCurve* transformCurve = Platform::current()->co mpositorSupport()->createTransformAnimationCurve(); 707 CompositorTransformAnimationCurve* transformCurve = CompositorFactor y::current().createTransformAnimationCurve();
707 addKeyframesToCurve(*transformCurve, values, timing); 708 addKeyframesToCurve(*transformCurve, values, timing);
708 setTimingFunctionOnCurve(*transformCurve, timing.timingFunction.get( )); 709 setTimingFunctionOnCurve(*transformCurve, timing.timingFunction.get( ));
709 curve = adoptPtr(transformCurve); 710 curve = adoptPtr(transformCurve);
710 break; 711 break;
711 } 712 }
712 default: 713 default:
713 ASSERT_NOT_REACHED(); 714 ASSERT_NOT_REACHED();
714 continue; 715 continue;
715 } 716 }
716 ASSERT(curve.get()); 717 ASSERT(curve.get());
717 718
718 OwnPtr<WebCompositorAnimation> animation = adoptPtr(Platform::current()- >compositorSupport()->createAnimation(*curve, targetProperty, group, 0)); 719 OwnPtr<CompositorAnimation> animation = adoptPtr(CompositorFactory::curr ent().createAnimation(*curve, targetProperty, group, 0));
719 720
720 if (!std::isnan(startTime)) 721 if (!std::isnan(startTime))
721 animation->setStartTime(startTime); 722 animation->setStartTime(startTime);
722 723
723 animation->setIterations(compositorTiming.adjustedIterationCount); 724 animation->setIterations(compositorTiming.adjustedIterationCount);
724 animation->setIterationStart(compositorTiming.iterationStart); 725 animation->setIterationStart(compositorTiming.iterationStart);
725 animation->setTimeOffset(compositorTiming.scaledTimeOffset); 726 animation->setTimeOffset(compositorTiming.scaledTimeOffset);
726 727
727 switch (compositorTiming.direction) { 728 switch (compositorTiming.direction) {
728 case Timing::PlaybackDirectionNormal: 729 case Timing::PlaybackDirectionNormal:
729 animation->setDirection(WebCompositorAnimation::DirectionNormal); 730 animation->setDirection(CompositorAnimation::DirectionNormal);
730 break; 731 break;
731 case Timing::PlaybackDirectionReverse: 732 case Timing::PlaybackDirectionReverse:
732 animation->setDirection(WebCompositorAnimation::DirectionReverse); 733 animation->setDirection(CompositorAnimation::DirectionReverse);
733 break; 734 break;
734 case Timing::PlaybackDirectionAlternate: 735 case Timing::PlaybackDirectionAlternate:
735 animation->setDirection(WebCompositorAnimation::DirectionAlternate); 736 animation->setDirection(CompositorAnimation::DirectionAlternate);
736 break; 737 break;
737 case Timing::PlaybackDirectionAlternateReverse: 738 case Timing::PlaybackDirectionAlternateReverse:
738 animation->setDirection(WebCompositorAnimation::DirectionAlternateRe verse); 739 animation->setDirection(CompositorAnimation::DirectionAlternateRever se);
739 break; 740 break;
740 default: 741 default:
741 ASSERT_NOT_REACHED(); 742 ASSERT_NOT_REACHED();
742 } 743 }
743 animation->setPlaybackRate(compositorTiming.playbackRate); 744 animation->setPlaybackRate(compositorTiming.playbackRate);
744 745
745 switch (compositorTiming.fillMode) { 746 switch (compositorTiming.fillMode) {
746 case Timing::FillModeNone: 747 case Timing::FillModeNone:
747 animation->setFillMode(WebCompositorAnimation::FillModeNone); 748 animation->setFillMode(CompositorAnimation::FillModeNone);
748 break; 749 break;
749 case Timing::FillModeForwards: 750 case Timing::FillModeForwards:
750 animation->setFillMode(WebCompositorAnimation::FillModeForwards); 751 animation->setFillMode(CompositorAnimation::FillModeForwards);
751 break; 752 break;
752 case Timing::FillModeBackwards: 753 case Timing::FillModeBackwards:
753 animation->setFillMode(WebCompositorAnimation::FillModeBackwards); 754 animation->setFillMode(CompositorAnimation::FillModeBackwards);
754 break; 755 break;
755 case Timing::FillModeBoth: 756 case Timing::FillModeBoth:
756 animation->setFillMode(WebCompositorAnimation::FillModeBoth); 757 animation->setFillMode(CompositorAnimation::FillModeBoth);
757 break; 758 break;
758 default: 759 default:
759 ASSERT_NOT_REACHED(); 760 ASSERT_NOT_REACHED();
760 } 761 }
761 animations.append(animation.release()); 762 animations.append(animation.release());
762 } 763 }
763 ASSERT(!animations.isEmpty()); 764 ASSERT(!animations.isEmpty());
764 } 765 }
765 766
766 } // namespace blink 767 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698