Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(685)

Side by Side Diff: cc/page_scale_animation.cc

Issue 11377068: ui: Make gfx::Size::Scale() mutate the class. Add gfx::ScaleSize() similar to Rect/Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebaseTOGO Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layer_tree_host_unittest.cc ('k') | chrome/browser/chromeos/status/network_menu_icon.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « cc/layer_tree_host_unittest.cc ('k') | chrome/browser/chromeos/status/network_menu_icon.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698