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/WebFilterAnimationCurve.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/animation/WebFilterOperations.h" |
| 11 |
| 12 using blink::WebFilterKeyframe; |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 WebFilterAnimationCurve::WebFilterAnimationCurve() |
| 17 : m_curve(cc::KeyframedFilterAnimationCurve::Create()) |
| 18 { |
| 19 } |
| 20 |
| 21 WebFilterAnimationCurve::~WebFilterAnimationCurve() |
| 22 { |
| 23 } |
| 24 |
| 25 blink::WebCompositorAnimationCurve::AnimationCurveType |
| 26 WebFilterAnimationCurve::type() const |
| 27 { |
| 28 return WebCompositorAnimationCurve::AnimationCurveTypeFilter; |
| 29 } |
| 30 |
| 31 void WebFilterAnimationCurve::add(const WebFilterKeyframe& keyframe, |
| 32 TimingFunctionType type) |
| 33 { |
| 34 const cc::FilterOperations& filterOperations = keyframe.value().AsFilterOper
ations(); |
| 35 m_curve->AddKeyframe(cc::FilterKeyframe::Create( |
| 36 base::TimeDelta::FromSecondsD(keyframe.time()), filterOperations, |
| 37 CreateTimingFunction(type))); |
| 38 } |
| 39 |
| 40 void WebFilterAnimationCurve::add(const WebFilterKeyframe& keyframe, |
| 41 double x1, |
| 42 double y1, |
| 43 double x2, |
| 44 double y2) |
| 45 { |
| 46 const cc::FilterOperations& filterOperations = keyframe.value().AsFilterOper
ations(); |
| 47 m_curve->AddKeyframe(cc::FilterKeyframe::Create( |
| 48 base::TimeDelta::FromSecondsD(keyframe.time()), filterOperations, |
| 49 cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2))); |
| 50 } |
| 51 |
| 52 void WebFilterAnimationCurve::add(const WebFilterKeyframe& keyframe, |
| 53 int steps, |
| 54 float stepsStartOffset) |
| 55 { |
| 56 const cc::FilterOperations& filterOperations = keyframe.value().AsFilterOper
ations(); |
| 57 m_curve->AddKeyframe(cc::FilterKeyframe::Create( |
| 58 base::TimeDelta::FromSecondsD(keyframe.time()), filterOperations, |
| 59 cc::StepsTimingFunction::Create(steps, stepsStartOffset))); |
| 60 } |
| 61 |
| 62 void WebFilterAnimationCurve::setLinearTimingFunction() |
| 63 { |
| 64 m_curve->SetTimingFunction(nullptr); |
| 65 } |
| 66 |
| 67 void WebFilterAnimationCurve::setCubicBezierTimingFunction( |
| 68 TimingFunctionType type) |
| 69 { |
| 70 m_curve->SetTimingFunction(CreateTimingFunction(type)); |
| 71 } |
| 72 |
| 73 void WebFilterAnimationCurve::setCubicBezierTimingFunction(double x1, |
| 74 double y1, |
| 75 double x2, |
| 76 double y2) |
| 77 { |
| 78 m_curve->SetTimingFunction( |
| 79 cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2)); |
| 80 } |
| 81 |
| 82 void WebFilterAnimationCurve::setStepsTimingFunction( |
| 83 int numberOfSteps, |
| 84 float stepsStartOffset) |
| 85 { |
| 86 m_curve->SetTimingFunction( |
| 87 cc::StepsTimingFunction::Create(numberOfSteps, stepsStartOffset)); |
| 88 } |
| 89 |
| 90 scoped_ptr<cc::AnimationCurve> |
| 91 WebFilterAnimationCurve::CloneToAnimationCurve() const |
| 92 { |
| 93 return m_curve->Clone(); |
| 94 } |
| 95 |
| 96 } // namespace blink |
OLD | NEW |