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

Side by Side Diff: third_party/WebKit/Source/platform/animation/WebScrollOffsetAnimationCurve.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
(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/WebScrollOffsetAnimationCurve.h"
6
7 #include "cc/animation/scroll_offset_animation_curve.h"
8 #include "cc/animation/timing_function.h"
9
10 using blink::WebFloatPoint;
11 using blink::WebScrollOffsetAnimationCurve;
12 using DurationBehavior = cc::ScrollOffsetAnimationCurve::DurationBehavior;
13
14 namespace blink {
15
16 static DurationBehavior GetDurationBehavior(
17 WebScrollOffsetAnimationCurve::ScrollDurationBehavior webDurationBehavior)
18 {
19 switch (webDurationBehavior) {
20 case WebScrollOffsetAnimationCurve::ScrollDurationDeltaBased:
21 return DurationBehavior::DELTA_BASED;
22
23 case WebScrollOffsetAnimationCurve::ScrollDurationConstant:
24 return DurationBehavior::CONSTANT;
25
26 case WebScrollOffsetAnimationCurve::ScrollDurationInverseDelta:
27 return DurationBehavior::INVERSE_DELTA;
28 }
29 NOTREACHED();
30 return DurationBehavior::DELTA_BASED;
31 }
32
33 WebScrollOffsetAnimationCurve::WebScrollOffsetAnimationCurve(
34 WebFloatPoint targetValue,
35 TimingFunctionType timingFunction,
36 ScrollDurationBehavior durationBehavior)
37 : m_curve(cc::ScrollOffsetAnimationCurve::Create(
38 gfx::ScrollOffset(targetValue.x, targetValue.y),
39 WebCompositorAnimationCurve::CreateTimingFunction(timingFunction),
40 GetDurationBehavior(durationBehavior)))
41 {
42 }
43
44 WebScrollOffsetAnimationCurve::~WebScrollOffsetAnimationCurve()
45 {
46 }
47
48 WebCompositorAnimationCurve::AnimationCurveType
49 WebScrollOffsetAnimationCurve::type() const
50 {
51 return WebCompositorAnimationCurve::AnimationCurveTypeScrollOffset;
52 }
53
54 void WebScrollOffsetAnimationCurve::setInitialValue(WebFloatPoint initialValue)
55 {
56 m_curve->SetInitialValue(gfx::ScrollOffset(initialValue.x, initialValue.y));
57 }
58
59 WebFloatPoint WebScrollOffsetAnimationCurve::getValue(double time) const
60 {
61 gfx::ScrollOffset value = m_curve->GetValue(base::TimeDelta::FromSecondsD(ti me));
62 return WebFloatPoint(value.x(), value.y());
63 }
64
65 double WebScrollOffsetAnimationCurve::duration() const
66 {
67 return m_curve->Duration().InSecondsF();
68 }
69
70 WebFloatPoint WebScrollOffsetAnimationCurve::targetValue() const
71 {
72 gfx::ScrollOffset target = m_curve->target_value();
73 return WebFloatPoint(target.x(), target.y());
74 }
75
76 void WebScrollOffsetAnimationCurve::updateTarget(double time, WebFloatPoint newT arget)
77 {
78 m_curve->UpdateTarget(time, gfx::ScrollOffset(newTarget.x, newTarget.y));
esprehn 2016/01/28 03:40:40 we can probably add WebFoo to gfx::Foo conversion
loyso (OOO) 2016/01/28 07:10:09 Acknowledged.
79 }
80
81 scoped_ptr<cc::AnimationCurve>
82 WebScrollOffsetAnimationCurve::CloneToAnimationCurve() const
83 {
84 return m_curve->Clone();
85 }
86
87 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698