| 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/rect_f.h" | 10 #include "ui/gfx/rect_f.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 m_scrollEnd = finalScroll; | 68 m_scrollEnd = finalScroll; |
| 69 m_pageScaleEnd = finalPageScale; | 69 m_pageScaleEnd = finalPageScale; |
| 70 m_duration = duration; | 70 m_duration = duration; |
| 71 m_anchorMode = false; | 71 m_anchorMode = false; |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 void PageScaleAnimation::zoomWithAnchor(gfx::Vector2d anchor, float finalPageSca
le, double duration) | 75 void PageScaleAnimation::zoomWithAnchor(gfx::Vector2d anchor, float finalPageSca
le, double duration) |
| 76 { | 76 { |
| 77 m_scrollEnd = m_scrollStart + anchor; | 77 m_scrollEnd = m_scrollStart + anchor; |
| 78 m_scrollEnd = gfx::ToFlooredVector2d(cc::ScaleVector2d(m_scrollEnd, finalPag
eScale / m_pageScaleStart)); | 78 m_scrollEnd = gfx::ToFlooredVector2d(gfx::ScaleVector2d(m_scrollEnd, finalPa
geScale / m_pageScaleStart)); |
| 79 m_scrollEnd -= anchor; | 79 m_scrollEnd -= anchor; |
| 80 | 80 |
| 81 m_scrollEnd = ClampFromBelow(m_scrollEnd, gfx::Vector2d()); | 81 m_scrollEnd = ClampFromBelow(m_scrollEnd, gfx::Vector2d()); |
| 82 gfx::SizeF scaledContentSize = gfx::ScaleSize(m_contentSize, finalPageScale
/ m_pageScaleStart); | 82 gfx::SizeF scaledContentSize = gfx::ScaleSize(m_contentSize, finalPageScale
/ m_pageScaleStart); |
| 83 gfx::Vector2d maxScrollOffset = gfx::ToRoundedVector2d(BottomRight(gfx::Rect
F(scaledContentSize)) - BottomRight(gfx::Rect(m_windowSize))); | 83 gfx::Vector2d maxScrollOffset = gfx::ToRoundedVector2d(BottomRight(gfx::Rect
F(scaledContentSize)) - BottomRight(gfx::Rect(m_windowSize))); |
| 84 m_scrollEnd = m_scrollEnd; | 84 m_scrollEnd = m_scrollEnd; |
| 85 m_scrollEnd = ClampFromAbove(m_scrollEnd, maxScrollOffset); | 85 m_scrollEnd = ClampFromAbove(m_scrollEnd, maxScrollOffset); |
| 86 | 86 |
| 87 m_anchor = anchor; | 87 m_anchor = anchor; |
| 88 m_pageScaleEnd = finalPageScale; | 88 m_pageScaleEnd = finalPageScale; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // example, if we zoom from 0.5 to 4.0 in 3 seconds, then we should | 155 // example, if we zoom from 0.5 to 4.0 in 3 seconds, then we should |
| 156 // be zooming by 2x every second. | 156 // be zooming by 2x every second. |
| 157 float diff = m_pageScaleEnd / m_pageScaleStart; | 157 float diff = m_pageScaleEnd / m_pageScaleStart; |
| 158 float logDiff = log(diff); | 158 float logDiff = log(diff); |
| 159 logDiff *= ratio; | 159 logDiff *= ratio; |
| 160 diff = exp(logDiff); | 160 diff = exp(logDiff); |
| 161 return m_pageScaleStart * diff; | 161 return m_pageScaleStart * diff; |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace cc | 164 } // namespace cc |
| OLD | NEW |