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

Side by Side Diff: ui/compositor/transform_animation_curve_adapter.cc

Issue 659713003: Use scoped_ptr::Pass instead of scoped_ptr::PassAs<T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify Created 6 years, 2 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/compositor/transform_animation_curve_adapter.h" 5 #include "ui/compositor/transform_animation_curve_adapter.h"
6 6
7 namespace ui { 7 namespace ui {
8 8
9 TransformAnimationCurveAdapter::TransformAnimationCurveAdapter( 9 TransformAnimationCurveAdapter::TransformAnimationCurveAdapter(
10 gfx::Tween::Type tween_type, 10 gfx::Tween::Type tween_type,
11 gfx::Transform initial_value, 11 gfx::Transform initial_value,
12 gfx::Transform target_value, 12 gfx::Transform target_value,
13 base::TimeDelta duration) 13 base::TimeDelta duration)
14 : tween_type_(tween_type), 14 : tween_type_(tween_type),
15 initial_value_(initial_value), 15 initial_value_(initial_value),
16 target_value_(target_value), 16 target_value_(target_value),
17 duration_(duration) { 17 duration_(duration) {
18 gfx::DecomposeTransform(&decomposed_initial_value_, initial_value_); 18 gfx::DecomposeTransform(&decomposed_initial_value_, initial_value_);
19 gfx::DecomposeTransform(&decomposed_target_value_, target_value_); 19 gfx::DecomposeTransform(&decomposed_target_value_, target_value_);
20 } 20 }
21 21
22 TransformAnimationCurveAdapter::~TransformAnimationCurveAdapter() { 22 TransformAnimationCurveAdapter::~TransformAnimationCurveAdapter() {
23 } 23 }
24 24
25 double TransformAnimationCurveAdapter::Duration() const { 25 double TransformAnimationCurveAdapter::Duration() const {
26 return duration_.InSecondsF(); 26 return duration_.InSecondsF();
27 } 27 }
28 28
29 scoped_ptr<cc::AnimationCurve> TransformAnimationCurveAdapter::Clone() const { 29 scoped_ptr<cc::AnimationCurve> TransformAnimationCurveAdapter::Clone() const {
30 scoped_ptr<TransformAnimationCurveAdapter> to_return( 30 return make_scoped_ptr(new TransformAnimationCurveAdapter(
31 new TransformAnimationCurveAdapter(tween_type_, 31 tween_type_, initial_value_, target_value_, duration_));
32 initial_value_,
33 target_value_,
34 duration_));
35 return to_return.PassAs<cc::AnimationCurve>();
36 } 32 }
37 33
38 gfx::Transform TransformAnimationCurveAdapter::GetValue( 34 gfx::Transform TransformAnimationCurveAdapter::GetValue(
39 double t) const { 35 double t) const {
40 if (t >= duration_.InSecondsF()) 36 if (t >= duration_.InSecondsF())
41 return target_value_; 37 return target_value_;
42 if (t <= 0.0) 38 if (t <= 0.0)
43 return initial_value_; 39 return initial_value_;
44 double progress = t / duration_.InSecondsF(); 40 double progress = t / duration_.InSecondsF();
45 41
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 84 }
89 85
90 InverseTransformCurveAdapter::~InverseTransformCurveAdapter() { 86 InverseTransformCurveAdapter::~InverseTransformCurveAdapter() {
91 } 87 }
92 88
93 double InverseTransformCurveAdapter::Duration() const { 89 double InverseTransformCurveAdapter::Duration() const {
94 return duration_.InSeconds(); 90 return duration_.InSeconds();
95 } 91 }
96 92
97 scoped_ptr<cc::AnimationCurve> InverseTransformCurveAdapter::Clone() const { 93 scoped_ptr<cc::AnimationCurve> InverseTransformCurveAdapter::Clone() const {
98 scoped_ptr<InverseTransformCurveAdapter> to_return( 94 return make_scoped_ptr(
99 new InverseTransformCurveAdapter(base_curve_, 95 new InverseTransformCurveAdapter(base_curve_, initial_value_, duration_));
100 initial_value_,
101 duration_));
102 return to_return.PassAs<cc::AnimationCurve>();
103 } 96 }
104 97
105 gfx::Transform InverseTransformCurveAdapter::GetValue( 98 gfx::Transform InverseTransformCurveAdapter::GetValue(
106 double t) const { 99 double t) const {
107 if (t <= 0.0) 100 if (t <= 0.0)
108 return initial_value_; 101 return initial_value_;
109 102
110 gfx::Transform base_transform = base_curve_.GetValue(t); 103 gfx::Transform base_transform = base_curve_.GetValue(t);
111 // Invert base 104 // Invert base
112 gfx::Transform to_return(gfx::Transform::kSkipInitialization); 105 gfx::Transform to_return(gfx::Transform::kSkipInitialization);
(...skipping 22 matching lines...) Expand all
135 return initial_value_.IsIdentityOrTranslation() && 128 return initial_value_.IsIdentityOrTranslation() &&
136 base_curve_.IsTranslation(); 129 base_curve_.IsTranslation();
137 } 130 }
138 131
139 bool InverseTransformCurveAdapter::MaximumTargetScale(bool forward_direction, 132 bool InverseTransformCurveAdapter::MaximumTargetScale(bool forward_direction,
140 float* max_scale) const { 133 float* max_scale) const {
141 return false; 134 return false;
142 } 135 }
143 136
144 } // namespace ui 137 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/float_animation_curve_adapter.cc ('k') | ui/events/gesture_detection/motion_event_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698