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

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

Issue 51943004: Creating a helper class for reversing timing functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
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/rendering/RenderLayer.h" 36 #include "core/rendering/RenderLayer.h"
37 #include "core/rendering/RenderObject.h" 37 #include "core/rendering/RenderObject.h"
38 #include "public/platform/Platform.h" 38 #include "public/platform/Platform.h"
39 #include "public/platform/WebAnimation.h" 39 #include "public/platform/WebAnimation.h"
40 #include "public/platform/WebCompositorSupport.h" 40 #include "public/platform/WebCompositorSupport.h"
41 #include "public/platform/WebFloatAnimationCurve.h" 41 #include "public/platform/WebFloatAnimationCurve.h"
42 #include "public/platform/WebFloatKeyframe.h" 42 #include "public/platform/WebFloatKeyframe.h"
43 43
44 namespace WebCore { 44 namespace WebCore {
45 45
46 // -----------------------------------------------------------------------
47
48 PassRefPtr<TimingFunction> CompositorAnimationsTimingFunctionReverser::reverse(c onst LinearTimingFunction* timefunc)
49 {
50 return const_cast<LinearTimingFunction*>(timefunc);
51 }
52
53 PassRefPtr<TimingFunction> CompositorAnimationsTimingFunctionReverser::reverse(c onst CubicBezierTimingFunction* timefunc)
54 {
55 switch (timefunc->subType()) {
56 case CubicBezierTimingFunction::EaseIn:
57 return CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Ease Out);
58 case CubicBezierTimingFunction::EaseOut:
59 return CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Ease In);
60 case CubicBezierTimingFunction::EaseInOut:
61 return const_cast<CubicBezierTimingFunction*>(timefunc);
62 case CubicBezierTimingFunction::Ease: // Ease is not symmetrical
63 case CubicBezierTimingFunction::Custom:
64 // Flip the timing function in x. We also have to flip it in y to
65 // maintain the invariant that it runs from (0, 0) to (1, 1).
Steve Block 2013/11/06 06:06:23 You can probably remove this, given the comment in
mithro-old 2013/11/07 00:56:59 Done.
66 return CubicBezierTimingFunction::create(1 - timefunc->x2(), 1 - timefun c->y2(), 1 - timefunc->x1(), 1 - timefunc->y1());
67 default:
68 ASSERT_NOT_REACHED();
69 }
70 }
71
72 PassRefPtr<TimingFunction> CompositorAnimationsTimingFunctionReverser::reverse(c onst ChainedTimingFunction* timefunc)
73 {
74 RefPtr<ChainedTimingFunction> reversed = ChainedTimingFunction::create();
75 for (size_t i = 0; i < timefunc->m_segments.size(); i++) {
76 size_t index = timefunc->m_segments.size() - i - 1;
77
78 RefPtr<TimingFunction> rtf = reverse(timefunc->m_segments[index].m_timin gFunction.get());
79 reversed->appendSegment(1 - timefunc->m_segments[index].m_min, rtf.get() );
80 }
81 return reversed;
82 }
83
84 PassRefPtr<TimingFunction> CompositorAnimationsTimingFunctionReverser::reverse(c onst TimingFunction* timefunc)
85 {
86 switch (timefunc->type()) {
87 case TimingFunction::LinearFunction: {
88 const LinearTimingFunction* linear = static_cast<const LinearTimingFunct ion*>(timefunc);
89 return reverse(linear);
90 }
91 case TimingFunction::CubicBezierFunction: {
92 const CubicBezierTimingFunction* cubic = static_cast<const CubicBezierTi mingFunction*>(timefunc);
93 return reverse(cubic);
94 }
95 case TimingFunction::ChainedFunction: {
96 const ChainedTimingFunction* chained = static_cast<const ChainedTimingFu nction*>(timefunc);
97 return reverse(chained);
98 }
99
100 // Steps function can not be reversed.
101 case TimingFunction::StepsFunction:
102 default:
103 ASSERT_NOT_REACHED();
104 }
105 }
106
107 // -----------------------------------------------------------------------
108
109
46 bool CompositorAnimations::isCandidateForCompositorAnimation(const Timing& timin g, const AnimationEffect* effect) 110 bool CompositorAnimations::isCandidateForCompositorAnimation(const Timing& timin g, const AnimationEffect* effect)
47 { 111 {
48 // FIXME: Implement. 112 // FIXME: Implement.
49 ASSERT_NOT_REACHED(); 113 ASSERT_NOT_REACHED();
50 return false; 114 return false;
51 } 115 }
52 116
53 bool CompositorAnimations::canStartCompositorAnimation(const Element* element) 117 bool CompositorAnimations::canStartCompositorAnimation(const Element* element)
54 { 118 {
55 return element->renderer() && element->renderer()->compositingState() == Pai ntsIntoOwnBacking; 119 return element->renderer() && element->renderer()->compositingState() == Pai ntsIntoOwnBacking;
56 } 120 }
57 121
58 void CompositorAnimations::startCompositorAnimation(const Element* element, cons t Timing&, const AnimationEffect*, Vector<int>& startedAnimationIds) 122 void CompositorAnimations::startCompositorAnimation(const Element* element, cons t Timing&, const AnimationEffect*, Vector<int>& startedAnimationIds)
59 { 123 {
60 // FIXME: Implement. 124 // FIXME: Implement.
61 ASSERT_NOT_REACHED(); 125 ASSERT_NOT_REACHED();
62 } 126 }
63 127
64 void CompositorAnimations::cancelCompositorAnimation(const Element* element, int id) 128 void CompositorAnimations::cancelCompositorAnimation(const Element* element, int id)
65 { 129 {
66 // FIXME: Implement. 130 // FIXME: Implement.
67 ASSERT_NOT_REACHED(); 131 ASSERT_NOT_REACHED();
68 } 132 }
69 133
70 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698