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

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

Issue 23874019: Web Animations CSS: Start running animations on the compositor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase and rename hasActiveAnimationOnCompositor to hasActiveAnimationsOnCompositor Created 7 years, 1 month 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 return CompositorAnimationsImpl::isCandidateForCompositor(t, frames); 108 return CompositorAnimationsImpl::isCandidateForCompositor(t, frames);
109 } 109 }
110 bool isCandidateForCompositor(const Keyframe& k) 110 bool isCandidateForCompositor(const Keyframe& k)
111 { 111 {
112 return CompositorAnimationsImpl::isCandidateForCompositor(k); 112 return CompositorAnimationsImpl::isCandidateForCompositor(k);
113 } 113 }
114 bool isCandidateForCompositor(const KeyframeAnimationEffect& k) 114 bool isCandidateForCompositor(const KeyframeAnimationEffect& k)
115 { 115 {
116 return CompositorAnimationsImpl::isCandidateForCompositor(k); 116 return CompositorAnimationsImpl::isCandidateForCompositor(k);
117 } 117 }
118 void getCompositorAnimations(Timing& timing, KeyframeAnimationEffect& effect , Vector<OwnPtr<blink::WebAnimation> >& animations, const IntSize& size = empty) 118 void getAnimationOnCompositor(Timing& timing, KeyframeAnimationEffect& effec t, Vector<OwnPtr<blink::WebAnimation> >& animations, const IntSize& size = empty )
119 { 119 {
120 return CompositorAnimationsImpl::getCompositorAnimations(timing, effect, animations, size); 120 return CompositorAnimationsImpl::getAnimationOnCompositor(timing, effect , animations, size);
121 } 121 }
122 122
123 static IntSize empty; 123 static IntSize empty;
124 124
125 // ------------------------------------------------------------------- 125 // -------------------------------------------------------------------
126 126
127 Timing createCompositableTiming() 127 Timing createCompositableTiming()
128 { 128 {
129 Timing timing; 129 Timing timing;
130 timing.startDelay = 0; 130 timing.startDelay = 0;
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 chainedTimingFunc->appendSegment(0.5, m_linearTimingFunction.get()); 704 chainedTimingFunc->appendSegment(0.5, m_linearTimingFunction.get());
705 chainedTimingFunc->appendSegment(1.0, cubicTimingFunc.get()); 705 chainedTimingFunc->appendSegment(1.0, cubicTimingFunc.get());
706 Timing chainedTiming(createCompositableTiming()); 706 Timing chainedTiming(createCompositableTiming());
707 chainedTiming.timingFunction = chainedTimingFunc; 707 chainedTiming.timingFunction = chainedTimingFunc;
708 708
709 KeyframeAnimationEffect::KeyframeVector basicFramesVector; 709 KeyframeAnimationEffect::KeyframeVector basicFramesVector;
710 basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animation Effect::CompositeReplace, 0.0).get()); 710 basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animation Effect::CompositeReplace, 0.0).get());
711 basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animation Effect::CompositeReplace, 1.0).get()); 711 basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animation Effect::CompositeReplace, 1.0).get());
712 RefPtr<KeyframeAnimationEffect> basicFrames = KeyframeAnimationEffect::creat e(basicFramesVector).get(); 712 RefPtr<KeyframeAnimationEffect> basicFrames = KeyframeAnimationEffect::creat e(basicFramesVector).get();
713 713
714 EXPECT_TRUE(CompositorAnimations::instance()->isCandidateForCompositorAnimat ion(linearTiming, *basicFrames.get())); 714 EXPECT_TRUE(CompositorAnimations::instance()->isCandidateForAnimationOnCompo sitor(linearTiming, *basicFrames.get()));
715 EXPECT_TRUE(CompositorAnimations::instance()->isCandidateForCompositorAnimat ion(cubicTiming, *basicFrames.get())); 715 EXPECT_TRUE(CompositorAnimations::instance()->isCandidateForAnimationOnCompo sitor(cubicTiming, *basicFrames.get()));
716 // number of timing function and keyframes don't match 716 // number of timing function and keyframes don't match
717 EXPECT_FALSE(CompositorAnimations::instance()->isCandidateForCompositorAnima tion(chainedTiming, *basicFrames.get())); 717 EXPECT_FALSE(CompositorAnimations::instance()->isCandidateForAnimationOnComp ositor(chainedTiming, *basicFrames.get()));
718 718
719 KeyframeAnimationEffect::KeyframeVector nonBasicFramesVector; 719 KeyframeAnimationEffect::KeyframeVector nonBasicFramesVector;
720 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animat ionEffect::CompositeReplace, 0.0).get()); 720 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animat ionEffect::CompositeReplace, 0.0).get());
721 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animat ionEffect::CompositeReplace, 0.5).get()); 721 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animat ionEffect::CompositeReplace, 0.5).get());
722 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animat ionEffect::CompositeReplace, 1.0).get()); 722 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animat ionEffect::CompositeReplace, 1.0).get());
723 RefPtr<KeyframeAnimationEffect> nonBasicFrames = KeyframeAnimationEffect::cr eate(nonBasicFramesVector).get(); 723 RefPtr<KeyframeAnimationEffect> nonBasicFrames = KeyframeAnimationEffect::cr eate(nonBasicFramesVector).get();
724 724
725 EXPECT_TRUE(CompositorAnimations::instance()->isCandidateForCompositorAnimat ion(linearTiming, *nonBasicFrames.get())); 725 EXPECT_TRUE(CompositorAnimations::instance()->isCandidateForAnimationOnCompo sitor(linearTiming, *nonBasicFrames.get()));
726 EXPECT_FALSE(CompositorAnimations::instance()->isCandidateForCompositorAnima tion(cubicTiming, *nonBasicFrames.get())); 726 EXPECT_FALSE(CompositorAnimations::instance()->isCandidateForAnimationOnComp ositor(cubicTiming, *nonBasicFrames.get()));
727 EXPECT_TRUE(CompositorAnimations::instance()->isCandidateForCompositorAnimat ion(chainedTiming, *nonBasicFrames.get())); 727 EXPECT_TRUE(CompositorAnimations::instance()->isCandidateForAnimationOnCompo sitor(chainedTiming, *nonBasicFrames.get()));
728 } 728 }
729 729
730 // ----------------------------------------------------------------------- 730 // -----------------------------------------------------------------------
731 // ----------------------------------------------------------------------- 731 // -----------------------------------------------------------------------
732 732
733 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimation) 733 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimation)
734 { 734 {
735 // Animation to convert 735 // Animation to convert
736 RefPtr<KeyframeAnimationEffect> effect = createKeyframeAnimationEffect( 736 RefPtr<KeyframeAnimationEffect> effect = createKeyframeAnimationEffect(
737 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), 737 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0),
(...skipping 25 matching lines...) Expand all
763 EXPECT_CALL(*mockAnimationPtr, delete_()) 763 EXPECT_CALL(*mockAnimationPtr, delete_())
764 .Times(1) 764 .Times(1)
765 .After(usesMockAnimation); 765 .After(usesMockAnimation);
766 EXPECT_CALL(*mockCurvePtr, delete_()) 766 EXPECT_CALL(*mockCurvePtr, delete_())
767 .Times(1) 767 .Times(1)
768 .After(usesMockCurve); 768 .After(usesMockCurve);
769 769
770 // Go! 770 // Go!
771 setCompositorForTesting(mockCompositor); 771 setCompositorForTesting(mockCompositor);
772 Vector<OwnPtr<blink::WebAnimation> > result; 772 Vector<OwnPtr<blink::WebAnimation> > result;
773 getCompositorAnimations(m_timing, *effect.get(), result); 773 getAnimationOnCompositor(m_timing, *effect.get(), result);
774 EXPECT_EQ(1U, result.size()); 774 EXPECT_EQ(1U, result.size());
775 result[0].clear(); 775 result[0].clear();
776 } 776 }
777 777
778 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration) 778 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration)
779 { 779 {
780 // Animation to convert 780 // Animation to convert
781 RefPtr<KeyframeAnimationEffect> effect = createKeyframeAnimationEffect( 781 RefPtr<KeyframeAnimationEffect> effect = createKeyframeAnimationEffect(
782 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), 782 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0),
783 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); 783 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0));
(...skipping 26 matching lines...) Expand all
810 EXPECT_CALL(*mockAnimationPtr, delete_()) 810 EXPECT_CALL(*mockAnimationPtr, delete_())
811 .Times(1) 811 .Times(1)
812 .After(usesMockAnimation); 812 .After(usesMockAnimation);
813 EXPECT_CALL(*mockCurvePtr, delete_()) 813 EXPECT_CALL(*mockCurvePtr, delete_())
814 .Times(1) 814 .Times(1)
815 .After(usesMockCurve); 815 .After(usesMockCurve);
816 816
817 // Go! 817 // Go!
818 setCompositorForTesting(mockCompositor); 818 setCompositorForTesting(mockCompositor);
819 Vector<OwnPtr<blink::WebAnimation> > result; 819 Vector<OwnPtr<blink::WebAnimation> > result;
820 getCompositorAnimations(m_timing, *effect.get(), result); 820 getAnimationOnCompositor(m_timing, *effect.get(), result);
821 EXPECT_EQ(1U, result.size()); 821 EXPECT_EQ(1U, result.size());
822 result[0].clear(); 822 result[0].clear();
823 } 823 }
824 824
825 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation Linear) 825 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation Linear)
826 { 826 {
827 // Animation to convert 827 // Animation to convert
828 RefPtr<KeyframeAnimationEffect> effect = createKeyframeAnimationEffect( 828 RefPtr<KeyframeAnimationEffect> effect = createKeyframeAnimationEffect(
829 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), 829 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0),
830 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1. 0).get(), 0.25), 830 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1. 0).get(), 0.25),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 EXPECT_CALL(*mockAnimationPtr, delete_()) 863 EXPECT_CALL(*mockAnimationPtr, delete_())
864 .Times(1) 864 .Times(1)
865 .After(usesMockAnimation); 865 .After(usesMockAnimation);
866 EXPECT_CALL(*mockCurvePtr, delete_()) 866 EXPECT_CALL(*mockCurvePtr, delete_())
867 .Times(1) 867 .Times(1)
868 .After(usesMockCurve); 868 .After(usesMockCurve);
869 869
870 // Go! 870 // Go!
871 setCompositorForTesting(mockCompositor); 871 setCompositorForTesting(mockCompositor);
872 Vector<OwnPtr<blink::WebAnimation> > result; 872 Vector<OwnPtr<blink::WebAnimation> > result;
873 getCompositorAnimations(m_timing, *effect.get(), result); 873 getAnimationOnCompositor(m_timing, *effect.get(), result);
874 EXPECT_EQ(1U, result.size()); 874 EXPECT_EQ(1U, result.size());
875 result[0].clear(); 875 result[0].clear();
876 } 876 }
877 877
878 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationNegativeSt artDelay) 878 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationNegativeSt artDelay)
879 { 879 {
880 // Animation to convert 880 // Animation to convert
881 RefPtr<KeyframeAnimationEffect> effect = createKeyframeAnimationEffect( 881 RefPtr<KeyframeAnimationEffect> effect = createKeyframeAnimationEffect(
882 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), 882 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0),
883 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); 883 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0));
(...skipping 28 matching lines...) Expand all
912 EXPECT_CALL(*mockAnimationPtr, delete_()) 912 EXPECT_CALL(*mockAnimationPtr, delete_())
913 .Times(1) 913 .Times(1)
914 .After(usesMockAnimation); 914 .After(usesMockAnimation);
915 EXPECT_CALL(*mockCurvePtr, delete_()) 915 EXPECT_CALL(*mockCurvePtr, delete_())
916 .Times(1) 916 .Times(1)
917 .After(usesMockCurve); 917 .After(usesMockCurve);
918 918
919 // Go! 919 // Go!
920 setCompositorForTesting(mockCompositor); 920 setCompositorForTesting(mockCompositor);
921 Vector<OwnPtr<blink::WebAnimation> > result; 921 Vector<OwnPtr<blink::WebAnimation> > result;
922 getCompositorAnimations(m_timing, *effect.get(), result); 922 getAnimationOnCompositor(m_timing, *effect.get(), result);
923 EXPECT_EQ(1U, result.size()); 923 EXPECT_EQ(1U, result.size());
924 result[0].clear(); 924 result[0].clear();
925 } 925 }
926 926
927 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation Chained) 927 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation Chained)
928 { 928 {
929 // Animation to convert 929 // Animation to convert
930 RefPtr<KeyframeAnimationEffect> effect = createKeyframeAnimationEffect( 930 RefPtr<KeyframeAnimationEffect> effect = createKeyframeAnimationEffect(
931 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), 931 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0),
932 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1. 0).get(), 0.25), 932 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1. 0).get(), 0.25),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 EXPECT_CALL(*mockAnimationPtr, delete_()) 972 EXPECT_CALL(*mockAnimationPtr, delete_())
973 .Times(1) 973 .Times(1)
974 .After(usesMockAnimation); 974 .After(usesMockAnimation);
975 EXPECT_CALL(*mockCurvePtr, delete_()) 975 EXPECT_CALL(*mockCurvePtr, delete_())
976 .Times(1) 976 .Times(1)
977 .After(usesMockCurve); 977 .After(usesMockCurve);
978 978
979 // Go! 979 // Go!
980 setCompositorForTesting(mockCompositor); 980 setCompositorForTesting(mockCompositor);
981 Vector<OwnPtr<blink::WebAnimation> > result; 981 Vector<OwnPtr<blink::WebAnimation> > result;
982 getCompositorAnimations(m_timing, *effect.get(), result); 982 getAnimationOnCompositor(m_timing, *effect.get(), result);
983 EXPECT_EQ(1U, result.size()); 983 EXPECT_EQ(1U, result.size());
984 result[0].clear(); 984 result[0].clear();
985 } 985 }
986 986
987 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) 987 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation)
988 { 988 {
989 // Animation to convert 989 // Animation to convert
990 RefPtr<KeyframeAnimationEffect> effect = createKeyframeAnimationEffect( 990 RefPtr<KeyframeAnimationEffect> effect = createKeyframeAnimationEffect(
991 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), 991 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0),
992 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1. 0).get(), 0.25), 992 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1. 0).get(), 0.25),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 EXPECT_CALL(*mockAnimationPtr, delete_()) 1032 EXPECT_CALL(*mockAnimationPtr, delete_())
1033 .Times(1) 1033 .Times(1)
1034 .After(usesMockAnimation); 1034 .After(usesMockAnimation);
1035 EXPECT_CALL(*mockCurvePtr, delete_()) 1035 EXPECT_CALL(*mockCurvePtr, delete_())
1036 .Times(1) 1036 .Times(1)
1037 .After(usesMockCurve); 1037 .After(usesMockCurve);
1038 1038
1039 // Go! 1039 // Go!
1040 setCompositorForTesting(mockCompositor); 1040 setCompositorForTesting(mockCompositor);
1041 Vector<OwnPtr<blink::WebAnimation> > result; 1041 Vector<OwnPtr<blink::WebAnimation> > result;
1042 getCompositorAnimations(m_timing, *effect.get(), result); 1042 getAnimationOnCompositor(m_timing, *effect.get(), result);
1043 EXPECT_EQ(1U, result.size()); 1043 EXPECT_EQ(1U, result.size());
1044 result[0].clear(); 1044 result[0].clear();
1045 } 1045 }
1046 1046
1047 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegative StartDelay) 1047 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegative StartDelay)
1048 { 1048 {
1049 // Animation to convert 1049 // Animation to convert
1050 RefPtr<KeyframeAnimationEffect> effect = createKeyframeAnimationEffect( 1050 RefPtr<KeyframeAnimationEffect> effect = createKeyframeAnimationEffect(
1051 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), 1051 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0),
1052 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); 1052 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0));
(...skipping 29 matching lines...) Expand all
1082 EXPECT_CALL(*mockAnimationPtr, delete_()) 1082 EXPECT_CALL(*mockAnimationPtr, delete_())
1083 .Times(1) 1083 .Times(1)
1084 .After(usesMockAnimation); 1084 .After(usesMockAnimation);
1085 EXPECT_CALL(*mockCurvePtr, delete_()) 1085 EXPECT_CALL(*mockCurvePtr, delete_())
1086 .Times(1) 1086 .Times(1)
1087 .After(usesMockCurve); 1087 .After(usesMockCurve);
1088 1088
1089 // Go! 1089 // Go!
1090 setCompositorForTesting(mockCompositor); 1090 setCompositorForTesting(mockCompositor);
1091 Vector<OwnPtr<blink::WebAnimation> > result; 1091 Vector<OwnPtr<blink::WebAnimation> > result;
1092 getCompositorAnimations(m_timing, *effect.get(), result); 1092 getAnimationOnCompositor(m_timing, *effect.get(), result);
1093 EXPECT_EQ(1U, result.size()); 1093 EXPECT_EQ(1U, result.size());
1094 result[0].clear(); 1094 result[0].clear();
1095 } 1095 }
1096 1096
1097 1097
1098 } // namespace WebCore 1098 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/animation/CompositorAnimationsImpl.h ('k') | Source/core/animation/DocumentTimeline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698