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

Side by Side Diff: cc/page_scale_animation.cc

Issue 11358240: ui: Add methods to Rect classes to get points at each of the rect's corners. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update cc 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_impl_unittest.cc ('k') | cc/tiled_layer.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 "cc/page_scale_animation.h" 5 #include "cc/page_scale_animation.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "cc/geometry.h"
9 #include "ui/gfx/point_f.h" 8 #include "ui/gfx/point_f.h"
10 #include "ui/gfx/rect_f.h" 9 #include "ui/gfx/rect_f.h"
11 #include "ui/gfx/vector2d_conversions.h" 10 #include "ui/gfx/vector2d_conversions.h"
12 11
13 #include <math.h> 12 #include <math.h>
14 13
15 namespace { 14 namespace {
16 15
17 // This takes a viewport-relative vector and returns a vector whose values are 16 // This takes a viewport-relative vector and returns a vector whose values are
18 // between 0 and 1, representing the percentage position within the viewport. 17 // between 0 and 1, representing the percentage position within the viewport.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // where both anchor and normalized begin as unknowns. Solving 109 // where both anchor and normalized begin as unknowns. Solving
111 // for the normalized, we get the following: 110 // for the normalized, we get the following:
112 float widthScale = 1 / (targetViewportSize().width() - startViewportSize().w idth()); 111 float widthScale = 1 / (targetViewportSize().width() - startViewportSize().w idth());
113 float heightScale = 1 / (targetViewportSize().height() - startViewportSize() .height()); 112 float heightScale = 1 / (targetViewportSize().height() - startViewportSize() .height());
114 gfx::Vector2dF normalized = gfx::ScaleVector2d(m_startScrollOffset - m_targe tScrollOffset, widthScale, heightScale); 113 gfx::Vector2dF normalized = gfx::ScaleVector2d(m_startScrollOffset - m_targe tScrollOffset, widthScale, heightScale);
115 m_targetAnchor = m_targetScrollOffset + denormalizeToViewport(normalized, ta rgetViewportSize()); 114 m_targetAnchor = m_targetScrollOffset + denormalizeToViewport(normalized, ta rgetViewportSize());
116 } 115 }
117 116
118 void PageScaleAnimation::clampTargetScrollOffset() 117 void PageScaleAnimation::clampTargetScrollOffset()
119 { 118 {
120 gfx::Vector2dF maxScrollOffset = BottomRight(gfx::RectF(m_rootLayerSize)) - BottomRight(gfx::RectF(targetViewportSize())); 119 gfx::Vector2dF maxScrollOffset = gfx::RectF(m_rootLayerSize).bottom_right() - gfx::RectF(targetViewportSize()).bottom_right();
121 m_targetScrollOffset.ClampToMin(gfx::Vector2dF()); 120 m_targetScrollOffset.ClampToMin(gfx::Vector2dF());
122 m_targetScrollOffset.ClampToMax(maxScrollOffset); 121 m_targetScrollOffset.ClampToMax(maxScrollOffset);
123 } 122 }
124 123
125 gfx::SizeF PageScaleAnimation::startViewportSize() const 124 gfx::SizeF PageScaleAnimation::startViewportSize() const
126 { 125 {
127 return gfx::ScaleSize(m_viewportSize, 1 / m_startPageScaleFactor); 126 return gfx::ScaleSize(m_viewportSize, 1 / m_startPageScaleFactor);
128 } 127 }
129 128
130 gfx::SizeF PageScaleAnimation::targetViewportSize() const 129 gfx::SizeF PageScaleAnimation::targetViewportSize() const
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 195
197 // Linearly interpolate the magnitude in log scale. 196 // Linearly interpolate the magnitude in log scale.
198 float diff = m_targetPageScaleFactor / m_startPageScaleFactor; 197 float diff = m_targetPageScaleFactor / m_startPageScaleFactor;
199 float logDiff = log(diff); 198 float logDiff = log(diff);
200 logDiff *= interp; 199 logDiff *= interp;
201 diff = exp(logDiff); 200 diff = exp(logDiff);
202 return m_startPageScaleFactor * diff; 201 return m_startPageScaleFactor * diff;
203 } 202 }
204 203
205 } // namespace cc 204 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_impl_unittest.cc ('k') | cc/tiled_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698