OLD | NEW |
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 "cc/animation/timing_function.h" | 10 #include "cc/animation/timing_function.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 gfx::Vector2dF normalized = gfx::ScaleVector2d( | 140 gfx::Vector2dF normalized = gfx::ScaleVector2d( |
141 start_scroll_offset_ - target_scroll_offset_, width_scale, height_scale); | 141 start_scroll_offset_ - target_scroll_offset_, width_scale, height_scale); |
142 target_anchor_ = | 142 target_anchor_ = |
143 target_scroll_offset_ + DenormalizeToViewport(normalized, | 143 target_scroll_offset_ + DenormalizeToViewport(normalized, |
144 TargetViewportSize()); | 144 TargetViewportSize()); |
145 } | 145 } |
146 | 146 |
147 void PageScaleAnimation::ClampTargetScrollOffset() { | 147 void PageScaleAnimation::ClampTargetScrollOffset() { |
148 gfx::Vector2dF max_scroll_offset = | 148 gfx::Vector2dF max_scroll_offset = |
149 gfx::RectF(root_layer_size_).bottom_right() - | 149 gfx::RectF(root_layer_size_).bottom_right() - |
150 gfx::RectF(TargetViewportSize()).bottom_right(); | 150 gfx::RectF(gfx::SizeF(TargetViewportSize())).bottom_right(); |
151 target_scroll_offset_.SetToMax(gfx::Vector2dF()); | 151 target_scroll_offset_.SetToMax(gfx::Vector2dF()); |
152 target_scroll_offset_.SetToMin(max_scroll_offset); | 152 target_scroll_offset_.SetToMin(max_scroll_offset); |
153 } | 153 } |
154 | 154 |
155 gfx::SizeF PageScaleAnimation::StartViewportSize() const { | 155 gfx::SizeF PageScaleAnimation::StartViewportSize() const { |
156 return gfx::ScaleSize(viewport_size_, 1.f / start_page_scale_factor_); | 156 return gfx::ScaleSize(viewport_size_, 1.f / start_page_scale_factor_); |
157 } | 157 } |
158 | 158 |
159 gfx::SizeF PageScaleAnimation::TargetViewportSize() const { | 159 gfx::SizeF PageScaleAnimation::TargetViewportSize() const { |
160 return gfx::ScaleSize(viewport_size_, 1.f / target_page_scale_factor_); | 160 return gfx::ScaleSize(viewport_size_, 1.f / target_page_scale_factor_); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 236 |
237 // Linearly interpolate the magnitude in log scale. | 237 // Linearly interpolate the magnitude in log scale. |
238 float diff = target_page_scale_factor_ / start_page_scale_factor_; | 238 float diff = target_page_scale_factor_ / start_page_scale_factor_; |
239 float log_diff = log(diff); | 239 float log_diff = log(diff); |
240 log_diff *= interp; | 240 log_diff *= interp; |
241 diff = exp(log_diff); | 241 diff = exp(log_diff); |
242 return start_page_scale_factor_ * diff; | 242 return start_page_scale_factor_ * diff; |
243 } | 243 } |
244 | 244 |
245 } // namespace cc | 245 } // namespace cc |
OLD | NEW |