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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 start_scroll_offset_ - target_scroll_offset_, width_scale, height_scale); | 142 start_scroll_offset_ - target_scroll_offset_, width_scale, height_scale); |
143 target_anchor_ = | 143 target_anchor_ = |
144 target_scroll_offset_ + DenormalizeToViewport(normalized, | 144 target_scroll_offset_ + DenormalizeToViewport(normalized, |
145 TargetViewportSize()); | 145 TargetViewportSize()); |
146 } | 146 } |
147 | 147 |
148 void PageScaleAnimation::ClampTargetScrollOffset() { | 148 void PageScaleAnimation::ClampTargetScrollOffset() { |
149 gfx::Vector2dF max_scroll_offset = | 149 gfx::Vector2dF max_scroll_offset = |
150 gfx::RectF(root_layer_size_).bottom_right() - | 150 gfx::RectF(root_layer_size_).bottom_right() - |
151 gfx::RectF(TargetViewportSize()).bottom_right(); | 151 gfx::RectF(TargetViewportSize()).bottom_right(); |
152 target_scroll_offset_.ClampToMin(gfx::Vector2dF()); | 152 target_scroll_offset_.SetToMax(gfx::Vector2dF()); |
153 target_scroll_offset_.ClampToMax(max_scroll_offset); | 153 target_scroll_offset_.SetToMin(max_scroll_offset); |
154 } | 154 } |
155 | 155 |
156 gfx::SizeF PageScaleAnimation::StartViewportSize() const { | 156 gfx::SizeF PageScaleAnimation::StartViewportSize() const { |
157 return gfx::ScaleSize(viewport_size_, 1.f / start_page_scale_factor_); | 157 return gfx::ScaleSize(viewport_size_, 1.f / start_page_scale_factor_); |
158 } | 158 } |
159 | 159 |
160 gfx::SizeF PageScaleAnimation::TargetViewportSize() const { | 160 gfx::SizeF PageScaleAnimation::TargetViewportSize() const { |
161 return gfx::ScaleSize(viewport_size_, 1.f / target_page_scale_factor_); | 161 return gfx::ScaleSize(viewport_size_, 1.f / target_page_scale_factor_); |
162 } | 162 } |
163 | 163 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 // Linearly interpolate the magnitude in log scale. | 224 // Linearly interpolate the magnitude in log scale. |
225 float diff = target_page_scale_factor_ / start_page_scale_factor_; | 225 float diff = target_page_scale_factor_ / start_page_scale_factor_; |
226 float log_diff = log(diff); | 226 float log_diff = log(diff); |
227 log_diff *= interp; | 227 log_diff *= interp; |
228 diff = exp(log_diff); | 228 diff = exp(log_diff); |
229 return start_page_scale_factor_ * diff; | 229 return start_page_scale_factor_ * diff; |
230 } | 230 } |
231 | 231 |
232 } // namespace cc | 232 } // namespace cc |
OLD | NEW |