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

Side by Side Diff: cc/input/page_scale_animation.cc

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 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
« no previous file with comments | « cc/input/page_scale_animation.h ('k') | cc/input/scroll_state.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "cc/input/page_scale_animation.h" 5 #include "cc/input/page_scale_animation.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h"
10 #include "cc/animation/timing_function.h" 11 #include "cc/animation/timing_function.h"
11 #include "ui/gfx/geometry/point_f.h" 12 #include "ui/gfx/geometry/point_f.h"
12 #include "ui/gfx/geometry/rect_f.h" 13 #include "ui/gfx/geometry/rect_f.h"
13 #include "ui/gfx/geometry/vector2d_conversions.h" 14 #include "ui/gfx/geometry/vector2d_conversions.h"
14 15
15 namespace { 16 namespace {
16 17
17 // This takes a viewport-relative vector and returns a vector whose values are 18 // This takes a viewport-relative vector and returns a vector whose values are
18 // between 0 and 1, representing the percentage position within the viewport. 19 // between 0 and 1, representing the percentage position within the viewport.
19 gfx::Vector2dF NormalizeFromViewport(const gfx::Vector2dF& denormalized, 20 gfx::Vector2dF NormalizeFromViewport(const gfx::Vector2dF& denormalized,
(...skipping 16 matching lines...) Expand all
36 return start + gfx::ScaleVector2d(end - start, interp); 37 return start + gfx::ScaleVector2d(end - start, interp);
37 } 38 }
38 39
39 } // namespace 40 } // namespace
40 41
41 namespace cc { 42 namespace cc {
42 43
43 using base::TimeTicks; 44 using base::TimeTicks;
44 using base::TimeDelta; 45 using base::TimeDelta;
45 46
46 scoped_ptr<PageScaleAnimation> PageScaleAnimation::Create( 47 std::unique_ptr<PageScaleAnimation> PageScaleAnimation::Create(
47 const gfx::Vector2dF& start_scroll_offset, 48 const gfx::Vector2dF& start_scroll_offset,
48 float start_page_scale_factor, 49 float start_page_scale_factor,
49 const gfx::SizeF& viewport_size, 50 const gfx::SizeF& viewport_size,
50 const gfx::SizeF& root_layer_size, 51 const gfx::SizeF& root_layer_size,
51 scoped_ptr<TimingFunction> timing_function) { 52 std::unique_ptr<TimingFunction> timing_function) {
52 return make_scoped_ptr(new PageScaleAnimation( 53 return base::WrapUnique(new PageScaleAnimation(
53 start_scroll_offset, start_page_scale_factor, viewport_size, 54 start_scroll_offset, start_page_scale_factor, viewport_size,
54 root_layer_size, std::move(timing_function))); 55 root_layer_size, std::move(timing_function)));
55 } 56 }
56 57
57 PageScaleAnimation::PageScaleAnimation( 58 PageScaleAnimation::PageScaleAnimation(
58 const gfx::Vector2dF& start_scroll_offset, 59 const gfx::Vector2dF& start_scroll_offset,
59 float start_page_scale_factor, 60 float start_page_scale_factor,
60 const gfx::SizeF& viewport_size, 61 const gfx::SizeF& viewport_size,
61 const gfx::SizeF& root_layer_size, 62 const gfx::SizeF& root_layer_size,
62 scoped_ptr<TimingFunction> timing_function) 63 std::unique_ptr<TimingFunction> timing_function)
63 : start_page_scale_factor_(start_page_scale_factor), 64 : start_page_scale_factor_(start_page_scale_factor),
64 target_page_scale_factor_(0.f), 65 target_page_scale_factor_(0.f),
65 start_scroll_offset_(start_scroll_offset), 66 start_scroll_offset_(start_scroll_offset),
66 start_anchor_(), 67 start_anchor_(),
67 target_anchor_(), 68 target_anchor_(),
68 viewport_size_(viewport_size), 69 viewport_size_(viewport_size),
69 root_layer_size_(root_layer_size), 70 root_layer_size_(root_layer_size),
70 timing_function_(std::move(timing_function)) {} 71 timing_function_(std::move(timing_function)) {}
71 72
72 PageScaleAnimation::~PageScaleAnimation() {} 73 PageScaleAnimation::~PageScaleAnimation() {}
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 234
234 // Linearly interpolate the magnitude in log scale. 235 // Linearly interpolate the magnitude in log scale.
235 float diff = target_page_scale_factor_ / start_page_scale_factor_; 236 float diff = target_page_scale_factor_ / start_page_scale_factor_;
236 float log_diff = log(diff); 237 float log_diff = log(diff);
237 log_diff *= interp; 238 log_diff *= interp;
238 diff = exp(log_diff); 239 diff = exp(log_diff);
239 return start_page_scale_factor_ * diff; 240 return start_page_scale_factor_ * diff;
240 } 241 }
241 242
242 } // namespace cc 243 } // namespace cc
OLDNEW
« no previous file with comments | « cc/input/page_scale_animation.h ('k') | cc/input/scroll_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698