| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/page_scale_animation.h" | 7 #include "cc/page_scale_animation.h" |
| 8 | 8 |
| 9 #include "cc/geometry.h" | 9 #include "cc/geometry.h" |
| 10 #include "ui/gfx/point_f.h" | 10 #include "ui/gfx/point_f.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // the target scale is impossible to attain without hitting the root layer | 94 // the target scale is impossible to attain without hitting the root layer |
| 95 // edges, then infer an anchor that doesn't collide with the edges. | 95 // edges, then infer an anchor that doesn't collide with the edges. |
| 96 // We will interpolate between the two anchors during the animation. | 96 // We will interpolate between the two anchors during the animation. |
| 97 inferTargetScrollOffsetFromStartAnchor(); | 97 inferTargetScrollOffsetFromStartAnchor(); |
| 98 clampTargetScrollOffset(); | 98 clampTargetScrollOffset(); |
| 99 inferTargetAnchorFromScrollOffsets(); | 99 inferTargetAnchorFromScrollOffsets(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 gfx::SizeF PageScaleAnimation::viewportSizeAtScale(float pageScaleFactor) const | 102 gfx::SizeF PageScaleAnimation::viewportSizeAtScale(float pageScaleFactor) const |
| 103 { | 103 { |
| 104 return gfx::SizeF(m_viewportSize.width() / pageScaleFactor, m_viewportSize.h
eight() / pageScaleFactor); | 104 return gfx::ScaleSize(m_viewportSize, 1 / pageScaleFactor); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void PageScaleAnimation::inferTargetScrollOffsetFromStartAnchor() | 107 void PageScaleAnimation::inferTargetScrollOffsetFromStartAnchor() |
| 108 { | 108 { |
| 109 gfx::Vector2dF anchorRelativeToStartViewport = m_startAnchor - m_startScroll
Offset; | 109 gfx::Vector2dF anchorRelativeToStartViewport = m_startAnchor - m_startScroll
Offset; |
| 110 gfx::Vector2dF normalized = normalizeFromViewport(anchorRelativeToStartViewp
ort, viewportSizeAtScale(m_startPageScaleFactor)); | 110 gfx::Vector2dF normalized = normalizeFromViewport(anchorRelativeToStartViewp
ort, viewportSizeAtScale(m_startPageScaleFactor)); |
| 111 m_targetScrollOffset = m_startAnchor - denormalizeToViewport(normalized, vie
wportSizeAtScale(m_targetPageScaleFactor)); | 111 m_targetScrollOffset = m_startAnchor - denormalizeToViewport(normalized, vie
wportSizeAtScale(m_targetPageScaleFactor)); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void PageScaleAnimation::inferTargetAnchorFromScrollOffsets() | 114 void PageScaleAnimation::inferTargetAnchorFromScrollOffsets() |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 // Linearly interpolate the magnitude in log scale. | 205 // Linearly interpolate the magnitude in log scale. |
| 206 float diff = m_targetPageScaleFactor / m_startPageScaleFactor; | 206 float diff = m_targetPageScaleFactor / m_startPageScaleFactor; |
| 207 float logDiff = log(diff); | 207 float logDiff = log(diff); |
| 208 logDiff *= interp; | 208 logDiff *= interp; |
| 209 diff = exp(logDiff); | 209 diff = exp(logDiff); |
| 210 return m_startPageScaleFactor * diff; | 210 return m_startPageScaleFactor * diff; |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace cc | 213 } // namespace cc |
| OLD | NEW |