summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-10 09:34:28 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-10 09:34:28 +0000
commit01a15a710b6ffb772bdf8e3827e9f1395d29d814 (patch)
treee0bf4c1332ac22b7cc939be4b08f2bdafa732a9c /cc
parentbcf7636d116fe67fd79d9acca753b1b18f380654 (diff)
downloadchromium_src-01a15a710b6ffb772bdf8e3827e9f1395d29d814.zip
chromium_src-01a15a710b6ffb772bdf8e3827e9f1395d29d814.tar.gz
chromium_src-01a15a710b6ffb772bdf8e3827e9f1395d29d814.tar.bz2
ui: Make gfx::Size::Scale() mutate the class. Add gfx::ScaleSize() similar to Rect/Point.
Covered by existing unit tests. R=sky BUG=160158 Review URL: https://chromiumcodereview.appspot.com/11377068 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167077 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/contents_scaling_layer.cc2
-rw-r--r--cc/layer_tree_host_impl.cc15
-rw-r--r--cc/layer_tree_host_impl_unittest.cc2
-rw-r--r--cc/layer_tree_host_unittest.cc7
-rw-r--r--cc/page_scale_animation.cc2
5 files changed, 12 insertions, 16 deletions
diff --git a/cc/contents_scaling_layer.cc b/cc/contents_scaling_layer.cc
index c0fb126..b758bd3 100644
--- a/cc/contents_scaling_layer.cc
+++ b/cc/contents_scaling_layer.cc
@@ -15,7 +15,7 @@ ContentsScalingLayer::~ContentsScalingLayer() {
}
gfx::Size ContentsScalingLayer::contentBounds() const {
- return gfx::ToCeiledSize(bounds().Scale(contentsScaleX(), contentsScaleY()));
+ return gfx::ToCeiledSize(gfx::ScaleSize(bounds(), contentsScaleX(), contentsScaleY()));
}
float ContentsScalingLayer::contentsScaleX() const {
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc
index 5bd3cac..b39dec9 100644
--- a/cc/layer_tree_host_impl.cc
+++ b/cc/layer_tree_host_impl.cc
@@ -297,10 +297,9 @@ void LayerTreeHostImpl::startPageScaleAnimation(gfx::Vector2d targetPosition, bo
gfx::SizeF scaledContentSize = contentSize();
if (!Settings::pageScalePinchZoomEnabled()) {
scrollTotal.Scale(1 / m_pinchZoomViewport.pageScaleFactor());
- scaledContentSize = scaledContentSize.Scale(1 / m_pinchZoomViewport.pageScaleFactor());
+ scaledContentSize.Scale(1 / m_pinchZoomViewport.pageScaleFactor());
}
- gfx::SizeF viewportSize = m_deviceViewportSize;
- viewportSize = viewportSize.Scale(1 / m_deviceScaleFactor);
+ gfx::SizeF viewportSize = gfx::ScaleSize(m_deviceViewportSize, 1 / m_deviceScaleFactor);
double startTimeSeconds = (startTime - base::TimeTicks()).InSecondsF();
m_pageScaleAnimation = PageScaleAnimation::create(scrollTotal, m_pinchZoomViewport.totalPageScaleFactor(), viewportSize, scaledContentSize, startTimeSeconds);
@@ -983,10 +982,8 @@ void LayerTreeHostImpl::updateMaxScrollOffset()
gfx::SizeF viewBounds = m_deviceViewportSize;
if (LayerImpl* clipLayer = m_rootScrollLayerImpl->parent()) {
// Compensate for non-overlay scrollbars.
- if (clipLayer->masksToBounds()) {
- viewBounds = clipLayer->bounds();
- viewBounds = viewBounds.Scale(m_deviceScaleFactor);
- }
+ if (clipLayer->masksToBounds())
+ viewBounds = gfx::ScaleSize(clipLayer->bounds(), m_deviceScaleFactor);
}
gfx::Size contentBounds = contentSize();
@@ -998,7 +995,7 @@ void LayerTreeHostImpl::updateMaxScrollOffset()
contentBounds.set_width(contentBounds.width() / pageScaleFactor);
contentBounds.set_height(contentBounds.height() / pageScaleFactor);
} else {
- viewBounds = viewBounds.Scale(1 / m_pinchZoomViewport.pageScaleDelta());
+ viewBounds.Scale(1 / m_pinchZoomViewport.pageScaleDelta());
}
gfx::Vector2dF maxScroll = BottomRight(gfx::Rect(contentBounds)) - BottomRight(gfx::RectF(viewBounds));
@@ -1288,7 +1285,7 @@ void LayerTreeHostImpl::computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo)
scrollBegin.Scale(m_pinchZoomViewport.pageScaleDelta());
float scaleBegin = m_pinchZoomViewport.totalPageScaleFactor();
float pageScaleDeltaToSend = m_pinchZoomViewport.minPageScaleFactor() / m_pinchZoomViewport.pageScaleFactor();
- gfx::SizeF scaledContentsSize = contentSize().Scale(pageScaleDeltaToSend);
+ gfx::SizeF scaledContentsSize = gfx::ScaleSize(contentSize(), pageScaleDeltaToSend);
gfx::Vector2d anchorOffset = m_previousPinchAnchor.OffsetFromOrigin();
gfx::Vector2dF scrollEnd = scrollBegin + anchorOffset;
diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc
index 3e25195..78691d9 100644
--- a/cc/layer_tree_host_impl_unittest.cc
+++ b/cc/layer_tree_host_impl_unittest.cc
@@ -485,7 +485,7 @@ TEST_P(LayerTreeHostImplTest, maxScrollOffsetChangedByDeviceScaleFactor)
float deviceScaleFactor = 2;
gfx::Size layoutViewport(25, 25);
- gfx::Size deviceViewport(gfx::ToFlooredSize(layoutViewport.Scale(deviceScaleFactor)));
+ gfx::Size deviceViewport(gfx::ToFlooredSize(gfx::ScaleSize(layoutViewport, deviceScaleFactor)));
m_hostImpl->setViewportSize(layoutViewport, deviceViewport);
m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), gfx::Vector2d(25, 25));
diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc
index 633b8ff..4fa8fc7 100644
--- a/cc/layer_tree_host_unittest.cc
+++ b/cc/layer_tree_host_unittest.cc
@@ -1337,8 +1337,7 @@ public:
EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60), root->renderSurface()->contentRect());
// The content bounds of the child should be scaled.
- gfx::Size childBoundsScaled = child->bounds();
- childBoundsScaled = gfx::ToRoundedSize(childBoundsScaled.Scale(1.5));
+ gfx::Size childBoundsScaled = gfx::ToCeiledSize(gfx::ScaleSize(child->bounds(), 1.5));
EXPECT_EQ(childBoundsScaled, child->contentBounds());
WebTransformationMatrix scaleTransform;
@@ -2185,7 +2184,7 @@ public:
virtual void beginTest() OVERRIDE
{
gfx::Size viewportSize(10, 10);
- gfx::Size deviceViewportSize = gfx::ToCeiledSize(viewportSize.Scale(m_deviceScaleFactor));
+ gfx::Size deviceViewportSize = gfx::ToCeiledSize(gfx::ScaleSize(viewportSize, m_deviceScaleFactor));
m_layerTreeHost->setViewportSize(viewportSize, deviceViewportSize);
m_layerTreeHost->setDeviceScaleFactor(m_deviceScaleFactor);
@@ -2345,7 +2344,7 @@ public:
virtual void beginTest() OVERRIDE
{
gfx::Size viewportSize(10, 10);
- gfx::Size deviceViewportSize = gfx::ToCeiledSize(viewportSize.Scale(m_deviceScaleFactor));
+ gfx::Size deviceViewportSize = gfx::ToCeiledSize(gfx::ScaleSize(viewportSize, m_deviceScaleFactor));
m_layerTreeHost->setViewportSize(viewportSize, deviceViewportSize);
m_layerTreeHost->setDeviceScaleFactor(m_deviceScaleFactor);
diff --git a/cc/page_scale_animation.cc b/cc/page_scale_animation.cc
index 5d9e882..e5b1fec 100644
--- a/cc/page_scale_animation.cc
+++ b/cc/page_scale_animation.cc
@@ -99,7 +99,7 @@ void PageScaleAnimation::zoomWithAnchor(const gfx::Vector2dF& anchor, float targ
gfx::SizeF PageScaleAnimation::viewportSizeAtScale(float pageScaleFactor) const
{
- return gfx::SizeF(m_viewportSize.width() / pageScaleFactor, m_viewportSize.height() / pageScaleFactor);
+ return gfx::ScaleSize(m_viewportSize, 1 / pageScaleFactor);
}
void PageScaleAnimation::inferTargetScrollOffsetFromStartAnchor()