| 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 "ui/gfx/point_f.h" | 10 #include "ui/gfx/point_f.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 start_scroll_offset_ - target_scroll_offset_, width_scale, height_scale); | 136 start_scroll_offset_ - target_scroll_offset_, width_scale, height_scale); |
| 137 target_anchor_ = | 137 target_anchor_ = |
| 138 target_scroll_offset_ + DenormalizeToViewport(normalized, | 138 target_scroll_offset_ + DenormalizeToViewport(normalized, |
| 139 TargetViewportSize()); | 139 TargetViewportSize()); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void PageScaleAnimation::ClampTargetScrollOffset() { | 142 void PageScaleAnimation::ClampTargetScrollOffset() { |
| 143 gfx::Vector2dF max_scroll_offset = | 143 gfx::Vector2dF max_scroll_offset = |
| 144 gfx::RectF(root_layer_size_).bottom_right() - | 144 gfx::RectF(root_layer_size_).bottom_right() - |
| 145 gfx::RectF(TargetViewportSize()).bottom_right(); | 145 gfx::RectF(TargetViewportSize()).bottom_right(); |
| 146 target_scroll_offset_.ClampToMin(gfx::Vector2dF()); | 146 target_scroll_offset_.ClampToLowerBound(gfx::Vector2dF()); |
| 147 target_scroll_offset_.ClampToMax(max_scroll_offset); | 147 target_scroll_offset_.ClampToUpperBound(max_scroll_offset); |
| 148 } | 148 } |
| 149 | 149 |
| 150 gfx::SizeF PageScaleAnimation::StartViewportSize() const { | 150 gfx::SizeF PageScaleAnimation::StartViewportSize() const { |
| 151 return gfx::ScaleSize(viewport_size_, 1.f / start_page_scale_factor_); | 151 return gfx::ScaleSize(viewport_size_, 1.f / start_page_scale_factor_); |
| 152 } | 152 } |
| 153 | 153 |
| 154 gfx::SizeF PageScaleAnimation::TargetViewportSize() const { | 154 gfx::SizeF PageScaleAnimation::TargetViewportSize() const { |
| 155 return gfx::ScaleSize(viewport_size_, 1.f / target_page_scale_factor_); | 155 return gfx::ScaleSize(viewport_size_, 1.f / target_page_scale_factor_); |
| 156 } | 156 } |
| 157 | 157 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 216 |
| 217 // Linearly interpolate the magnitude in log scale. | 217 // Linearly interpolate the magnitude in log scale. |
| 218 float diff = target_page_scale_factor_ / start_page_scale_factor_; | 218 float diff = target_page_scale_factor_ / start_page_scale_factor_; |
| 219 float log_diff = log(diff); | 219 float log_diff = log(diff); |
| 220 log_diff *= interp; | 220 log_diff *= interp; |
| 221 diff = exp(log_diff); | 221 diff = exp(log_diff); |
| 222 return start_page_scale_factor_ * diff; | 222 return start_page_scale_factor_ * diff; |
| 223 } | 223 } |
| 224 | 224 |
| 225 } // namespace cc | 225 } // namespace cc |
| OLD | NEW |