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

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: Fix ScrollAnimatorCompositorCoordinator for MSVC. 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 24 matching lines...) Expand all
35 #include "core/animation/CompositorAnimationsImpl.h" 35 #include "core/animation/CompositorAnimationsImpl.h"
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/CompositorFactory.h"
45 #include "platform/RuntimeEnabledFeatures.h" 46 #include "platform/RuntimeEnabledFeatures.h"
47 #include "platform/animation/WebCompositorAnimation.h"
48 #include "platform/animation/WebCompositorAnimationPlayer.h"
49 #include "platform/animation/WebFilterAnimationCurve.h"
50 #include "platform/animation/WebFilterKeyframe.h"
51 #include "platform/animation/WebFloatAnimationCurve.h"
52 #include "platform/animation/WebFloatKeyframe.h"
53 #include "platform/animation/WebTransformAnimationCurve.h"
54 #include "platform/animation/WebTransformKeyframe.h"
46 #include "platform/geometry/FloatBox.h" 55 #include "platform/geometry/FloatBox.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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 WebCompositorAnimationCurve::AnimationCurveTypeFilter: {
638 OwnPtr<WebFilterOperations> ops = adoptPtr(Platform::current()->comp ositorSupport()->createFilterOperations()); 639 OwnPtr<WebFilterOperations> ops = adoptPtr(CompositorFactory::curren t().createFilterOperations());
639 toWebFilterOperations(toAnimatableFilterOperations(value)->operation s(), ops.get()); 640 toWebFilterOperations(toAnimatableFilterOperations(value)->operation s(), ops.get());
640 641
641 WebFilterKeyframe filterKeyframe(keyframe->offset(), ops.release()); 642 WebFilterKeyframe filterKeyframe(keyframe->offset(), ops.release());
642 WebFilterAnimationCurve* filterCurve = static_cast<WebFilterAnimatio nCurve*>(&curve); 643 WebFilterAnimationCurve* filterCurve = static_cast<WebFilterAnimatio nCurve*>(&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 WebCompositorAnimationCurve::AnimationCurveTypeFloat: {
647 WebFloatKeyframe floatKeyframe(keyframe->offset(), toAnimatableDoubl e(value)->toDouble()); 648 WebFloatKeyframe floatKeyframe(keyframe->offset(), toAnimatableDoubl e(value)->toDouble());
648 WebFloatAnimationCurve* floatCurve = static_cast<WebFloatAnimationCu rve*>(&curve); 649 WebFloatAnimationCurve* floatCurve = static_cast<WebFloatAnimationCu rve*>(&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 WebCompositorAnimationCurve::AnimationCurveTypeTransform: {
653 OwnPtr<WebTransformOperations> ops = adoptPtr(Platform::current()->c ompositorSupport()->createTransformOperations()); 654 OwnPtr<WebTransformOperations> ops = adoptPtr(CompositorFactory::cur rent().createTransformOperations());
654 toWebTransformOperations(toAnimatableTransform(value)->transformOper ations(), ops.get()); 655 toWebTransformOperations(toAnimatableTransform(value)->transformOper ations(), ops.get());
655 656
656 WebTransformKeyframe transformKeyframe(keyframe->offset(), ops.relea se()); 657 WebTransformKeyframe transformKeyframe(keyframe->offset(), ops.relea se());
657 WebTransformAnimationCurve* transformCurve = static_cast<WebTransfor mAnimationCurve*>(&curve); 658 WebTransformAnimationCurve* transformCurve = static_cast<WebTransfor mAnimationCurve*>(&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 }
(...skipping 12 matching lines...) Expand all
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 WebCompositorAnimation::TargetProperty targetProperty;
681 OwnPtr<WebCompositorAnimationCurve> curve; 682 OwnPtr<WebCompositorAnimationCurve> curve;
682 switch (property.cssProperty()) { 683 switch (property.cssProperty()) {
683 case CSSPropertyOpacity: { 684 case CSSPropertyOpacity: {
684 targetProperty = WebCompositorAnimation::TargetPropertyOpacity; 685 targetProperty = WebCompositorAnimation::TargetPropertyOpacity;
685 686
686 WebFloatAnimationCurve* floatCurve = Platform::current()->compositor Support()->createFloatAnimationCurve(); 687 WebFloatAnimationCurve* floatCurve = CompositorFactory::current().cr eateFloatAnimationCurve();
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 = WebCompositorAnimation::TargetPropertyFilter;
695 WebFilterAnimationCurve* filterCurve = Platform::current()->composit orSupport()->createFilterAnimationCurve(); 696 WebFilterAnimationCurve* filterCurve = CompositorFactory::current(). 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 = WebCompositorAnimation::TargetPropertyTransform;
706 WebTransformAnimationCurve* transformCurve = Platform::current()->co mpositorSupport()->createTransformAnimationCurve(); 707 WebTransformAnimationCurve* transformCurve = CompositorFactory::curr ent().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<WebCompositorAnimation> animation = adoptPtr(CompositorFactory::c urrent().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:
(...skipping 28 matching lines...) Expand all
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