OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "platform/animation/CompositorFilterAnimationCurve.h" |
| 6 |
| 7 #include "cc/animation/keyframed_animation_curve.h" |
| 8 #include "cc/animation/timing_function.h" |
| 9 #include "cc/output/filter_operations.h" |
| 10 #include "platform/graphics/CompositorFilterOperations.h" |
| 11 |
| 12 using blink::CompositorFilterKeyframe; |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 CompositorFilterAnimationCurve::CompositorFilterAnimationCurve() |
| 17 : m_curve(cc::KeyframedFilterAnimationCurve::Create()) |
| 18 { |
| 19 } |
| 20 |
| 21 CompositorFilterAnimationCurve::~CompositorFilterAnimationCurve() |
| 22 { |
| 23 } |
| 24 |
| 25 blink::CompositorAnimationCurve::AnimationCurveType CompositorFilterAnimationCur
ve::type() const |
| 26 { |
| 27 return CompositorAnimationCurve::AnimationCurveTypeFilter; |
| 28 } |
| 29 |
| 30 void CompositorFilterAnimationCurve::add(const CompositorFilterKeyframe& keyfram
e, TimingFunctionType type) |
| 31 { |
| 32 const cc::FilterOperations& filterOperations = keyframe.value().asFilterOper
ations(); |
| 33 m_curve->AddKeyframe(cc::FilterKeyframe::Create( |
| 34 base::TimeDelta::FromSecondsD(keyframe.time()), filterOperations, |
| 35 createTimingFunction(type))); |
| 36 } |
| 37 |
| 38 void CompositorFilterAnimationCurve::add(const CompositorFilterKeyframe& keyfram
e, double x1, double y1, double x2, double y2) |
| 39 { |
| 40 const cc::FilterOperations& filterOperations = keyframe.value().asFilterOper
ations(); |
| 41 m_curve->AddKeyframe(cc::FilterKeyframe::Create( |
| 42 base::TimeDelta::FromSecondsD(keyframe.time()), filterOperations, |
| 43 cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2))); |
| 44 } |
| 45 |
| 46 void CompositorFilterAnimationCurve::add(const CompositorFilterKeyframe& keyfram
e, int steps, float stepsStartOffset) |
| 47 { |
| 48 const cc::FilterOperations& filterOperations = keyframe.value().asFilterOper
ations(); |
| 49 m_curve->AddKeyframe(cc::FilterKeyframe::Create( |
| 50 base::TimeDelta::FromSecondsD(keyframe.time()), filterOperations, |
| 51 cc::StepsTimingFunction::Create(steps, stepsStartOffset))); |
| 52 } |
| 53 |
| 54 void CompositorFilterAnimationCurve::setLinearTimingFunction() |
| 55 { |
| 56 m_curve->SetTimingFunction(nullptr); |
| 57 } |
| 58 |
| 59 void CompositorFilterAnimationCurve::setCubicBezierTimingFunction(TimingFunction
Type type) |
| 60 { |
| 61 m_curve->SetTimingFunction(createTimingFunction(type)); |
| 62 } |
| 63 |
| 64 void CompositorFilterAnimationCurve::setCubicBezierTimingFunction(double x1, dou
ble y1, double x2, double y2) |
| 65 { |
| 66 m_curve->SetTimingFunction(cc::CubicBezierTimingFunction::Create(x1, y1, x2,
y2)); |
| 67 } |
| 68 |
| 69 void CompositorFilterAnimationCurve::setStepsTimingFunction(int numberOfSteps, f
loat stepsStartOffset) |
| 70 { |
| 71 m_curve->SetTimingFunction(cc::StepsTimingFunction::Create(numberOfSteps, st
epsStartOffset)); |
| 72 } |
| 73 |
| 74 scoped_ptr<cc::AnimationCurve> CompositorFilterAnimationCurve::cloneToAnimationC
urve() const |
| 75 { |
| 76 return m_curve->Clone(); |
| 77 } |
| 78 |
| 79 } // namespace blink |
OLD | NEW |