summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-05 17:17:34 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-05 17:17:34 +0000
commitcf817fb1eddd3ab76b074029739828c4072b567b (patch)
treea0b699950f8538305df7b420406b8d7a821768cb /cc
parent3c6aa86510b3724b6c3c83c090f22775f8d4fa0e (diff)
downloadchromium_src-cf817fb1eddd3ab76b074029739828c4072b567b.zip
chromium_src-cf817fb1eddd3ab76b074029739828c4072b567b.tar.gz
chromium_src-cf817fb1eddd3ab76b074029739828c4072b567b.tar.bz2
Revert "cc: Remove all remaining use of WebCore Rect/Point/Size types from the compositor."
This reverts commit a76cb24ab8de742f70b83f6c045c2c23545eaae7. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165949 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/DEPS17
-rw-r--r--cc/geometry.h66
-rw-r--r--cc/input_handler.h12
-rw-r--r--cc/layer.cc18
-rw-r--r--cc/layer.h15
-rw-r--r--cc/layer_impl.cc25
-rw-r--r--cc/layer_impl.h28
-rw-r--r--cc/layer_impl_unittest.cc13
-rw-r--r--cc/layer_tree_host.cc10
-rw-r--r--cc/layer_tree_host.h2
-rw-r--r--cc/layer_tree_host_client.h7
-rw-r--r--cc/layer_tree_host_common.cc8
-rw-r--r--cc/layer_tree_host_common.h4
-rw-r--r--cc/layer_tree_host_common_unittest.cc42
-rw-r--r--cc/layer_tree_host_impl.cc149
-rw-r--r--cc/layer_tree_host_impl.h23
-rw-r--r--cc/layer_tree_host_impl_unittest.cc197
-rw-r--r--cc/layer_tree_host_unittest.cc205
-rw-r--r--cc/layer_unittest.cc2
-rw-r--r--cc/math_util.cc27
-rw-r--r--cc/math_util.h7
-rw-r--r--cc/math_util_unittest.cc35
-rw-r--r--cc/page_scale_animation.cc56
-rw-r--r--cc/page_scale_animation.h23
-rw-r--r--cc/proxy.h4
-rw-r--r--cc/scrollbar_animation_controller.cc12
-rw-r--r--cc/scrollbar_animation_controller.h17
-rw-r--r--cc/scrollbar_animation_controller_linear_fade.cc4
-rw-r--r--cc/scrollbar_animation_controller_linear_fade_unittest.cc12
-rw-r--r--cc/scrollbar_geometry_fixed_thumb.cc4
-rw-r--r--cc/scrollbar_geometry_fixed_thumb.h4
-rw-r--r--cc/scrollbar_layer_unittest.cc14
-rw-r--r--cc/single_thread_proxy.cc4
-rw-r--r--cc/single_thread_proxy.h2
-rw-r--r--cc/stubs/FloatPoint.h6
-rw-r--r--cc/stubs/FloatSize.h6
-rw-r--r--cc/stubs/IntPoint.h6
-rw-r--r--cc/stubs/IntSize.h6
-rw-r--r--cc/stubs/float_point.h58
-rw-r--r--cc/stubs/float_size.h59
-rw-r--r--cc/stubs/int_point.h47
-rw-r--r--cc/stubs/int_size.h50
-rw-r--r--cc/test/fake_layer_tree_host_client.h2
-rw-r--r--cc/test/geometry_test_utils.h22
-rw-r--r--cc/test/layer_tree_test_common.cc2
-rw-r--r--cc/test/layer_tree_test_common.h2
-rw-r--r--cc/thread_proxy.cc8
-rw-r--r--cc/thread_proxy.h4
48 files changed, 761 insertions, 585 deletions
diff --git a/cc/DEPS b/cc/DEPS
index 56c6cf7..cf10e4c 100644
--- a/cc/DEPS
+++ b/cc/DEPS
@@ -5,7 +5,22 @@ include_rules = [
"+third_party/khronos/GLES2/gl2ext.h",
"+ui/gfx",
"+media",
-# http://crbug.com/147395
+# http://crbug.com/144542
+ "+third_party/WebKit/Source/WebCore/platform/graphics/FloatPoint.h",
+ "+third_party/WebKit/Source/WebCore/platform/graphics/FloatQuad.h",
+ "+third_party/WebKit/Source/WebCore/platform/graphics/FloatRect.h",
+ "+third_party/WebKit/Source/WebCore/platform/graphics/FloatSize.h",
+ "+third_party/WebKit/Source/WebCore/platform/graphics/IntPoint.h",
+ "+third_party/WebKit/Source/WebCore/platform/graphics/IntRect.h",
+ "+third_party/WebKit/Source/WebCore/platform/graphics/IntSize.h",
+ "+Source/WebCore/platform/graphics/FloatPoint.h",
+ "+Source/WebCore/platform/graphics/FloatQuad.h",
+ "+Source/WebCore/platform/graphics/FloatRect.h",
+ "+Source/WebCore/platform/graphics/FloatSize.h",
+ "+Source/WebCore/platform/graphics/IntPoint.h",
+ "+Source/WebCore/platform/graphics/IntRect.h",
+ "+Source/WebCore/platform/graphics/IntSize.h",
+# http://crbug.com/144540
"+third_party/WebKit/Source/WebCore/platform/graphics/Region.h",
"+Source/WebCore/platform/graphics/Region.h",
# TODO(jamesr): Resolve these
diff --git a/cc/geometry.h b/cc/geometry.h
index 9198927..1e5e25a 100644
--- a/cc/geometry.h
+++ b/cc/geometry.h
@@ -5,10 +5,9 @@
#ifndef CC_GEOMETRY_H_
#define CC_GEOMETRY_H_
-#include "ui/gfx/rect.h"
-#include "ui/gfx/rect_f.h"
-#include "ui/gfx/vector2d.h"
+#include "ui/gfx/size.h"
#include "ui/gfx/vector2d_f.h"
+#include <cmath>
namespace cc {
@@ -17,67 +16,6 @@ inline gfx::Size ClampSizeFromAbove(gfx::Size s, gfx::Size other) {
s.height() < other.height() ? s.height() : other.height());
}
-inline gfx::Vector2dF ClampFromAbove(gfx::Vector2dF s, gfx::Vector2dF max) {
- return gfx::Vector2dF(s.x() < max.x() ? s.x() : max.x(),
- s.y() < max.y() ? s.y() : max.y());
-}
-
-inline gfx::Vector2dF ClampFromBelow(gfx::Vector2dF s, gfx::Vector2dF min) {
- return gfx::Vector2dF(s.x() > min.x() ? s.x() : min.x(),
- s.y() > min.y() ? s.y() : min.y());
-}
-
-inline gfx::Vector2d ClampFromAbove(gfx::Vector2d s, gfx::Vector2d max) {
- return gfx::Vector2d(s.x() < max.x() ? s.x() : max.x(),
- s.y() < max.y() ? s.y() : max.y());
-}
-
-inline gfx::Vector2d ClampFromBelow(gfx::Vector2d s, gfx::Vector2d min) {
- return gfx::Vector2d(s.x() > min.x() ? s.x() : min.x(),
- s.y() > min.y() ? s.y() : min.y());
-}
-
-inline gfx::PointF ClampFromAbove(gfx::PointF s, gfx::PointF max) {
- return gfx::PointF(s.x() < max.x() ? s.x() : max.x(),
- s.y() < max.y() ? s.y() : max.y());
-}
-
-inline gfx::PointF ClampFromBelow(gfx::PointF s, gfx::PointF min) {
- return gfx::PointF(s.x() > min.x() ? s.x() : min.x(),
- s.y() > min.y() ? s.y() : min.y());
-}
-
-inline gfx::Point ClampFromAbove(gfx::Point s, gfx::Point max) {
- return gfx::Point(s.x() < max.x() ? s.x() : max.x(),
- s.y() < max.y() ? s.y() : max.y());
-}
-
-inline gfx::Point ClampFromBelow(gfx::Point s, gfx::Point min) {
- return gfx::Point(s.x() > min.x() ? s.x() : min.x(),
- s.y() > min.y() ? s.y() : min.y());
-}
-
-inline gfx::Point BottomRight(gfx::Rect rect) {
- return gfx::Point(rect.right(), rect.bottom());
-}
-
-inline gfx::PointF BottomRight(gfx::RectF rect) {
- return gfx::PointF(rect.right(), rect.bottom());
-}
-
-// Return a vector that is |v| scaled by the given scale factors along each
-// axis.
-inline gfx::Vector2dF ScaleVector2d(gfx::Vector2dF v, float x_scale, float y_scale) {
- gfx::Vector2dF scaled = v;
- scaled.Scale(x_scale, y_scale);
- return scaled;
-}
-
-// Return a vector that is |v| scaled by the given scale factor.
-inline gfx::Vector2dF ScaleVector2d(gfx::Vector2dF v, float scale) {
- return ScaleVector2d(v, scale, scale);
-}
-
} // namespace cc
#endif // CC_GEOMETRY_H_
diff --git a/cc/input_handler.h b/cc/input_handler.h
index 6898c1f..5f6a706 100644
--- a/cc/input_handler.h
+++ b/cc/input_handler.h
@@ -11,11 +11,13 @@
namespace gfx {
class Point;
-class Vector2d;
}
namespace cc {
+class IntPoint;
+class IntSize;
+
// The InputHandler is a way for the embedders to interact with
// the impl thread side of the compositor implementation.
//
@@ -34,7 +36,7 @@ public:
// can be scrolled, ScrollOnMainThread if the scroll event should instead be
// delegated to the main thread, or ScrollIgnored if there is nothing to be
// scrolled at the given coordinates.
- virtual ScrollStatus scrollBegin(gfx::Point, ScrollInputType) = 0;
+ virtual ScrollStatus scrollBegin(const gfx::Point&, ScrollInputType) = 0;
// Scroll the selected layer starting at the given position. If the scroll
// type given to scrollBegin was a gesture, then the scroll point and delta
@@ -43,17 +45,17 @@ public:
// layer in the requested direction, its first ancestor layer that can be
// scrolled will be moved instead. Should only be called if scrollBegin()
// returned ScrollStarted.
- virtual void scrollBy(gfx::Point, gfx::Vector2d) = 0;
+ virtual void scrollBy(const gfx::Point&, const IntSize&) = 0;
// Stop scrolling the selected layer. Should only be called if scrollBegin()
// returned ScrollStarted.
virtual void scrollEnd() = 0;
virtual void pinchGestureBegin() = 0;
- virtual void pinchGestureUpdate(float magnifyDelta, gfx::Point anchor) = 0;
+ virtual void pinchGestureUpdate(float magnifyDelta, const IntPoint& anchor) = 0;
virtual void pinchGestureEnd() = 0;
- virtual void startPageScaleAnimation(gfx::Vector2d targetOffset,
+ virtual void startPageScaleAnimation(const IntSize& targetPosition,
bool anchorPoint,
float pageScale,
base::TimeTicks startTime,
diff --git a/cc/layer.cc b/cc/layer.cc
index b11c5e6..1377dec 100644
--- a/cc/layer.cc
+++ b/cc/layer.cc
@@ -408,21 +408,21 @@ bool Layer::transformIsAnimating() const
return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Transform);
}
-void Layer::setScrollOffset(gfx::Vector2d scrollOffset)
+void Layer::setScrollPosition(const IntPoint& scrollPosition)
{
- if (m_scrollOffset == scrollOffset)
+ if (m_scrollPosition == scrollPosition)
return;
- m_scrollOffset = scrollOffset;
+ m_scrollPosition = scrollPosition;
if (m_layerScrollClient)
m_layerScrollClient->didScroll();
setNeedsCommit();
}
-void Layer::setMaxScrollOffset(gfx::Vector2d maxScrollOffset)
+void Layer::setMaxScrollPosition(const IntSize& maxScrollPosition)
{
- if (m_maxScrollOffset == maxScrollOffset)
+ if (m_maxScrollPosition == maxScrollPosition)
return;
- m_maxScrollOffset = maxScrollOffset;
+ m_maxScrollPosition = maxScrollPosition;
setNeedsCommit();
}
@@ -587,8 +587,8 @@ void Layer::pushPropertiesTo(LayerImpl* layer)
layer->setFixedToContainerLayer(m_fixedToContainerLayer);
layer->setPreserves3D(preserves3D());
layer->setUseParentBackfaceVisibility(m_useParentBackfaceVisibility);
- layer->setScrollOffset(m_scrollOffset);
- layer->setMaxScrollOffset(m_maxScrollOffset);
+ layer->setScrollPosition(m_scrollPosition);
+ layer->setMaxScrollPosition(m_maxScrollPosition);
layer->setSublayerTransform(m_sublayerTransform);
if (!transformIsAnimating())
layer->setTransform(m_transform);
@@ -600,7 +600,7 @@ void Layer::pushPropertiesTo(LayerImpl* layer)
layer->setUpdateRect(m_updateRect);
layer->setScrollDelta(layer->scrollDelta() - layer->sentScrollDelta());
- layer->setSentScrollDelta(gfx::Vector2d());
+ layer->setSentScrollDelta(IntSize());
layer->setStackingOrderChanged(m_stackingOrderChanged);
diff --git a/cc/layer.h b/cc/layer.h
index 3375b65..d827ed4 100644
--- a/cc/layer.h
+++ b/cc/layer.h
@@ -5,6 +5,7 @@
#ifndef CC_LAYER_H_
#define CC_LAYER_H_
+#include "IntPoint.h"
#include "Region.h"
#include "base/memory/ref_counted.h"
#include "cc/cc_export.h"
@@ -128,11 +129,11 @@ public:
const gfx::Rect& visibleContentRect() const { return m_visibleContentRect; }
void setVisibleContentRect(const gfx::Rect& visibleContentRect) { m_visibleContentRect = visibleContentRect; }
- void setScrollOffset(gfx::Vector2d);
- gfx::Vector2d scrollOffset() const { return m_scrollOffset; }
+ void setScrollPosition(const IntPoint&);
+ const IntPoint& scrollPosition() const { return m_scrollPosition; }
- void setMaxScrollOffset(gfx::Vector2d);
- gfx::Vector2d maxScrollOffset() const { return m_maxScrollOffset; }
+ void setMaxScrollPosition(const IntSize&);
+ const IntSize& maxScrollPosition() const { return m_maxScrollPosition; }
void setScrollable(bool);
bool scrollable() const { return m_scrollable; }
@@ -155,7 +156,7 @@ public:
bool forceRenderSurface() const { return m_forceRenderSurface; }
void setForceRenderSurface(bool);
- gfx::Vector2d scrollDelta() const { return gfx::Vector2d(); }
+ IntSize scrollDelta() const { return IntSize(); }
void setImplTransform(const WebKit::WebTransformationMatrix&);
const WebKit::WebTransformationMatrix& implTransform() const { return m_implTransform; }
@@ -343,8 +344,8 @@ private:
// Uses layer's content space.
gfx::Rect m_visibleContentRect;
- gfx::Vector2d m_scrollOffset;
- gfx::Vector2d m_maxScrollOffset;
+ IntPoint m_scrollPosition;
+ IntSize m_maxScrollPosition;
bool m_scrollable;
bool m_shouldScrollOnMainThread;
bool m_haveWheelEventHandlers;
diff --git a/cc/layer_impl.cc b/cc/layer_impl.cc
index 0b57f67..54e45fad 100644
--- a/cc/layer_impl.cc
+++ b/cc/layer_impl.cc
@@ -9,7 +9,6 @@
#include "base/debug/trace_event.h"
#include "base/stringprintf.h"
#include "cc/debug_border_draw_quad.h"
-#include "cc/geometry.h"
#include "cc/layer_sorter.h"
#include "cc/math_util.h"
#include "cc/proxy.h"
@@ -180,15 +179,13 @@ ResourceProvider::ResourceId LayerImpl::contentsResourceId() const
return 0;
}
-gfx::Vector2dF LayerImpl::scrollBy(const gfx::Vector2dF& scroll)
+FloatSize LayerImpl::scrollBy(const FloatSize& scroll)
{
- gfx::Vector2dF minDelta = -m_scrollOffset;
- gfx::Vector2dF maxDelta = m_maxScrollOffset - m_scrollOffset;
+ IntSize minDelta = -toSize(m_scrollPosition);
+ IntSize maxDelta = m_maxScrollPosition - toSize(m_scrollPosition);
// Clamp newDelta so that position + delta stays within scroll bounds.
- gfx::Vector2dF newDelta = (m_scrollDelta + scroll);
- newDelta = ClampFromBelow(newDelta, minDelta);
- newDelta = ClampFromAbove(newDelta, maxDelta);
- gfx::Vector2dF unscrolled = m_scrollDelta + scroll - newDelta;
+ FloatSize newDelta = (m_scrollDelta + scroll).expandedTo(minDelta).shrunkTo(maxDelta);
+ FloatSize unscrolled = m_scrollDelta + scroll - newDelta;
if (m_scrollDelta == newDelta)
return unscrolled;
@@ -626,16 +623,16 @@ void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY)
m_layerPropertyChanged = true;
}
-void LayerImpl::setScrollOffset(gfx::Vector2d scrollOffset)
+void LayerImpl::setScrollPosition(const IntPoint& scrollPosition)
{
- if (m_scrollOffset == scrollOffset)
+ if (m_scrollPosition == scrollPosition)
return;
- m_scrollOffset = scrollOffset;
+ m_scrollPosition = scrollPosition;
noteLayerPropertyChangedForSubtree();
}
-void LayerImpl::setScrollDelta(const gfx::Vector2dF& scrollDelta)
+void LayerImpl::setScrollDelta(const FloatSize& scrollDelta)
{
if (m_scrollDelta == scrollDelta)
return;
@@ -673,9 +670,9 @@ void LayerImpl::didLoseContext()
{
}
-void LayerImpl::setMaxScrollOffset(gfx::Vector2d maxScrollOffset)
+void LayerImpl::setMaxScrollPosition(const IntSize& maxScrollPosition)
{
- m_maxScrollOffset = maxScrollOffset;
+ m_maxScrollPosition = maxScrollPosition;
if (!m_scrollbarAnimationController)
return;
diff --git a/cc/layer_impl.h b/cc/layer_impl.h
index c467d82..d51f3d0 100644
--- a/cc/layer_impl.h
+++ b/cc/layer_impl.h
@@ -7,6 +7,8 @@
#include <string>
+#include "FloatSize.h"
+#include "IntPoint.h"
#include "Region.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -185,23 +187,23 @@ public:
float contentsScaleY() const { return m_contentsScaleY; }
void setContentsScale(float contentsScaleX, float contentsScaleY);
- gfx::Vector2d scrollOffset() const { return m_scrollOffset; }
- void setScrollOffset(gfx::Vector2d);
+ const IntPoint& scrollPosition() const { return m_scrollPosition; }
+ void setScrollPosition(const IntPoint&);
- gfx::Vector2d maxScrollOffset() const {return m_maxScrollOffset; }
- void setMaxScrollOffset(gfx::Vector2d);
+ const IntSize& maxScrollPosition() const {return m_maxScrollPosition; }
+ void setMaxScrollPosition(const IntSize&);
- const gfx::Vector2dF& scrollDelta() const { return m_scrollDelta; }
- void setScrollDelta(const gfx::Vector2dF&);
+ const FloatSize& scrollDelta() const { return m_scrollDelta; }
+ void setScrollDelta(const FloatSize&);
const WebKit::WebTransformationMatrix& implTransform() const { return m_implTransform; }
void setImplTransform(const WebKit::WebTransformationMatrix& transform);
- const gfx::Vector2d& sentScrollDelta() const { return m_sentScrollDelta; }
- void setSentScrollDelta(const gfx::Vector2d& sentScrollDelta) { m_sentScrollDelta = sentScrollDelta; }
+ const IntSize& sentScrollDelta() const { return m_sentScrollDelta; }
+ void setSentScrollDelta(const IntSize& sentScrollDelta) { m_sentScrollDelta = sentScrollDelta; }
// Returns the delta of the scroll that was outside of the bounds of the initial scroll
- gfx::Vector2dF scrollBy(const gfx::Vector2dF& scroll);
+ FloatSize scrollBy(const FloatSize& scroll);
bool scrollable() const { return m_scrollable; }
void setScrollable(bool scrollable) { m_scrollable = scrollable; }
@@ -314,7 +316,7 @@ private:
gfx::Size m_contentBounds;
float m_contentsScaleX;
float m_contentsScaleY;
- gfx::Vector2d m_scrollOffset;
+ IntPoint m_scrollPosition;
bool m_scrollable;
bool m_shouldScrollOnMainThread;
bool m_haveWheelEventHandlers;
@@ -354,9 +356,9 @@ private:
// This is true if the layer should be fixed to the closest ancestor container.
bool m_fixedToContainerLayer;
- gfx::Vector2dF m_scrollDelta;
- gfx::Vector2d m_sentScrollDelta;
- gfx::Vector2d m_maxScrollOffset;
+ FloatSize m_scrollDelta;
+ IntSize m_sentScrollDelta;
+ IntSize m_maxScrollPosition;
WebKit::WebTransformationMatrix m_implTransform;
// The layer whose coordinate space this layer draws into. This can be
diff --git a/cc/layer_impl_unittest.cc b/cc/layer_impl_unittest.cc
index eafbc88..b852078 100644
--- a/cc/layer_impl_unittest.cc
+++ b/cc/layer_impl_unittest.cc
@@ -76,7 +76,6 @@ TEST(LayerImplTest, verifyLayerChangesAreTrackedProperly)
float arbitraryNumber = 0.352f;
gfx::Size arbitrarySize = gfx::Size(111, 222);
gfx::Point arbitraryPoint = gfx::Point(333, 444);
- gfx::Vector2d arbitraryVector2d = gfx::Vector2d(111, 222);
gfx::Rect arbitraryRect = gfx::Rect(arbitraryPoint, arbitrarySize);
gfx::RectF arbitraryRectF = gfx::RectF(arbitraryPointF, gfx::SizeF(1.234f, 5.678f));
SkColor arbitraryColor = SkColorSetRGB(10, 20, 30);
@@ -95,7 +94,7 @@ TEST(LayerImplTest, verifyLayerChangesAreTrackedProperly)
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawableContentRect(arbitraryRect));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setUpdateRect(arbitraryRectF));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setVisibleContentRect(arbitraryRect));
- EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setMaxScrollOffset(arbitraryVector2d));
+ EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setMaxScrollPosition(cc::IntSize(arbitrarySize)));
// Changing these properties affects the entire subtree of layers.
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setAnchorPoint(arbitraryPointF));
@@ -110,9 +109,9 @@ TEST(LayerImplTest, verifyLayerChangesAreTrackedProperly)
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setPosition(arbitraryPointF));
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setPreserves3D(true));
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setDoubleSided(false)); // constructor initializes it to "true".
- EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->scrollBy(arbitraryVector2d));
- EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setScrollDelta(gfx::Vector2d()));
- EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setScrollOffset(arbitraryVector2d));
+ EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->scrollBy(cc::IntSize(arbitrarySize)));
+ EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setScrollDelta(cc::IntSize()));
+ EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setScrollPosition(cc::IntPoint(arbitraryPoint)));
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setImplTransform(arbitraryTransform));
// Changing these properties only affects the layer itself.
@@ -150,8 +149,8 @@ TEST(LayerImplTest, verifyLayerChangesAreTrackedProperly)
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setPreserves3D(true));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setTransform(arbitraryTransform));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDoubleSided(false)); // constructor initializes it to "true".
- EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScrollDelta(gfx::Vector2d()));
- EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScrollOffset(arbitraryVector2d));
+ EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScrollDelta(cc::IntSize()));
+ EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScrollPosition(cc::IntPoint(arbitraryPoint)));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setImplTransform(arbitraryTransform));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setContentBounds(arbitrarySize));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setContentsScale(arbitraryNumber, arbitraryNumber));
diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc
index 65200d7..f9eae12 100644
--- a/cc/layer_tree_host.cc
+++ b/cc/layer_tree_host.cc
@@ -451,9 +451,9 @@ void LayerTreeHost::setVisible(bool visible)
m_proxy->setVisible(visible);
}
-void LayerTreeHost::startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration)
+void LayerTreeHost::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration)
{
- m_proxy->startPageScaleAnimation(targetOffset, useAnchor, scale, duration);
+ m_proxy->startPageScaleAnimation(targetPosition, useAnchor, scale, duration);
}
void LayerTreeHost::loseContext(int numTimes)
@@ -694,7 +694,7 @@ void LayerTreeHost::applyScrollAndScale(const ScrollAndScaleSet& info)
return;
Layer* rootScrollLayer = findFirstScrollableLayer(m_rootLayer.get());
- gfx::Vector2d rootScrollDelta;
+ IntSize rootScrollDelta;
for (size_t i = 0; i < info.scrolls.size(); ++i) {
Layer* layer = LayerTreeHostCommon::findLayerInSubtree(m_rootLayer.get(), info.scrolls[i].layerId);
@@ -703,9 +703,9 @@ void LayerTreeHost::applyScrollAndScale(const ScrollAndScaleSet& info)
if (layer == rootScrollLayer)
rootScrollDelta += info.scrolls[i].scrollDelta;
else
- layer->setScrollOffset(layer->scrollOffset() + info.scrolls[i].scrollDelta);
+ layer->setScrollPosition(layer->scrollPosition() + info.scrolls[i].scrollDelta);
}
- if (!rootScrollDelta.IsZero() || info.pageScaleDelta != 1)
+ if (!rootScrollDelta.isZero() || info.pageScaleDelta != 1)
m_client->applyScrollAndScale(rootScrollDelta, info.pageScaleDelta);
}
diff --git a/cc/layer_tree_host.h b/cc/layer_tree_host.h
index 74e999b..7dd334c 100644
--- a/cc/layer_tree_host.h
+++ b/cc/layer_tree_host.h
@@ -190,7 +190,7 @@ public:
bool visible() const { return m_visible; }
void setVisible(bool);
- void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration);
+ void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration);
void applyScrollAndScale(const ScrollAndScaleSet&);
gfx::PointF adjustEventPointForPinchZoom(const gfx::PointF&) const;
diff --git a/cc/layer_tree_host_client.h b/cc/layer_tree_host_client.h
index f6cb702..3bec0328 100644
--- a/cc/layer_tree_host_client.h
+++ b/cc/layer_tree_host_client.h
@@ -7,16 +7,13 @@
#include "base/memory/scoped_ptr.h"
-namespace gfx {
-class Vector2d;
-}
-
namespace WebKit {
class WebCompositorOutputSurface;
}
namespace cc {
class InputHandler;
+class IntSize;
class LayerTreeHostClient {
public:
@@ -25,7 +22,7 @@ public:
virtual void didBeginFrame() = 0;
virtual void animate(double frameBeginTime) = 0;
virtual void layout() = 0;
- virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float pageScale) = 0;
+ virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) = 0;
virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() = 0;
virtual void didRecreateOutputSurface(bool success) = 0;
virtual scoped_ptr<InputHandler> createInputHandler() = 0;
diff --git a/cc/layer_tree_host_common.cc b/cc/layer_tree_host_common.cc
index ae73d1d..a119b89 100644
--- a/cc/layer_tree_host_common.cc
+++ b/cc/layer_tree_host_common.cc
@@ -289,7 +289,7 @@ WebTransformationMatrix computeScrollCompensationForThisLayer(LayerImpl* scrolli
partialLayerOriginTransform.multiply(scrollingLayer->implTransform());
WebTransformationMatrix scrollCompensationForThisLayer = partialLayerOriginTransform; // Step 3
- scrollCompensationForThisLayer.translate(scrollingLayer->scrollDelta().x(), scrollingLayer->scrollDelta().y()); // Step 2
+ scrollCompensationForThisLayer.translate(scrollingLayer->scrollDelta().width(), scrollingLayer->scrollDelta().height()); // Step 2
scrollCompensationForThisLayer.multiply(partialLayerOriginTransform.inverse()); // Step 1
return scrollCompensationForThisLayer;
}
@@ -320,7 +320,7 @@ WebTransformationMatrix computeScrollCompensationMatrixForChildren(LayerImpl* la
//
// Avoid the overheads (including stack allocation and matrix initialization/copy) if we know that the scroll compensation doesn't need to be reset or adjusted.
- if (!layer->isContainerForFixedPositionLayers() && layer->scrollDelta().IsZero() && !layer->renderSurface())
+ if (!layer->isContainerForFixedPositionLayers() && layer->scrollDelta().isZero() && !layer->renderSurface())
return currentScrollCompensationMatrix;
// Start as identity matrix.
@@ -332,7 +332,7 @@ WebTransformationMatrix computeScrollCompensationMatrixForChildren(LayerImpl* la
// If the current layer has a non-zero scrollDelta, then we should compute its local scrollCompensation
// and accumulate it to the nextScrollCompensationMatrix.
- if (!layer->scrollDelta().IsZero()) {
+ if (!layer->scrollDelta().isZero()) {
WebTransformationMatrix scrollCompensationForThisLayer = computeScrollCompensationForThisLayer(layer, parentMatrix);
nextScrollCompensationMatrix.multiply(scrollCompensationForThisLayer);
}
@@ -491,7 +491,7 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
gfx::Size bounds = layer->bounds();
gfx::PointF anchorPoint = layer->anchorPoint();
- gfx::PointF position = layer->position() - layer->scrollDelta();
+ gfx::PointF position = layer->position() - gfx::Vector2d(layer->scrollDelta().width(), layer->scrollDelta().height());
WebTransformationMatrix layerLocalTransform;
// LT = Tr[origin] * Tr[origin2anchor]
diff --git a/cc/layer_tree_host_common.h b/cc/layer_tree_host_common.h
index cc5e621..78ec5e4 100644
--- a/cc/layer_tree_host_common.h
+++ b/cc/layer_tree_host_common.h
@@ -9,7 +9,7 @@
#include "cc/cc_export.h"
#include "cc/scoped_ptr_vector.h"
#include "ui/gfx/rect.h"
-#include "ui/gfx/vector2d.h"
+#include "IntSize.h"
#include <public/WebTransformationMatrix.h>
namespace cc {
@@ -46,7 +46,7 @@ public:
struct ScrollUpdateInfo {
int layerId;
- gfx::Vector2d scrollDelta;
+ IntSize scrollDelta;
};
};
diff --git a/cc/layer_tree_host_common_unittest.cc b/cc/layer_tree_host_common_unittest.cc
index 962d39c..e18137a 100644
--- a/cc/layer_tree_host_common_unittest.cc
+++ b/cc/layer_tree_host_common_unittest.cc
@@ -801,7 +801,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
grandChild->setFixedToContainerLayer(true);
// Case 1: scrollDelta of 0, 0
- child->setScrollDelta(gfx::Vector2d(0, 0));
+ child->setScrollDelta(IntSize(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedChildTransform;
@@ -811,7 +811,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
// Case 2: scrollDelta of 10, 10
- child->setScrollDelta(gfx::Vector2d(10, 10));
+ child->setScrollDelta(IntSize(10, 10));
executeCalculateDrawTransformsAndVisibility(root.get());
// Here the child is affected by scrollDelta, but the fixed position grandChild should not be affected.
@@ -847,7 +847,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT
grandChild->setFixedToContainerLayer(true);
// Case 1: scrollDelta of 0, 0
- child->setScrollDelta(gfx::Vector2d(0, 0));
+ child->setScrollDelta(IntSize(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedChildTransform;
@@ -859,7 +859,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
// Case 2: scrollDelta of 10, 20
- child->setScrollDelta(gfx::Vector2d(10, 20));
+ child->setScrollDelta(IntSize(10, 20));
executeCalculateDrawTransformsAndVisibility(root.get());
// The child should be affected by scrollDelta, but the fixed position grandChild should not be affected.
@@ -887,7 +887,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
greatGrandChild->setFixedToContainerLayer(true);
// Case 1: scrollDelta of 0, 0
- child->setScrollDelta(gfx::Vector2d(0, 0));
+ child->setScrollDelta(IntSize(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedChildTransform;
@@ -901,7 +901,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrandChild->drawTransform());
// Case 2: scrollDelta of 10, 10
- child->setScrollDelta(gfx::Vector2d(10, 10));
+ child->setScrollDelta(IntSize(10, 10));
executeCalculateDrawTransformsAndVisibility(root.get());
// Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected.
@@ -936,7 +936,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is positioned upside-down with respect to the renderTarget.
// Case 1: scrollDelta of 0, 0
- child->setScrollDelta(gfx::Vector2d(0, 0));
+ child->setScrollDelta(IntSize(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedChildTransform;
@@ -954,7 +954,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrandChild->drawTransform());
// Case 2: scrollDelta of 10, 20
- child->setScrollDelta(gfx::Vector2d(10, 20));
+ child->setScrollDelta(IntSize(10, 20));
executeCalculateDrawTransformsAndVisibility(root.get());
// Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected.
@@ -998,7 +998,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is positioned upside-down with respect to the renderTarget.
// Case 1: scrollDelta of 0, 0
- child->setScrollDelta(gfx::Vector2d(0, 0));
+ child->setScrollDelta(IntSize(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedChildTransform;
@@ -1016,8 +1016,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrandChild->drawTransform());
// Case 2: scrollDelta of 10, 20
- child->setScrollDelta(gfx::Vector2d(10, 0));
- grandChild->setScrollDelta(gfx::Vector2d(5, 0));
+ child->setScrollDelta(IntSize(10, 0));
+ grandChild->setScrollDelta(IntSize(5, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
// Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected.
@@ -1061,7 +1061,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithI
grandChild->setTransform(rotationAboutZ);
// Case 1: scrollDelta of 0, 0
- child->setScrollDelta(gfx::Vector2d(0, 0));
+ child->setScrollDelta(IntSize(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedChildTransform;
@@ -1077,7 +1077,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithI
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrandChild->drawTransform());
// Case 2: scrollDelta of 10, 30
- child->setScrollDelta(gfx::Vector2d(10, 30));
+ child->setScrollDelta(IntSize(10, 30));
executeCalculateDrawTransformsAndVisibility(root.get());
// Here the grandChild remains unchanged, because it scrolls along with the
@@ -1153,7 +1153,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
greatGrandChild->setTransform(rotationAboutZ);
// Case 1: scrollDelta of 0, 0
- child->setScrollDelta(gfx::Vector2d(0, 0));
+ child->setScrollDelta(IntSize(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedChildTransform;
@@ -1182,7 +1182,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPositionChild->drawTransform());
// Case 2: scrollDelta of 10, 30
- child->setScrollDelta(gfx::Vector2d(10, 30));
+ child->setScrollDelta(IntSize(10, 30));
executeCalculateDrawTransformsAndVisibility(root.get());
expectedChildTransform.makeIdentity();
@@ -1239,7 +1239,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithC
grandChild->setDrawsContent(true);
// Case 1: scrollDelta of 0, 0
- child->setScrollDelta(gfx::Vector2d(0, 0));
+ child->setScrollDelta(IntSize(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedSurfaceDrawTransform;
@@ -1252,7 +1252,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithC
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
// Case 2: scrollDelta of 10, 10
- child->setScrollDelta(gfx::Vector2d(10, 10));
+ child->setScrollDelta(IntSize(10, 10));
executeCalculateDrawTransformsAndVisibility(root.get());
// The surface is translated by scrollDelta, the child transform doesn't change
@@ -1287,7 +1287,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatI
grandChild->setIsContainerForFixedPositionLayers(true);
// Case 1: scrollDelta of 0, 0
- child->setScrollDelta(gfx::Vector2d(0, 0));
+ child->setScrollDelta(IntSize(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedChildTransform;
@@ -1296,7 +1296,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatI
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
// Case 2: scrollDelta of 10, 10
- child->setScrollDelta(gfx::Vector2d(10, 10));
+ child->setScrollDelta(IntSize(10, 10));
executeCalculateDrawTransformsAndVisibility(root.get());
// Here the child is affected by scrollDelta, but the fixed position grandChild should not be affected.
@@ -1324,7 +1324,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH
grandChild->setFixedToContainerLayer(true);
// Case 1: root scrollDelta of 0, 0
- root->setScrollDelta(gfx::Vector2d(0, 0));
+ root->setScrollDelta(IntSize(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix identityMatrix;
@@ -1333,7 +1333,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH
EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform());
// Case 2: root scrollDelta of 10, 10
- root->setScrollDelta(gfx::Vector2d(10, 20));
+ root->setScrollDelta(IntSize(10, 20));
executeCalculateDrawTransformsAndVisibility(root.get());
// The child is affected by scrollDelta, but it is already implcitly accounted for by
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc
index 2f5ee5c..73568ff 100644
--- a/cc/layer_tree_host_impl.cc
+++ b/cc/layer_tree_host_impl.cc
@@ -14,7 +14,6 @@
#include "cc/delay_based_time_source.h"
#include "cc/font_atlas.h"
#include "cc/frame_rate_counter.h"
-#include "cc/geometry.h"
#include "cc/gl_renderer.h"
#include "cc/heads_up_display_layer_impl.h"
#include "cc/layer_iterator.h"
@@ -33,7 +32,6 @@
#include "cc/software_renderer.h"
#include "cc/texture_uploader.h"
#include "ui/gfx/size_conversions.h"
-#include "ui/gfx/vector2d_conversions.h"
#include <algorithm>
using WebKit::WebTransformationMatrix;
@@ -103,12 +101,12 @@ gfx::RectF PinchZoomViewport::bounds() const
scaledViewportSize = scaledViewportSize.Scale(1 / totalPageScaleFactor());
gfx::RectF bounds(gfx::PointF(), scaledViewportSize);
- bounds.Offset(m_pinchViewportScrollDelta);
+ bounds.set_origin(m_pinchViewportScrollDelta);
return bounds;
}
-gfx::Vector2dF PinchZoomViewport::applyScroll(const gfx::Vector2dF& delta)
+FloatSize PinchZoomViewport::applyScroll(const gfx::Vector2dF& delta)
{
gfx::Vector2dF overflow;
gfx::RectF pinchedBounds = bounds();
@@ -133,9 +131,9 @@ gfx::Vector2dF PinchZoomViewport::applyScroll(const gfx::Vector2dF& delta)
overflow.set_y(pinchedBounds.bottom() - m_layoutViewportSize.height());
pinchedBounds.Offset(0, m_layoutViewportSize.height() - pinchedBounds.bottom());
}
- m_pinchViewportScrollDelta = pinchedBounds.OffsetFromOrigin();
+ m_pinchViewportScrollDelta = cc::FloatPoint(pinchedBounds.origin());
- return overflow;
+ return cc::FloatSize(overflow);
}
WebTransformationMatrix PinchZoomViewport::implTransform() const
@@ -251,7 +249,7 @@ void LayerTreeHostImpl::commitComplete()
TRACE_EVENT0("cc", "LayerTreeHostImpl::commitComplete");
// Recompute max scroll position; must be after layer content bounds are
// updated.
- updateMaxScrollOffset();
+ updateMaxScrollPosition();
m_client->sendManagedMemoryStats();
}
@@ -292,26 +290,26 @@ void LayerTreeHostImpl::animate(base::TimeTicks monotonicTime, base::Time wallCl
animateScrollbars(monotonicTime);
}
-void LayerTreeHostImpl::startPageScaleAnimation(gfx::Vector2d targetOffset, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta duration)
+void LayerTreeHostImpl::startPageScaleAnimation(const IntSize& targetPosition, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta duration)
{
if (!m_rootScrollLayerImpl)
return;
- gfx::Vector2dF scrollTotal = m_rootScrollLayerImpl->scrollOffset() + m_rootScrollLayerImpl->scrollDelta();
- scrollTotal.Scale(m_pinchZoomViewport.pageScaleDelta());
+ IntSize scrollTotal = flooredIntSize(m_rootScrollLayerImpl->scrollPosition() + m_rootScrollLayerImpl->scrollDelta());
+ scrollTotal.scale(m_pinchZoomViewport.pageScaleDelta());
float scaleTotal = m_pinchZoomViewport.totalPageScaleFactor();
gfx::Size scaledContentSize = gfx::ToFlooredSize(contentSize().Scale(m_pinchZoomViewport.pageScaleDelta()));
double startTimeSeconds = (startTime - base::TimeTicks()).InSecondsF();
- m_pageScaleAnimation = PageScaleAnimation::create(gfx::ToFlooredVector2d(scrollTotal), scaleTotal, m_deviceViewportSize, scaledContentSize, startTimeSeconds);
+ m_pageScaleAnimation = PageScaleAnimation::create(scrollTotal, scaleTotal, cc::IntSize(m_deviceViewportSize), scaledContentSize, startTimeSeconds);
if (anchorPoint) {
- gfx::Vector2dF windowAnchor = targetOffset;
- windowAnchor.Scale(scaleTotal / pageScale);
+ IntSize windowAnchor(targetPosition);
+ windowAnchor.scale(scaleTotal / pageScale);
windowAnchor -= scrollTotal;
- m_pageScaleAnimation->zoomWithAnchor(gfx::ToFlooredVector2d(windowAnchor), pageScale, duration.InSecondsF());
+ m_pageScaleAnimation->zoomWithAnchor(windowAnchor, pageScale, duration.InSecondsF());
} else
- m_pageScaleAnimation->zoomTo(targetOffset, pageScale, duration.InSecondsF());
+ m_pageScaleAnimation->zoomTo(targetPosition, pageScale, duration.InSecondsF());
m_client->setNeedsRedrawOnImplThread();
m_client->setNeedsCommitOnImplThread();
@@ -892,9 +890,9 @@ void LayerTreeHostImpl::setViewportSize(const gfx::Size& layoutViewportSize, con
m_layoutViewportSize = layoutViewportSize;
m_deviceViewportSize = deviceViewportSize;
- m_pinchZoomViewport.setLayoutViewportSize(layoutViewportSize);
+ m_pinchZoomViewport.setLayoutViewportSize(FloatSize(layoutViewportSize));
- updateMaxScrollOffset();
+ updateMaxScrollPosition();
if (m_renderer)
m_renderer->viewportChanged();
@@ -909,8 +907,8 @@ static void adjustScrollsForPageScaleChange(LayerImpl* layerImpl, float pageScal
if (layerImpl->scrollable()) {
// We need to convert impl-side scroll deltas to pageScale space.
- gfx::Vector2dF scrollDelta = layerImpl->scrollDelta();
- scrollDelta.Scale(pageScaleChange);
+ FloatSize scrollDelta = layerImpl->scrollDelta();
+ scrollDelta.scale(pageScaleChange);
layerImpl->setScrollDelta(scrollDelta);
}
@@ -924,7 +922,7 @@ void LayerTreeHostImpl::setDeviceScaleFactor(float deviceScaleFactor)
return;
m_deviceScaleFactor = deviceScaleFactor;
- updateMaxScrollOffset();
+ updateMaxScrollPosition();
}
float LayerTreeHostImpl::pageScaleFactor() const
@@ -954,10 +952,10 @@ void LayerTreeHostImpl::setPageScaleDelta(float delta)
{
m_pinchZoomViewport.setPageScaleDelta(delta);
- updateMaxScrollOffset();
+ updateMaxScrollPosition();
}
-void LayerTreeHostImpl::updateMaxScrollOffset()
+void LayerTreeHostImpl::updateMaxScrollPosition()
{
if (!m_rootScrollLayerImpl || !m_rootScrollLayerImpl->children().size())
return;
@@ -983,14 +981,14 @@ void LayerTreeHostImpl::updateMaxScrollOffset()
viewBounds = viewBounds.Scale(1 / m_pinchZoomViewport.pageScaleDelta());
}
- gfx::Vector2dF maxScroll = BottomRight(gfx::Rect(contentBounds)) - BottomRight(gfx::RectF(viewBounds));
- maxScroll.Scale(1 / m_deviceScaleFactor);
+ IntSize maxScroll = cc::IntSize(contentBounds) - expandedIntSize(cc::FloatSize(viewBounds));
+ maxScroll.scale(1 / m_deviceScaleFactor);
// The viewport may be larger than the contents in some cases, such as
// having a vertical scrollbar but no horizontal overflow.
- maxScroll = ClampFromBelow(maxScroll, gfx::Vector2dF());
+ maxScroll.clampNegativeToZero();
- m_rootScrollLayerImpl->setMaxScrollOffset(gfx::ToFlooredVector2d(maxScroll));
+ m_rootScrollLayerImpl->setMaxScrollPosition(maxScroll);
}
void LayerTreeHostImpl::setNeedsRedraw()
@@ -1019,7 +1017,7 @@ bool LayerTreeHostImpl::ensureRenderSurfaceLayerList()
return m_renderSurfaceLayerList.size();
}
-InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewportPoint, InputHandlerClient::ScrollInputType type)
+InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(const gfx::Point& viewportPoint, InputHandlerClient::ScrollInputType type)
{
TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin");
@@ -1072,7 +1070,7 @@ InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp
return ScrollIgnored;
}
-static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewport, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF viewportPoint, gfx::Vector2dF viewportDelta)
+static FloatSize scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewport, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, const gfx::PointF& viewportPoint, const FloatSize& viewportDelta)
{
// Layers with non-invertible screen space transforms should not have passed the scroll hit
// test in the first place.
@@ -1081,8 +1079,8 @@ static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewp
gfx::PointF screenSpacePoint = viewportPoint.Scale(scaleFromViewportToScreenSpace);
- gfx::Vector2dF screenSpaceDelta = viewportDelta;
- screenSpaceDelta.Scale(scaleFromViewportToScreenSpace);
+ FloatSize screenSpaceDelta = viewportDelta;
+ screenSpaceDelta.scale(scaleFromViewportToScreenSpace, scaleFromViewportToScreenSpace);
// First project the scroll start and end points to local layer space to find the scroll delta
// in layer coordinates.
@@ -1095,7 +1093,7 @@ static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewp
DCHECK(!startClipped);
DCHECK(!endClipped);
if (startClipped || endClipped)
- return gfx::Vector2dF();
+ return FloatSize();
// localStartPoint and localEndPoint are in content space but we want to move them to layer space for scrolling.
float widthScale = 1 / layerImpl.contentsScaleX();
@@ -1104,8 +1102,8 @@ static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewp
localEndPoint = localEndPoint.Scale(widthScale, heightScale);
// Apply the scroll delta.
- gfx::Vector2dF previousDelta = layerImpl.scrollDelta();
- gfx::Vector2dF unscrolled = layerImpl.scrollBy(localEndPoint - localStartPoint);
+ FloatSize previousDelta(layerImpl.scrollDelta());
+ FloatSize unscrolled = layerImpl.scrollBy(cc::FloatSize(localEndPoint - localStartPoint));
if (viewport)
viewport->applyScroll(unscrolled);
@@ -1118,32 +1116,32 @@ static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewp
gfx::PointF actualScreenSpaceEndPoint = MathUtil::mapPoint(layerImpl.screenSpaceTransform(), actualLocalContentEndPoint, endClipped);
DCHECK(!endClipped);
if (endClipped)
- return gfx::Vector2dF();
+ return FloatSize();
gfx::PointF actualViewportEndPoint = actualScreenSpaceEndPoint.Scale(1 / scaleFromViewportToScreenSpace);
- return actualViewportEndPoint - viewportPoint;
+ return cc::FloatSize(actualViewportEndPoint - viewportPoint);
}
-static gfx::Vector2dF scrollLayerWithLocalDelta(LayerImpl& layerImpl, gfx::Vector2dF localDelta)
+static FloatSize scrollLayerWithLocalDelta(LayerImpl& layerImpl, const FloatSize& localDelta)
{
- gfx::Vector2dF previousDelta(layerImpl.scrollDelta());
+ FloatSize previousDelta(layerImpl.scrollDelta());
layerImpl.scrollBy(localDelta);
return layerImpl.scrollDelta() - previousDelta;
}
-void LayerTreeHostImpl::scrollBy(gfx::Point viewportPoint, gfx::Vector2d scrollDelta)
+void LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint, const IntSize& scrollDelta)
{
TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy");
if (!m_currentlyScrollingLayerImpl)
return;
- gfx::Vector2dF pendingDelta = scrollDelta;
+ FloatSize pendingDelta(scrollDelta);
for (LayerImpl* layerImpl = m_currentlyScrollingLayerImpl; layerImpl; layerImpl = layerImpl->parent()) {
if (!layerImpl->scrollable())
continue;
PinchZoomViewport* viewport = layerImpl == m_rootScrollLayerImpl ? &m_pinchZoomViewport : 0;
- gfx::Vector2dF appliedDelta;
+ FloatSize appliedDelta;
if (m_scrollDeltaIsInViewportSpace) {
float scaleFromViewportToScreenSpace = m_deviceScaleFactor;
appliedDelta = scrollLayerWithViewportSpaceDelta(viewport, *layerImpl, scaleFromViewportToScreenSpace, viewportPoint, pendingDelta);
@@ -1152,27 +1150,27 @@ void LayerTreeHostImpl::scrollBy(gfx::Point viewportPoint, gfx::Vector2d scrollD
// If the layer wasn't able to move, try the next one in the hierarchy.
float moveThresholdSquared = 0.1f * 0.1f;
- if (appliedDelta.LengthSquared() < moveThresholdSquared)
+ if (appliedDelta.diagonalLengthSquared() < moveThresholdSquared)
continue;
// If the applied delta is within 45 degrees of the input delta, bail out to make it easier
// to scroll just one layer in one direction without affecting any of its parents.
float angleThreshold = 45;
if (MathUtil::smallestAngleBetweenVectors(appliedDelta, pendingDelta) < angleThreshold) {
- pendingDelta = gfx::Vector2d();
+ pendingDelta = FloatSize();
break;
}
// Allow further movement only on an axis perpendicular to the direction in which the layer
// moved.
- gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x());
+ FloatSize perpendicularAxis(-appliedDelta.height(), appliedDelta.width());
pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis);
- if (gfx::ToFlooredVector2d(pendingDelta).IsZero())
+ if (flooredIntSize(pendingDelta).isZero())
break;
}
- if (!scrollDelta.IsZero() && gfx::ToFlooredVector2d(pendingDelta).IsZero()) {
+ if (!scrollDelta.isZero() && flooredIntSize(pendingDelta).isEmpty()) {
m_client->setNeedsCommitOnImplThread();
m_client->setNeedsRedrawOnImplThread();
}
@@ -1192,40 +1190,42 @@ void LayerTreeHostImpl::scrollEnd()
void LayerTreeHostImpl::pinchGestureBegin()
{
m_pinchGestureActive = true;
- m_previousPinchAnchor = gfx::Point();
+ m_previousPinchAnchor = IntPoint();
if (m_rootScrollLayerImpl && m_rootScrollLayerImpl->scrollbarAnimationController())
m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureBegin();
}
-void LayerTreeHostImpl::pinchGestureUpdate(float magnifyDelta, gfx::Point anchor)
+void LayerTreeHostImpl::pinchGestureUpdate(float magnifyDelta,
+ const IntPoint& anchor)
{
TRACE_EVENT0("cc", "LayerTreeHostImpl::pinchGestureUpdate");
if (!m_rootScrollLayerImpl)
return;
- if (m_previousPinchAnchor == gfx::Point())
+ if (m_previousPinchAnchor == IntPoint::zero())
m_previousPinchAnchor = anchor;
// Keep the center-of-pinch anchor specified by (x, y) in a stable
// position over the course of the magnify.
float pageScaleDelta = m_pinchZoomViewport.pageScaleDelta();
- gfx::PointF previousScaleAnchor = m_previousPinchAnchor.Scale(1 / pageScaleDelta);
+ FloatPoint previousScaleAnchor(m_previousPinchAnchor.x() / pageScaleDelta,
+ m_previousPinchAnchor.y() / pageScaleDelta);
setPageScaleDelta(pageScaleDelta * magnifyDelta);
pageScaleDelta = m_pinchZoomViewport.pageScaleDelta();
- gfx::PointF newScaleAnchor = anchor.Scale(1 / pageScaleDelta);
- gfx::Vector2dF move = previousScaleAnchor - newScaleAnchor;
+ FloatPoint newScaleAnchor(anchor.x() / pageScaleDelta, anchor.y() / pageScaleDelta);
+ FloatSize move = previousScaleAnchor - newScaleAnchor;
m_previousPinchAnchor = anchor;
if (Settings::pageScalePinchZoomEnabled()) {
// Compute the application of the delta with respect to the current page zoom of the page.
- move.Scale(1 / (m_pinchZoomViewport.pageScaleFactor() * m_deviceScaleFactor));
+ move.scale(1 / (m_pinchZoomViewport.pageScaleFactor() * m_deviceScaleFactor));
}
- gfx::Vector2dF scrollOverflow = Settings::pageScalePinchZoomEnabled() ? m_pinchZoomViewport.applyScroll(move) : move;
- m_rootScrollLayerImpl->scrollBy(scrollOverflow);
+ FloatSize scrollOverflow = Settings::pageScalePinchZoomEnabled() ? m_pinchZoomViewport.applyScroll(move) : move;
+ m_rootScrollLayerImpl->scrollBy(roundedIntSize(scrollOverflow));
if (m_rootScrollLayerImpl->scrollbarAnimationController())
m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureUpdate();
@@ -1247,9 +1247,9 @@ void LayerTreeHostImpl::pinchGestureEnd()
void LayerTreeHostImpl::computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo)
{
float pageScale = m_pageScaleAnimation->finalPageScale();
- gfx::Vector2dF scrollOffset = m_pageScaleAnimation->finalScrollOffset();
- scrollOffset.Scale(m_pinchZoomViewport.pageScaleFactor() / pageScale);
- makeScrollAndScaleSet(scrollInfo, gfx::ToRoundedVector2d(scrollOffset), pageScale);
+ IntSize scrollOffset = m_pageScaleAnimation->finalScrollOffset();
+ scrollOffset.scale(m_pinchZoomViewport.pageScaleFactor() / pageScale);
+ makeScrollAndScaleSet(scrollInfo, scrollOffset, pageScale);
}
void LayerTreeHostImpl::computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo)
@@ -1266,32 +1266,31 @@ void LayerTreeHostImpl::computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo)
// Compute where the scroll offset/page scale would be if fully pinch-zoomed
// out from the anchor point.
- gfx::Vector2dF scrollBegin = m_rootScrollLayerImpl->scrollOffset() + m_rootScrollLayerImpl->scrollDelta();
- scrollBegin.Scale(m_pinchZoomViewport.pageScaleDelta());
+ IntSize scrollBegin = flooredIntSize(m_rootScrollLayerImpl->scrollPosition() + m_rootScrollLayerImpl->scrollDelta());
+ 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::Vector2d anchorOffset = m_previousPinchAnchor.OffsetFromOrigin();
- gfx::Vector2dF scrollEnd = scrollBegin + anchorOffset;
- scrollEnd.Scale(m_pinchZoomViewport.minPageScaleFactor() / scaleBegin);
- scrollEnd -= anchorOffset;
- scrollEnd = ClampFromAbove(scrollEnd, BottomRight(gfx::RectF(scaledContentsSize)) - BottomRight(gfx::Rect(m_deviceViewportSize)));
- scrollEnd = ClampFromBelow(scrollEnd, gfx::Vector2d());
- scrollEnd.Scale(1 / pageScaleDeltaToSend);
- scrollEnd.Scale(m_deviceScaleFactor);
+ FloatSize anchor = toSize(m_previousPinchAnchor);
+ FloatSize scrollEnd = scrollBegin + anchor;
+ scrollEnd.scale(m_pinchZoomViewport.minPageScaleFactor() / scaleBegin);
+ scrollEnd -= anchor;
+ scrollEnd = scrollEnd.shrunkTo(roundedIntSize(cc::FloatSize(scaledContentsSize) - cc::IntSize(m_deviceViewportSize))).expandedTo(FloatSize(0, 0));
+ scrollEnd.scale(1 / pageScaleDeltaToSend);
+ scrollEnd.scale(m_deviceScaleFactor);
- makeScrollAndScaleSet(scrollInfo, gfx::ToRoundedVector2d(scrollEnd), m_pinchZoomViewport.minPageScaleFactor());
+ makeScrollAndScaleSet(scrollInfo, roundedIntSize(scrollEnd), m_pinchZoomViewport.minPageScaleFactor());
}
-void LayerTreeHostImpl::makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx::Vector2d scrollOffset, float pageScale)
+void LayerTreeHostImpl::makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, const IntSize& scrollOffset, float pageScale)
{
if (!m_rootScrollLayerImpl)
return;
LayerTreeHostCommon::ScrollUpdateInfo scroll;
scroll.layerId = m_rootScrollLayerImpl->id();
- scroll.scrollDelta = scrollOffset - m_rootScrollLayerImpl->scrollOffset();
+ scroll.scrollDelta = scrollOffset - toSize(m_rootScrollLayerImpl->scrollPosition());
scrollInfo->scrolls.push_back(scroll);
m_rootScrollLayerImpl->setSentScrollDelta(scroll.scrollDelta);
scrollInfo->pageScaleDelta = pageScale / m_pinchZoomViewport.pageScaleFactor();
@@ -1303,8 +1302,8 @@ static void collectScrollDeltas(ScrollAndScaleSet* scrollInfo, LayerImpl* layerI
if (!layerImpl)
return;
- if (!layerImpl->scrollDelta().IsZero()) {
- gfx::Vector2d scrollDelta = gfx::ToFlooredVector2d(layerImpl->scrollDelta());
+ if (!layerImpl->scrollDelta().isZero()) {
+ IntSize scrollDelta = flooredIntSize(layerImpl->scrollDelta());
LayerTreeHostCommon::ScrollUpdateInfo scroll;
scroll.layerId = layerImpl->id();
scroll.scrollDelta = scrollDelta;
@@ -1361,11 +1360,11 @@ void LayerTreeHostImpl::animatePageScale(base::TimeTicks time)
return;
double monotonicTime = (time - base::TimeTicks()).InSecondsF();
- gfx::Vector2dF scrollTotal = m_rootScrollLayerImpl->scrollOffset() + m_rootScrollLayerImpl->scrollDelta();
+ IntSize scrollTotal = flooredIntSize(m_rootScrollLayerImpl->scrollPosition() + m_rootScrollLayerImpl->scrollDelta());
setPageScaleDelta(m_pageScaleAnimation->pageScaleAtTime(monotonicTime) / m_pinchZoomViewport.pageScaleFactor());
- gfx::Vector2dF nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monotonicTime);
- nextScroll.Scale(1 / m_pinchZoomViewport.pageScaleDelta());
+ IntSize nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monotonicTime);
+ nextScroll.scale(1 / m_pinchZoomViewport.pageScaleDelta());
m_rootScrollLayerImpl->scrollBy(nextScroll - scrollTotal);
m_client->setNeedsRedrawOnImplThread();
diff --git a/cc/layer_tree_host_impl.h b/cc/layer_tree_host_impl.h
index 9af0553..bfbef47 100644
--- a/cc/layer_tree_host_impl.h
+++ b/cc/layer_tree_host_impl.h
@@ -5,6 +5,7 @@
#ifndef CC_LAYER_TREE_HOST_IMPL_H_
#define CC_LAYER_TREE_HOST_IMPL_H_
+#include "FloatPoint.h"
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/time.h"
@@ -77,14 +78,14 @@ public:
// Returns the bounds and offset of the scaled and translated viewport to use for pinch-zoom.
gfx::RectF bounds() const;
- const gfx::Vector2dF& scrollDelta() const { return m_pinchViewportScrollDelta; }
+ const FloatPoint& scrollDelta() const { return m_pinchViewportScrollDelta; }
void setLayoutViewportSize(const gfx::SizeF& size) { m_layoutViewportSize = size; }
// Apply the scroll offset in layout space to the offset of the pinch-zoom viewport. The viewport cannot be
// scrolled outside of the layout viewport bounds. Returns the component of the scroll that is un-applied due to
// this constraint.
- gfx::Vector2dF applyScroll(const gfx::Vector2dF&);
+ FloatSize applyScroll(const gfx::Vector2dF&);
WebKit::WebTransformationMatrix implTransform() const;
@@ -95,7 +96,7 @@ private:
float m_maxPageScaleFactor;
float m_minPageScaleFactor;
- gfx::Vector2dF m_pinchViewportScrollDelta;
+ FloatPoint m_pinchViewportScrollDelta;
gfx::SizeF m_layoutViewportSize;
};
@@ -110,13 +111,13 @@ public:
virtual ~LayerTreeHostImpl();
// InputHandlerClient implementation
- virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandlerClient::ScrollInputType) OVERRIDE;
- virtual void scrollBy(gfx::Point, gfx::Vector2d) OVERRIDE;
+ virtual InputHandlerClient::ScrollStatus scrollBegin(const gfx::Point&, InputHandlerClient::ScrollInputType) OVERRIDE;
+ virtual void scrollBy(const gfx::Point&, const IntSize&) OVERRIDE;
virtual void scrollEnd() OVERRIDE;
virtual void pinchGestureBegin() OVERRIDE;
- virtual void pinchGestureUpdate(float, gfx::Point) OVERRIDE;
+ virtual void pinchGestureUpdate(float, const IntPoint&) OVERRIDE;
virtual void pinchGestureEnd() OVERRIDE;
- virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta duration) OVERRIDE;
+ virtual void startPageScaleAnimation(const IntSize& targetPosition, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta duration) OVERRIDE;
virtual void scheduleAnimation() OVERRIDE;
struct CC_EXPORT FrameData : public RenderPassSink {
@@ -212,7 +213,7 @@ public:
scoped_ptr<ScrollAndScaleSet> processScrollDeltas();
WebKit::WebTransformationMatrix implTransform() const;
- void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration);
+ void startPageScaleAnimation(const IntSize& tragetPosition, bool useAnchor, float scale, base::TimeDelta duration);
SkColor backgroundColor() const { return m_backgroundColor; }
void setBackgroundColor(SkColor color) { m_backgroundColor = color; }
@@ -284,10 +285,10 @@ protected:
private:
void computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo);
void computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo);
- void makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx::Vector2d scrollOffset, float pageScale);
+ void makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, const IntSize& scrollOffset, float pageScale);
void setPageScaleDelta(float);
- void updateMaxScrollOffset();
+ void updateMaxScrollPosition();
void trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, const LayerList& renderSurfaceLayerList);
// Returns false if the frame should not be displayed. This function should
@@ -330,7 +331,7 @@ private:
// If this is true, it is necessary to traverse the layer tree ticking the animators.
bool m_needsAnimateLayers;
bool m_pinchGestureActive;
- gfx::Point m_previousPinchAnchor;
+ IntPoint m_previousPinchAnchor;
scoped_ptr<PageScaleAnimation> m_pageScaleAnimation;
diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc
index 6613dbf..f6c2bff 100644
--- a/cc/layer_tree_host_impl_unittest.cc
+++ b/cc/layer_tree_host_impl_unittest.cc
@@ -10,7 +10,6 @@
#include "base/command_line.h"
#include "base/hash_tables.h"
#include "cc/delegated_renderer_layer_impl.h"
-#include "cc/geometry.h"
#include "cc/gl_renderer.h"
#include "cc/heads_up_display_layer_impl.h"
#include "cc/io_surface_layer_impl.h"
@@ -41,7 +40,6 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/size_conversions.h"
-#include "ui/gfx/vector2d_conversions.h"
#include <public/WebVideoFrame.h>
#include <public/WebVideoFrameProvider.h>
@@ -124,19 +122,20 @@ public:
static void expectClearedScrollDeltasRecursive(LayerImpl* layer)
{
- ASSERT_EQ(layer->scrollDelta(), gfx::Vector2d());
+ ASSERT_EQ(layer->scrollDelta(), IntSize());
for (size_t i = 0; i < layer->children().size(); ++i)
expectClearedScrollDeltasRecursive(layer->children()[i]);
}
- static void expectContains(const ScrollAndScaleSet& scrollInfo, int id, const gfx::Vector2d& scrollDelta)
+ static void expectContains(const ScrollAndScaleSet& scrollInfo, int id, const IntSize& scrollDelta)
{
int timesEncountered = 0;
for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) {
if (scrollInfo.scrolls[i].layerId != id)
continue;
- EXPECT_VECTOR_EQ(scrollDelta, scrollInfo.scrolls[i].scrollDelta);
+ EXPECT_EQ(scrollDelta.width(), scrollInfo.scrolls[i].scrollDelta.width());
+ EXPECT_EQ(scrollDelta.height(), scrollInfo.scrolls[i].scrollDelta.height());
timesEncountered++;
}
@@ -147,8 +146,8 @@ public:
{
scoped_ptr<LayerImpl> root = LayerImpl::create(1);
root->setScrollable(true);
- root->setScrollOffset(gfx::Vector2d(0, 0));
- root->setMaxScrollOffset(gfx::Vector2d(contentSize.width(), contentSize.height()));
+ root->setScrollPosition(IntPoint(0, 0));
+ root->setMaxScrollPosition(cc::IntSize(contentSize));
root->setBounds(contentSize);
root->setContentBounds(contentSize);
root->setPosition(gfx::PointF(0, 0));
@@ -171,7 +170,7 @@ public:
layer->setDrawsContent(true);
layer->setBounds(size);
layer->setContentBounds(size);
- layer->setMaxScrollOffset(gfx::Vector2d(size.width() * 2, size.height() * 2));
+ layer->setMaxScrollPosition(IntSize(size.width() * 2, size.height() * 2));
return layer.Pass();
}
@@ -300,13 +299,13 @@ TEST_P(LayerTreeHostImplTest, scrollDeltaTreeButNoChanges)
TEST_P(LayerTreeHostImplTest, scrollDeltaRepeatedScrolls)
{
- gfx::Vector2d scrollOffset(20, 30);
- gfx::Vector2d scrollDelta(11, -15);
+ IntPoint scrollPosition(20, 30);
+ IntSize scrollDelta(11, -15);
{
scoped_ptr<LayerImpl> root = LayerImpl::create(1);
- root->setScrollOffset(scrollOffset);
+ root->setScrollPosition(scrollPosition);
root->setScrollable(true);
- root->setMaxScrollOffset(gfx::Vector2d(100, 100));
+ root->setMaxScrollPosition(IntSize(100, 100));
root->scrollBy(scrollDelta);
m_hostImpl->setRootLayer(root.Pass());
}
@@ -316,17 +315,17 @@ TEST_P(LayerTreeHostImplTest, scrollDeltaRepeatedScrolls)
scrollInfo = m_hostImpl->processScrollDeltas();
ASSERT_EQ(scrollInfo->scrolls.size(), 1u);
- EXPECT_VECTOR_EQ(root->sentScrollDelta(), scrollDelta);
+ EXPECT_EQ(root->sentScrollDelta(), scrollDelta);
expectContains(*scrollInfo, root->id(), scrollDelta);
- gfx::Vector2d scrollDelta2(-5, 27);
+ IntSize scrollDelta2(-5, 27);
root->scrollBy(scrollDelta2);
scrollInfo = m_hostImpl->processScrollDeltas();
ASSERT_EQ(scrollInfo->scrolls.size(), 1u);
- EXPECT_VECTOR_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2);
+ EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2);
expectContains(*scrollInfo, root->id(), scrollDelta + scrollDelta2);
- root->scrollBy(gfx::Vector2d());
+ root->scrollBy(IntSize());
scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2);
}
@@ -338,7 +337,7 @@ TEST_P(LayerTreeHostImplTest, scrollRootCallsCommitAndRedraw)
initializeRendererAndDrawFrame();
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
- m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10));
+ m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10));
m_hostImpl->scrollEnd();
EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit);
@@ -380,7 +379,7 @@ TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling)
setupScrollAndContentsLayers(gfx::Size(100, 100));
// We should still be scrolling, because the scrolled layer also exists in the new tree.
- gfx::Vector2d scrollDelta(0, 10);
+ IntSize scrollDelta(0, 10);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd();
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
@@ -443,10 +442,10 @@ TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionBasic)
// All scroll types outside this region should succeed.
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
- m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10));
+ m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10));
m_hostImpl->scrollEnd();
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Gesture), InputHandlerClient::ScrollStarted);
- m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10));
+ m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10));
m_hostImpl->scrollEnd();
}
@@ -462,14 +461,14 @@ TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionWithOffset)
// This point would fall into the non-fast scrollable region except that we've moved the layer down by 25 pixels.
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(40, 10), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
- m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 1));
+ m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 1));
m_hostImpl->scrollEnd();
// This point is still inside the non-fast region.
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wheel), InputHandlerClient::ScrollOnMainThread);
}
-TEST_P(LayerTreeHostImplTest, maxScrollOffsetChangedByDeviceScaleFactor)
+TEST_P(LayerTreeHostImplTest, maxScrollPositionChangedByDeviceScaleFactor)
{
setupScrollAndContentsLayers(gfx::Size(100, 100));
@@ -478,12 +477,12 @@ TEST_P(LayerTreeHostImplTest, maxScrollOffsetChangedByDeviceScaleFactor)
gfx::Size deviceViewport(gfx::ToFlooredSize(layoutViewport.Scale(deviceScaleFactor)));
m_hostImpl->setViewportSize(layoutViewport, deviceViewport);
m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
- EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), gfx::Vector2d(25, 25));
+ EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(25, 25));
deviceScaleFactor = 1;
m_hostImpl->setViewportSize(layoutViewport, layoutViewport);
m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
- EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), gfx::Vector2d(75, 75));
+ EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(75, 75));
}
TEST_P(LayerTreeHostImplTest, implPinchZoom)
@@ -506,11 +505,11 @@ TEST_P(LayerTreeHostImplTest, implPinchZoom)
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform);
- scrollLayer->setScrollDelta(gfx::Vector2d());
+ scrollLayer->setScrollDelta(IntSize());
float pageScaleDelta = 2;
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50));
+ m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50));
m_hostImpl->pinchGestureEnd();
EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit);
@@ -518,7 +517,7 @@ TEST_P(LayerTreeHostImplTest, implPinchZoom)
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
- EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), gfx::Vector2d(50, 50));
+ EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(50, 50));
}
// Scrolling after a pinch gesture should always be in local space. The scroll deltas do not
@@ -526,14 +525,14 @@ TEST_P(LayerTreeHostImplTest, implPinchZoom)
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform);
- scrollLayer->setScrollDelta(gfx::Vector2d());
+ scrollLayer->setScrollDelta(IntSize());
float pageScaleDelta = 2;
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0));
+ m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0));
m_hostImpl->pinchGestureEnd();
- gfx::Vector2d scrollDelta(0, 10);
+ IntSize scrollDelta(0, 10);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd();
@@ -560,11 +559,11 @@ TEST_P(LayerTreeHostImplTest, pinchGesture)
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform);
- scrollLayer->setScrollDelta(gfx::Vector2d());
+ scrollLayer->setScrollDelta(IntSize());
float pageScaleDelta = 2;
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50));
+ m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50));
m_hostImpl->pinchGestureEnd();
EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit);
@@ -577,11 +576,11 @@ TEST_P(LayerTreeHostImplTest, pinchGesture)
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform);
- scrollLayer->setScrollDelta(gfx::Vector2d());
+ scrollLayer->setScrollDelta(IntSize());
float pageScaleDelta = 10;
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50));
+ m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50));
m_hostImpl->pinchGestureEnd();
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
@@ -592,12 +591,12 @@ TEST_P(LayerTreeHostImplTest, pinchGesture)
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform);
- scrollLayer->setScrollDelta(gfx::Vector2d());
- scrollLayer->setScrollOffset(gfx::Vector2d(50, 50));
+ scrollLayer->setScrollDelta(IntSize());
+ scrollLayer->setScrollPosition(IntPoint(50, 50));
float pageScaleDelta = 0.1f;
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0));
+ m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0));
m_hostImpl->pinchGestureEnd();
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
@@ -605,7 +604,7 @@ TEST_P(LayerTreeHostImplTest, pinchGesture)
if (!Settings::pageScalePinchZoomEnabled()) {
// Pushed to (0,0) via clamping against contents layer size.
- expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50));
+ expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50));
} else {
EXPECT_TRUE(scrollInfo->scrolls.empty());
}
@@ -615,18 +614,18 @@ TEST_P(LayerTreeHostImplTest, pinchGesture)
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform);
- scrollLayer->setScrollDelta(gfx::Vector2d());
- scrollLayer->setScrollOffset(gfx::Vector2d(20, 20));
+ scrollLayer->setScrollDelta(IntSize());
+ scrollLayer->setScrollPosition(IntPoint(20, 20));
float pageScaleDelta = 1;
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10));
- m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20));
+ m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(10, 10));
+ m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(20, 20));
m_hostImpl->pinchGestureEnd();
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
- expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-10, -10));
+ expectContains(*scrollInfo, scrollLayer->id(), IntSize(-10, -10));
}
}
@@ -651,9 +650,9 @@ TEST_P(LayerTreeHostImplTest, pageScaleAnimation)
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform);
- scrollLayer->setScrollOffset(gfx::Vector2d(50, 50));
+ scrollLayer->setScrollPosition(IntPoint(50, 50));
- m_hostImpl->startPageScaleAnimation(gfx::Vector2d(0, 0), false, 2, startTime, duration);
+ m_hostImpl->startPageScaleAnimation(IntSize(0, 0), false, 2, startTime, duration);
m_hostImpl->animate(halfwayThroughAnimation, base::Time());
EXPECT_TRUE(m_didRequestRedraw);
m_hostImpl->animate(endTime, base::Time());
@@ -661,16 +660,16 @@ TEST_P(LayerTreeHostImplTest, pageScaleAnimation)
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, 2);
- expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50));
+ expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50));
}
// Anchor zoom-out
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform);
- scrollLayer->setScrollOffset(gfx::Vector2d(50, 50));
+ scrollLayer->setScrollPosition(IntPoint(50, 50));
- m_hostImpl->startPageScaleAnimation(gfx::Vector2d(25, 25), true, minPageScale, startTime, duration);
+ m_hostImpl->startPageScaleAnimation(IntSize(25, 25), true, minPageScale, startTime, duration);
m_hostImpl->animate(endTime, base::Time());
EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit);
@@ -678,7 +677,7 @@ TEST_P(LayerTreeHostImplTest, pageScaleAnimation)
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
// Pushed to (0,0) via clamping against contents layer size.
- expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50));
+ expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50));
}
}
@@ -700,7 +699,7 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming)
const float zoomInDelta = 2;
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(zoomInDelta, gfx::Point(50, 50));
+ m_hostImpl->pinchGestureUpdate(zoomInDelta, IntPoint(50, 50));
// Because we are pinch zooming in, we shouldn't get any scroll or page
// scale deltas.
@@ -713,7 +712,7 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming)
scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, zoomInDelta);
if (!Settings::pageScalePinchZoomEnabled()) {
- expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25));
+ expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
} else {
EXPECT_TRUE(scrollInfo->scrolls.empty());
}
@@ -725,14 +724,14 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming)
const float zoomOutDelta = 0.75;
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(zoomOutDelta, gfx::Point(50, 50));
+ m_hostImpl->pinchGestureUpdate(zoomOutDelta, IntPoint(50, 50));
// Since we are pinch zooming out, we should get an update to zoom all
// the way out to the minimum page scale.
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
if (!Settings::pageScalePinchZoomEnabled()) {
EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
- expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(0, 0));
+ expectContains(*scrollInfo, scrollLayer->id(), IntSize(0, 0));
} else {
EXPECT_EQ(scrollInfo->pageScaleDelta, 1);
EXPECT_TRUE(scrollInfo->scrolls.empty());
@@ -743,10 +742,10 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming)
scrollInfo = m_hostImpl->processScrollDeltas();
if (Settings::pageScalePinchZoomEnabled()) {
EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
- expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25));
+ expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
} else {
EXPECT_EQ(scrollInfo->pageScaleDelta, zoomOutDelta);
- expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(8, 8));
+ expectContains(*scrollInfo, scrollLayer->id(), IntSize(8, 8));
}
}
}
@@ -769,7 +768,7 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPage
// Start a page scale animation.
const float pageScaleDelta = 2;
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- m_hostImpl->startPageScaleAnimation(gfx::Vector2d(50, 50), false, pageScaleDelta, startTime, duration);
+ m_hostImpl->startPageScaleAnimation(IntSize(50, 50), false, pageScaleDelta, startTime, duration);
// We should immediately get the final zoom and scroll values for the
// animation.
@@ -778,14 +777,14 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPage
if (!Settings::pageScalePinchZoomEnabled()) {
EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
- expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25));
+ expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
} else {
EXPECT_EQ(scrollInfo->pageScaleDelta, 1);
EXPECT_TRUE(scrollInfo->scrolls.empty());
}
// Scrolling during the animation is ignored.
- const gfx::Vector2d scrollDelta(0, 10);
+ const IntSize scrollDelta(0, 10);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd();
@@ -795,7 +794,7 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPage
m_hostImpl->animate(endTime, base::Time());
scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
- expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25));
+ expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
}
class DidDrawCheckLayer : public TiledLayerImpl {
@@ -1050,7 +1049,7 @@ TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot)
scoped_ptr<LayerImpl> scrollLayer = LayerImpl::create(2);
scrollLayer->setScrollable(true);
- scrollLayer->setMaxScrollOffset(gfx::Vector2d(surfaceSize.width(), surfaceSize.height()));
+ scrollLayer->setMaxScrollPosition(cc::IntSize(surfaceSize));
scrollLayer->setBounds(surfaceSize);
scrollLayer->setContentBounds(surfaceSize);
scrollLayer->setPosition(gfx::PointF(0, 0));
@@ -1062,7 +1061,7 @@ TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot)
initializeRendererAndDrawFrame();
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
- m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10));
+ m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10));
m_hostImpl->scrollEnd();
EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit);
@@ -1080,7 +1079,7 @@ TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw)
initializeRendererAndDrawFrame();
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
- m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10));
+ m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10));
m_hostImpl->scrollEnd();
EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit);
@@ -1151,9 +1150,9 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread)
m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
initializeRendererAndDrawFrame();
- gfx::Vector2d scrollDelta(0, 10);
- gfx::Vector2d expectedScrollDelta(scrollDelta);
- gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
+ IntSize scrollDelta(0, 10);
+ IntSize expectedScrollDelta(scrollDelta);
+ IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition());
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd();
@@ -1163,13 +1162,13 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread)
if (!Settings::pageScalePinchZoomEnabled()) {
// The scale should apply to the scroll delta.
- expectedScrollDelta = gfx::ToFlooredVector2d(cc::ScaleVector2d(expectedScrollDelta, pageScale));
+ expectedScrollDelta.scale(pageScale);
}
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScrollDelta);
// The scroll range should also have been updated.
- EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
+ EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll);
// The page scale delta remains constant because the impl thread did not scale.
EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix());
@@ -1185,16 +1184,16 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
initializeRendererAndDrawFrame();
- gfx::Vector2d scrollDelta(0, 10);
- gfx::Vector2d expectedScrollDelta(scrollDelta);
- gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
+ IntSize scrollDelta(0, 10);
+ IntSize expectedScrollDelta(scrollDelta);
+ IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition());
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd();
// Set new page scale on impl thread by pinching.
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
+ m_hostImpl->pinchGestureUpdate(pageScale, IntPoint());
m_hostImpl->pinchGestureEnd();
m_hostImpl->updateRootScrollLayerImplTransform();
@@ -1203,7 +1202,7 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScrollDelta);
// The scroll range should also have been updated.
- EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
+ EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll);
// The page scale delta should match the new scale on the impl side.
WebTransformationMatrix expectedScale;
@@ -1232,7 +1231,7 @@ TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
// Set new page scale on impl thread by pinching.
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point());
+ m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint());
m_hostImpl->pinchGestureEnd();
m_hostImpl->updateRootScrollLayerImplTransform();
@@ -1272,9 +1271,9 @@ TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
LayerImpl* child = m_hostImpl->rootLayer()->children()[0];
- gfx::Vector2d scrollDelta(0, 10);
- gfx::Vector2d expectedScrollDelta(scrollDelta);
- gfx::Vector2d expectedMaxScroll(child->maxScrollOffset());
+ IntSize scrollDelta(0, 10);
+ IntSize expectedScrollDelta(scrollDelta);
+ IntSize expectedMaxScroll(child->maxScrollPosition());
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd();
@@ -1286,13 +1285,13 @@ TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
if (!Settings::pageScalePinchZoomEnabled()) {
// The scale should apply to the scroll delta.
- expectedScrollDelta = gfx::ToFlooredVector2d(cc::ScaleVector2d(expectedScrollDelta, pageScale));
+ expectedScrollDelta.scale(pageScale);
}
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta);
// The scroll range should not have changed.
- EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll);
+ EXPECT_EQ(child->maxScrollPosition(), expectedMaxScroll);
// The page scale delta remains constant because the impl thread did not scale.
WebTransformationMatrix identityTransform;
@@ -1308,10 +1307,10 @@ TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit)
scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize);
- grandChild->setScrollOffset(gfx::Vector2d(0, 5));
+ grandChild->setScrollPosition(IntPoint(0, 5));
scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize);
- child->setScrollOffset(gfx::Vector2d(3, 0));
+ child->setScrollPosition(IntPoint(3, 0));
child->addChild(grandChild.Pass());
root->addChild(child.Pass());
@@ -1319,7 +1318,7 @@ TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit)
m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
initializeRendererAndDrawFrame();
{
- gfx::Vector2d scrollDelta(-8, -7);
+ IntSize scrollDelta(-8, -7);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd();
@@ -1329,10 +1328,10 @@ TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit)
// The grand child should have scrolled up to its limit.
LayerImpl* child = m_hostImpl->rootLayer()->children()[0];
LayerImpl* grandChild = child->children()[0];
- expectContains(*scrollInfo.get(), grandChild->id(), gfx::Vector2d(0, -5));
+ expectContains(*scrollInfo.get(), grandChild->id(), IntSize(0, -5));
// The child should have only scrolled on the other axis.
- expectContains(*scrollInfo.get(), child->id(), gfx::Vector2d(-3, 0));
+ expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0));
}
}
@@ -1351,7 +1350,7 @@ TEST_P(LayerTreeHostImplTest, scrollEventBubbling)
m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
initializeRendererAndDrawFrame();
{
- gfx::Vector2d scrollDelta(0, 4);
+ IntSize scrollDelta(0, 4);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd();
@@ -1393,18 +1392,18 @@ TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer)
initializeRendererAndDrawFrame();
// Scroll to the right in screen coordinates with a gesture.
- gfx::Vector2d gestureScrollDelta(10, 0);
+ IntSize gestureScrollDelta(10, 0);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta);
m_hostImpl->scrollEnd();
// The layer should have scrolled down in its local coordinates.
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
- expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector2d(0, gestureScrollDelta.x()));
+ expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), IntSize(0, gestureScrollDelta.width()));
// Reset and scroll down with the wheel.
- m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF());
- gfx::Vector2d wheelScrollDelta(0, 10);
+ m_hostImpl->rootLayer()->setScrollDelta(FloatSize());
+ IntSize wheelScrollDelta(0, 10);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta);
m_hostImpl->scrollEnd();
@@ -1429,7 +1428,7 @@ TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
child->setTransform(rotateTransform);
// Only allow vertical scrolling.
- child->setMaxScrollOffset(gfx::Vector2d(0, child->contentBounds().height()));
+ child->setMaxScrollPosition(IntSize(0, child->contentBounds().height()));
m_hostImpl->rootLayer()->addChild(child.Pass());
gfx::Size surfaceSize(50, 50);
@@ -1438,14 +1437,14 @@ TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
{
// Scroll down in screen coordinates with a gesture.
- gfx::Vector2d gestureScrollDelta(0, 10);
+ IntSize gestureScrollDelta(0, 10);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta);
m_hostImpl->scrollEnd();
// The child layer should have scrolled down in its local coordinates an amount proportional to
// the angle between it and the input scroll delta.
- gfx::Vector2d expectedScrollDelta(0, gestureScrollDelta.y() * cosf(deg2rad(childLayerAngle)));
+ IntSize expectedScrollDelta(0, gestureScrollDelta.height() * cosf(deg2rad(childLayerAngle)));
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta);
@@ -1456,21 +1455,21 @@ TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
{
// Now reset and scroll the same amount horizontally.
- m_hostImpl->rootLayer()->children()[1]->setScrollDelta(gfx::Vector2dF());
- gfx::Vector2d gestureScrollDelta(10, 0);
+ m_hostImpl->rootLayer()->children()[1]->setScrollDelta(FloatSize());
+ IntSize gestureScrollDelta(10, 0);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta);
m_hostImpl->scrollEnd();
// The child layer should have scrolled down in its local coordinates an amount proportional to
// the angle between it and the input scroll delta.
- gfx::Vector2d expectedScrollDelta(0, -gestureScrollDelta.x() * sinf(deg2rad(childLayerAngle)));
+ IntSize expectedScrollDelta(0, -gestureScrollDelta.width() * sinf(deg2rad(childLayerAngle)));
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta);
// The root layer should have scrolled more, since the input scroll delta was mostly
// orthogonal to the child layer's vertical scroll axis.
- gfx::Vector2d expectedRootScrollDelta(gestureScrollDelta.x() * pow(cosf(deg2rad(childLayerAngle)), 2), 0);
+ IntSize expectedRootScrollDelta(gestureScrollDelta.width() * pow(cosf(deg2rad(childLayerAngle)), 2), 0);
expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedRootScrollDelta);
}
}
@@ -1490,18 +1489,18 @@ TEST_P(LayerTreeHostImplTest, scrollScaledLayer)
initializeRendererAndDrawFrame();
// Scroll down in screen coordinates with a gesture.
- gfx::Vector2d scrollDelta(0, 10);
+ IntSize scrollDelta(0, 10);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd();
// The layer should have scrolled down in its local coordinates, but half he amount.
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
- expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector2d(0, scrollDelta.y() / scale));
+ expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), IntSize(0, scrollDelta.height() / scale));
// Reset and scroll down with the wheel.
- m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF());
- gfx::Vector2d wheelScrollDelta(0, 10);
+ m_hostImpl->rootLayer()->setScrollDelta(FloatSize());
+ IntSize wheelScrollDelta(0, 10);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta);
m_hostImpl->scrollEnd();
diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc
index 893ebee..704158e 100644
--- a/cc/layer_tree_host_unittest.cc
+++ b/cc/layer_tree_host_unittest.cc
@@ -24,7 +24,6 @@
#include "third_party/khronos/GLES2/gl2ext.h"
#include "ui/gfx/point_conversions.h"
#include "ui/gfx/size_conversions.h"
-#include "ui/gfx/vector2d_conversions.h"
#include <public/WebLayerScrollClient.h>
#include <public/WebSize.h>
@@ -835,8 +834,8 @@ SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAnimationFinishedEvents)
class LayerTreeHostTestScrollSimple : public LayerTreeHostTest {
public:
LayerTreeHostTestScrollSimple()
- : m_initialScroll(10, 20)
- , m_secondScroll(40, 5)
+ : m_initialScroll(IntPoint(10, 20))
+ , m_secondScroll(IntPoint(40, 5))
, m_scrollAmount(2, -1)
, m_scrolls(0)
{
@@ -845,7 +844,7 @@ public:
virtual void beginTest() OVERRIDE
{
m_layerTreeHost->rootLayer()->setScrollable(true);
- m_layerTreeHost->rootLayer()->setScrollOffset(m_initialScroll);
+ m_layerTreeHost->rootLayer()->setScrollPosition(m_initialScroll);
postSetNeedsCommitToMainThread();
}
@@ -853,39 +852,39 @@ public:
{
Layer* root = m_layerTreeHost->rootLayer();
if (!m_layerTreeHost->commitNumber())
- EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll);
+ EXPECT_EQ(root->scrollPosition(), m_initialScroll);
else {
- EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll + m_scrollAmount);
+ EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount);
// Pretend like Javascript updated the scroll position itself.
- root->setScrollOffset(m_secondScroll);
+ root->setScrollPosition(m_secondScroll);
}
}
virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
{
LayerImpl* root = impl->rootLayer();
- EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d());
+ EXPECT_EQ(root->scrollDelta(), IntSize());
root->setScrollable(true);
- root->setMaxScrollOffset(gfx::Vector2d(100, 100));
+ root->setMaxScrollPosition(IntSize(100, 100));
root->scrollBy(m_scrollAmount);
if (!impl->sourceFrameNumber()) {
- EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll);
- EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount);
+ EXPECT_EQ(root->scrollPosition(), m_initialScroll);
+ EXPECT_EQ(root->scrollDelta(), m_scrollAmount);
postSetNeedsCommitToMainThread();
} else if (impl->sourceFrameNumber() == 1) {
- EXPECT_VECTOR_EQ(root->scrollOffset(), m_secondScroll);
- EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount);
+ EXPECT_EQ(root->scrollPosition(), m_secondScroll);
+ EXPECT_EQ(root->scrollDelta(), m_scrollAmount);
endTest();
}
}
- virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
+ virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE
{
- gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset();
- m_layerTreeHost->rootLayer()->setScrollOffset(offset + scrollDelta);
+ IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition();
+ m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta);
m_scrolls++;
}
@@ -894,9 +893,9 @@ public:
EXPECT_EQ(1, m_scrolls);
}
private:
- gfx::Vector2d m_initialScroll;
- gfx::Vector2d m_secondScroll;
- gfx::Vector2d m_scrollAmount;
+ IntPoint m_initialScroll;
+ IntPoint m_secondScroll;
+ IntSize m_scrollAmount;
int m_scrolls;
};
@@ -908,7 +907,7 @@ TEST_F(LayerTreeHostTestScrollSimple, runMultiThread)
class LayerTreeHostTestScrollMultipleRedraw : public LayerTreeHostTest {
public:
LayerTreeHostTestScrollMultipleRedraw()
- : m_initialScroll(40, 10)
+ : m_initialScroll(IntPoint(40, 10))
, m_scrollAmount(-3, 17)
, m_scrolls(0)
{
@@ -917,7 +916,7 @@ public:
virtual void beginTest() OVERRIDE
{
m_layerTreeHost->rootLayer()->setScrollable(true);
- m_layerTreeHost->rootLayer()->setScrollOffset(m_initialScroll);
+ m_layerTreeHost->rootLayer()->setScrollPosition(m_initialScroll);
postSetNeedsCommitToMainThread();
}
@@ -925,48 +924,48 @@ public:
{
Layer* root = m_layerTreeHost->rootLayer();
if (!m_layerTreeHost->commitNumber())
- EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll);
+ EXPECT_EQ(root->scrollPosition(), m_initialScroll);
else if (m_layerTreeHost->commitNumber() == 1)
- EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll + m_scrollAmount + m_scrollAmount);
+ EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount + m_scrollAmount);
else if (m_layerTreeHost->commitNumber() == 2)
- EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll + m_scrollAmount + m_scrollAmount);
+ EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount + m_scrollAmount);
}
virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
{
LayerImpl* root = impl->rootLayer();
root->setScrollable(true);
- root->setMaxScrollOffset(gfx::Vector2d(100, 100));
+ root->setMaxScrollPosition(IntSize(100, 100));
if (!impl->sourceFrameNumber() && impl->sourceAnimationFrameNumber() == 1) {
// First draw after first commit.
- EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d());
+ EXPECT_EQ(root->scrollDelta(), IntSize());
root->scrollBy(m_scrollAmount);
- EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount);
+ EXPECT_EQ(root->scrollDelta(), m_scrollAmount);
- EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll);
+ EXPECT_EQ(root->scrollPosition(), m_initialScroll);
postSetNeedsRedrawToMainThread();
} else if (!impl->sourceFrameNumber() && impl->sourceAnimationFrameNumber() == 2) {
// Second draw after first commit.
EXPECT_EQ(root->scrollDelta(), m_scrollAmount);
root->scrollBy(m_scrollAmount);
- EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount + m_scrollAmount);
+ EXPECT_EQ(root->scrollDelta(), m_scrollAmount + m_scrollAmount);
- EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll);
+ EXPECT_EQ(root->scrollPosition(), m_initialScroll);
postSetNeedsCommitToMainThread();
} else if (impl->sourceFrameNumber() == 1) {
// Third or later draw after second commit.
EXPECT_GE(impl->sourceAnimationFrameNumber(), 3);
- EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d());
- EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll + m_scrollAmount + m_scrollAmount);
+ EXPECT_EQ(root->scrollDelta(), IntSize());
+ EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount + m_scrollAmount);
endTest();
}
}
- virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
+ virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE
{
- gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset();
- m_layerTreeHost->rootLayer()->setScrollOffset(offset + scrollDelta);
+ IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition();
+ m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta);
m_scrolls++;
}
@@ -975,8 +974,8 @@ public:
EXPECT_EQ(1, m_scrolls);
}
private:
- gfx::Vector2d m_initialScroll;
- gfx::Vector2d m_scrollAmount;
+ IntPoint m_initialScroll;
+ IntSize m_scrollAmount;
int m_scrolls;
};
@@ -1030,20 +1029,20 @@ public:
virtual void beginTest() OVERRIDE
{
m_layerTreeHost->rootLayer()->setScrollable(true);
- m_layerTreeHost->rootLayer()->setScrollOffset(gfx::Vector2d());
+ m_layerTreeHost->rootLayer()->setScrollPosition(IntPoint());
postSetNeedsCommitToMainThread();
postSetNeedsRedrawToMainThread();
}
void requestStartPageScaleAnimation()
{
- layerTreeHost()->startPageScaleAnimation(gfx::Vector2d(), false, 1.25, base::TimeDelta());
+ layerTreeHost()->startPageScaleAnimation(IntSize(), false, 1.25, base::TimeDelta());
}
virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
{
impl->rootLayer()->setScrollable(true);
- impl->rootLayer()->setScrollOffset(gfx::Vector2d());
+ impl->rootLayer()->setScrollPosition(IntPoint());
impl->setPageScaleFactorAndLimits(impl->pageScaleFactor(), 0.5, 2);
// We request animation only once.
@@ -1053,10 +1052,10 @@ public:
}
}
- virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
+ virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE
{
- gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset();
- m_layerTreeHost->rootLayer()->setScrollOffset(offset + scrollDelta);
+ IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition();
+ m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta);
m_layerTreeHost->setPageScaleFactorAndLimits(scale, 0.5, 2);
}
@@ -2091,36 +2090,36 @@ public:
virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
{
LayerImpl* root = impl->rootLayer();
- root->setMaxScrollOffset(gfx::Vector2d(100, 100));
+ root->setMaxScrollPosition(IntSize(100, 100));
// Check that a fractional scroll delta is correctly accumulated over multiple commits.
if (!impl->sourceFrameNumber()) {
- EXPECT_VECTOR_EQ(root->scrollOffset(), gfx::Vector2d(0, 0));
- EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d(0, 0));
+ EXPECT_EQ(root->scrollPosition(), IntPoint(0, 0));
+ EXPECT_EQ(root->scrollDelta(), FloatSize(0, 0));
postSetNeedsCommitToMainThread();
} else if (impl->sourceFrameNumber() == 1) {
- EXPECT_VECTOR_EQ(root->scrollOffset(), gfx::ToFlooredVector2d(m_scrollAmount));
- EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2dF(fmod(m_scrollAmount.x(), 1), 0));
+ EXPECT_EQ(root->scrollPosition(), flooredIntPoint(m_scrollAmount));
+ EXPECT_EQ(root->scrollDelta(), FloatSize(fmod(m_scrollAmount.width(), 1), 0));
postSetNeedsCommitToMainThread();
} else if (impl->sourceFrameNumber() == 2) {
- EXPECT_VECTOR_EQ(root->scrollOffset(), gfx::ToFlooredVector2d(m_scrollAmount + m_scrollAmount));
- EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2dF(fmod(2 * m_scrollAmount.x(), 1), 0));
+ EXPECT_EQ(root->scrollPosition(), flooredIntPoint(m_scrollAmount + m_scrollAmount));
+ EXPECT_EQ(root->scrollDelta(), FloatSize(fmod(2 * m_scrollAmount.width(), 1), 0));
endTest();
}
root->scrollBy(m_scrollAmount);
}
- virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
+ virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE
{
- gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset();
- m_layerTreeHost->rootLayer()->setScrollOffset(offset + scrollDelta);
+ IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition();
+ m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta);
}
virtual void afterTest() OVERRIDE
{
}
private:
- gfx::Vector2dF m_scrollAmount;
+ FloatSize m_scrollAmount;
};
TEST_F(LayerTreeHostTestFractionalScroll, runMultiThread)
@@ -2224,8 +2223,8 @@ class LayerTreeHostTestScrollChildLayer : public LayerTreeHostTest, public WebLa
public:
LayerTreeHostTestScrollChildLayer(float deviceScaleFactor)
: m_deviceScaleFactor(deviceScaleFactor)
- , m_initialScroll(10, 20)
- , m_secondScroll(40, 5)
+ , m_initialScroll(IntPoint(10, 20))
+ , m_secondScroll(IntPoint(40, 5))
, m_scrollAmount(2, -1)
, m_rootScrolls(0)
{
@@ -2247,7 +2246,7 @@ public:
m_rootScrollLayer->setIsDrawable(true);
m_rootScrollLayer->setScrollable(true);
- m_rootScrollLayer->setMaxScrollOffset(gfx::Vector2d(100, 100));
+ m_rootScrollLayer->setMaxScrollPosition(IntSize(100, 100));
m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer);
m_childLayer = ContentLayer::create(&m_mockDelegate);
@@ -2261,42 +2260,42 @@ public:
m_childLayer->setIsDrawable(true);
m_childLayer->setScrollable(true);
- m_childLayer->setMaxScrollOffset(gfx::Vector2d(100, 100));
+ m_childLayer->setMaxScrollPosition(IntSize(100, 100));
m_rootScrollLayer->addChild(m_childLayer);
- m_childLayer->setScrollOffset(m_initialScroll);
+ m_childLayer->setScrollPosition(m_initialScroll);
postSetNeedsCommitToMainThread();
}
virtual void didScroll() OVERRIDE
{
- m_finalScrollOffset = m_childLayer->scrollOffset();
+ m_finalScrollPosition = m_childLayer->scrollPosition();
}
- virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
+ virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE
{
- gfx::Vector2d offset = m_rootScrollLayer->scrollOffset();
- m_rootScrollLayer->setScrollOffset(offset + scrollDelta);
+ IntPoint position = m_rootScrollLayer->scrollPosition();
+ m_rootScrollLayer->setScrollPosition(position + scrollDelta);
m_rootScrolls++;
}
virtual void layout() OVERRIDE
{
- EXPECT_VECTOR_EQ(gfx::Vector2d(), m_rootScrollLayer->scrollOffset());
+ EXPECT_EQ(IntPoint(), m_rootScrollLayer->scrollPosition());
switch (m_layerTreeHost->commitNumber()) {
case 0:
- EXPECT_VECTOR_EQ(m_initialScroll, m_childLayer->scrollOffset());
+ EXPECT_POINT_EQ(m_initialScroll, m_childLayer->scrollPosition());
break;
case 1:
- EXPECT_VECTOR_EQ(m_initialScroll + m_scrollAmount, m_childLayer->scrollOffset());
+ EXPECT_POINT_EQ(m_initialScroll + m_scrollAmount, m_childLayer->scrollPosition());
// Pretend like Javascript updated the scroll position itself.
- m_childLayer->setScrollOffset(m_secondScroll);
+ m_childLayer->setScrollPosition(m_secondScroll);
break;
case 2:
- EXPECT_VECTOR_EQ(m_secondScroll + m_scrollAmount, m_childLayer->scrollOffset());
+ EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, m_childLayer->scrollPosition());
break;
}
}
@@ -2307,8 +2306,8 @@ public:
LayerImpl* rootScrollLayer = root->children()[0];
LayerImpl* childLayer = rootScrollLayer->children()[0];
- EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d());
- EXPECT_VECTOR_EQ(rootScrollLayer->scrollDelta(), gfx::Vector2d());
+ EXPECT_SIZE_EQ(root->scrollDelta(), IntSize());
+ EXPECT_SIZE_EQ(rootScrollLayer->scrollDelta(), IntSize());
EXPECT_EQ(rootScrollLayer->bounds().width() * m_deviceScaleFactor, rootScrollLayer->contentBounds().width());
EXPECT_EQ(rootScrollLayer->bounds().height() * m_deviceScaleFactor, rootScrollLayer->contentBounds().height());
EXPECT_EQ(childLayer->bounds().width() * m_deviceScaleFactor, childLayer->contentBounds().width());
@@ -2321,8 +2320,8 @@ public:
impl->scrollBy(gfx::Point(), m_scrollAmount);
impl->scrollEnd();
- EXPECT_VECTOR_EQ(m_initialScroll, childLayer->scrollOffset());
- EXPECT_VECTOR_EQ(m_scrollAmount, childLayer->scrollDelta());
+ EXPECT_POINT_EQ(m_initialScroll, childLayer->scrollPosition());
+ EXPECT_SIZE_EQ(m_scrollAmount, childLayer->scrollDelta());
break;
case 1:
// Wheel scroll on impl thread.
@@ -2330,12 +2329,12 @@ public:
impl->scrollBy(gfx::Point(), m_scrollAmount);
impl->scrollEnd();
- EXPECT_VECTOR_EQ(m_secondScroll, childLayer->scrollOffset());
- EXPECT_VECTOR_EQ(m_scrollAmount, childLayer->scrollDelta());
+ EXPECT_POINT_EQ(m_secondScroll, childLayer->scrollPosition());
+ EXPECT_SIZE_EQ(m_scrollAmount, childLayer->scrollDelta());
break;
case 2:
- EXPECT_VECTOR_EQ(m_secondScroll + m_scrollAmount, childLayer->scrollOffset());
- EXPECT_VECTOR_EQ(gfx::Vector2d(0, 0), childLayer->scrollDelta());
+ EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, childLayer->scrollPosition());
+ EXPECT_SIZE_EQ(IntSize(0, 0), childLayer->scrollDelta());
endTest();
}
@@ -2344,16 +2343,16 @@ public:
virtual void afterTest() OVERRIDE
{
EXPECT_EQ(0, m_rootScrolls);
- EXPECT_VECTOR_EQ(m_secondScroll + m_scrollAmount, m_finalScrollOffset);
+ EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, m_finalScrollPosition);
}
private:
float m_deviceScaleFactor;
- gfx::Vector2d m_initialScroll;
- gfx::Vector2d m_secondScroll;
- gfx::Vector2d m_scrollAmount;
+ IntPoint m_initialScroll;
+ IntPoint m_secondScroll;
+ IntSize m_scrollAmount;
int m_rootScrolls;
- gfx::Vector2d m_finalScrollOffset;
+ IntPoint m_finalScrollPosition;
MockContentLayerClient m_mockDelegate;
scoped_refptr<Layer> m_rootScrollLayer;
@@ -2384,8 +2383,8 @@ class LayerTreeHostTestScrollRootScrollLayer : public LayerTreeHostTest {
public:
LayerTreeHostTestScrollRootScrollLayer(float deviceScaleFactor)
: m_deviceScaleFactor(deviceScaleFactor)
- , m_initialScroll(10, 20)
- , m_secondScroll(40, 5)
+ , m_initialScroll(IntPoint(10, 20))
+ , m_secondScroll(IntPoint(40, 5))
, m_scrollAmount(2, -1)
, m_rootScrolls(0)
{
@@ -2400,25 +2399,25 @@ public:
m_layerTreeHost->setDeviceScaleFactor(m_deviceScaleFactor);
m_rootScrollLayer = ContentLayer::create(&m_mockDelegate);
- m_rootScrollLayer->setBounds(gfx::Size(110, 110));
+ m_rootScrollLayer->setBounds(IntSize(110, 110));
m_rootScrollLayer->setPosition(gfx::PointF(0, 0));
m_rootScrollLayer->setAnchorPoint(gfx::PointF(0, 0));
m_rootScrollLayer->setIsDrawable(true);
m_rootScrollLayer->setScrollable(true);
- m_rootScrollLayer->setMaxScrollOffset(gfx::Vector2d(100, 100));
+ m_rootScrollLayer->setMaxScrollPosition(IntSize(100, 100));
m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer);
- m_rootScrollLayer->setScrollOffset(m_initialScroll);
+ m_rootScrollLayer->setScrollPosition(m_initialScroll);
postSetNeedsCommitToMainThread();
}
- virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
+ virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE
{
- gfx::Vector2d offset = m_rootScrollLayer->scrollOffset();
- m_rootScrollLayer->setScrollOffset(offset + scrollDelta);
+ IntPoint position = m_rootScrollLayer->scrollPosition();
+ m_rootScrollLayer->setScrollPosition(position + scrollDelta);
m_rootScrolls++;
}
@@ -2426,16 +2425,16 @@ public:
{
switch (m_layerTreeHost->commitNumber()) {
case 0:
- EXPECT_VECTOR_EQ(m_initialScroll, m_rootScrollLayer->scrollOffset());
+ EXPECT_POINT_EQ(m_initialScroll, m_rootScrollLayer->scrollPosition());
break;
case 1:
- EXPECT_VECTOR_EQ(m_initialScroll + m_scrollAmount, m_rootScrollLayer->scrollOffset());
+ EXPECT_POINT_EQ(m_initialScroll + m_scrollAmount, m_rootScrollLayer->scrollPosition());
// Pretend like Javascript updated the scroll position itself.
- m_rootScrollLayer->setScrollOffset(m_secondScroll);
+ m_rootScrollLayer->setScrollPosition(m_secondScroll);
break;
case 2:
- EXPECT_VECTOR_EQ(m_secondScroll + m_scrollAmount, m_rootScrollLayer->scrollOffset());
+ EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, m_rootScrollLayer->scrollPosition());
break;
}
}
@@ -2445,7 +2444,7 @@ public:
LayerImpl* root = impl->rootLayer();
LayerImpl* rootScrollLayer = root->children()[0];
- EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d());
+ EXPECT_SIZE_EQ(root->scrollDelta(), IntSize());
EXPECT_EQ(rootScrollLayer->bounds().width() * m_deviceScaleFactor, rootScrollLayer->contentBounds().width());
EXPECT_EQ(rootScrollLayer->bounds().height() * m_deviceScaleFactor, rootScrollLayer->contentBounds().height());
@@ -2456,8 +2455,8 @@ public:
impl->scrollBy(gfx::Point(), m_scrollAmount);
impl->scrollEnd();
- EXPECT_VECTOR_EQ(m_initialScroll, rootScrollLayer->scrollOffset());
- EXPECT_VECTOR_EQ(m_scrollAmount, rootScrollLayer->scrollDelta());
+ EXPECT_POINT_EQ(m_initialScroll, rootScrollLayer->scrollPosition());
+ EXPECT_SIZE_EQ(m_scrollAmount, rootScrollLayer->scrollDelta());
break;
case 1:
// Wheel scroll on impl thread.
@@ -2465,12 +2464,12 @@ public:
impl->scrollBy(gfx::Point(), m_scrollAmount);
impl->scrollEnd();
- EXPECT_VECTOR_EQ(m_secondScroll, rootScrollLayer->scrollOffset());
- EXPECT_VECTOR_EQ(m_scrollAmount, rootScrollLayer->scrollDelta());
+ EXPECT_POINT_EQ(m_secondScroll, rootScrollLayer->scrollPosition());
+ EXPECT_SIZE_EQ(m_scrollAmount, rootScrollLayer->scrollDelta());
break;
case 2:
- EXPECT_VECTOR_EQ(m_secondScroll + m_scrollAmount, rootScrollLayer->scrollOffset());
- EXPECT_VECTOR_EQ(gfx::Vector2d(0, 0), rootScrollLayer->scrollDelta());
+ EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, rootScrollLayer->scrollPosition());
+ EXPECT_SIZE_EQ(IntSize(0, 0), rootScrollLayer->scrollDelta());
endTest();
}
@@ -2483,9 +2482,9 @@ public:
private:
float m_deviceScaleFactor;
- gfx::Vector2d m_initialScroll;
- gfx::Vector2d m_secondScroll;
- gfx::Vector2d m_scrollAmount;
+ IntPoint m_initialScroll;
+ IntPoint m_secondScroll;
+ IntSize m_scrollAmount;
int m_rootScrolls;
MockContentLayerClient m_mockDelegate;
diff --git a/cc/layer_unittest.cc b/cc/layer_unittest.cc
index 88db65b..aadf11e 100644
--- a/cc/layer_unittest.cc
+++ b/cc/layer_unittest.cc
@@ -511,7 +511,7 @@ TEST_F(LayerTest, checkPropertyChangeCausesCorrectBehavior)
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setShouldScrollOnMainThread(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNonFastScrollableRegion(gfx::Rect(1, 1, 2, 2)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setHaveWheelEventHandlers(true));
- EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollOffset(gfx::Vector2d(10, 10)));
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollPosition(IntPoint(10, 10)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(WebTransformationMatrix(0, 0, 0, 0, 0, 0)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDoubleSided(false));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDebugName("Test Layer"));
diff --git a/cc/math_util.cc b/cc/math_util.cc
index a48dc4e..23fd588 100644
--- a/cc/math_util.cc
+++ b/cc/math_util.cc
@@ -6,14 +6,12 @@
#include "cc/math_util.h"
-#include <cmath>
-#include <limits>
-
+#include "FloatSize.h"
#include "ui/gfx/quad_f.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/rect_f.h"
-#include "ui/gfx/vector2d_f.h"
+#include <cmath>
#include <public/WebTransformationMatrix.h>
using WebKit::WebTransformationMatrix;
@@ -380,24 +378,19 @@ gfx::Vector2dF MathUtil::computeTransform2dScaleComponents(const WebTransformati
return gfx::Vector2dF(xScale, yScale);
}
-static inline double rad2deg(double r)
-{
- double pi = 3.14159265358979323846;
- return r * 180.0 / pi;
-}
-
-float MathUtil::smallestAngleBetweenVectors(gfx::Vector2dF v1, gfx::Vector2dF v2)
+float MathUtil::smallestAngleBetweenVectors(const FloatSize& v1, const FloatSize& v2)
{
- double dotProduct = gfx::DotProduct(v1, v2) / v1.Length() / v2.Length();
+ float dotProduct = (v1.width() * v2.width() + v1.height() * v2.height()) / (v1.diagonalLength() * v2.diagonalLength());
// Clamp to compensate for rounding errors.
- dotProduct = std::max(-1.0, std::min(1.0, dotProduct));
- return static_cast<float>(rad2deg(std::acos(dotProduct)));
+ dotProduct = std::max(-1.f, std::min(1.f, dotProduct));
+ return rad2deg(acosf(dotProduct));
}
-gfx::Vector2dF MathUtil::projectVector(gfx::Vector2dF source, gfx::Vector2dF destination)
+FloatSize MathUtil::projectVector(const FloatSize& source, const FloatSize& destination)
{
- float projectedLength = gfx::DotProduct(source, destination) / destination.LengthSquared();
- return gfx::Vector2dF(projectedLength * destination.x(), projectedLength * destination.y());
+ float sourceDotDestination = source.width() * destination.width() + source.height() * destination.height();
+ float projectedLength = sourceDotDestination / destination.diagonalLengthSquared();
+ return FloatSize(projectedLength * destination.width(), projectedLength * destination.height());
}
} // namespace cc
diff --git a/cc/math_util.h b/cc/math_util.h
index 1caf659..7d22c6c 100644
--- a/cc/math_util.h
+++ b/cc/math_util.h
@@ -18,11 +18,12 @@ namespace gfx {
class QuadF;
class Rect;
class RectF;
-class Vector2dF;
}
namespace cc {
+class FloatSize;
+
struct HomogeneousCoordinate {
HomogeneousCoordinate(double newX, double newY, double newZ, double newW)
: x(newX)
@@ -103,10 +104,10 @@ public:
// Returns the smallest angle between the given two vectors in degrees. Neither vector is
// assumed to be normalized.
- static float smallestAngleBetweenVectors(gfx::Vector2dF, gfx::Vector2dF);
+ static float smallestAngleBetweenVectors(const FloatSize&, const FloatSize&);
// Projects the |source| vector onto |destination|. Neither vector is assumed to be normalized.
- static gfx::Vector2dF projectVector(gfx::Vector2dF source, gfx::Vector2dF destination);
+ static FloatSize projectVector(const FloatSize& source, const FloatSize& destination);
};
} // namespace cc
diff --git a/cc/math_util_unittest.cc b/cc/math_util_unittest.cc
index 3fef272..0b3ddcd 100644
--- a/cc/math_util_unittest.cc
+++ b/cc/math_util_unittest.cc
@@ -6,8 +6,7 @@
#include "cc/math_util.h"
-#include <cmath>
-
+#include "FloatSize.h"
#include "cc/test/geometry_test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -137,9 +136,9 @@ TEST(MathUtilTest, verifyEnclosingRectOfVerticesUsesCorrectInitialBounds)
TEST(MathUtilTest, smallestAngleBetweenVectors)
{
- gfx::Vector2dF x(1, 0);
- gfx::Vector2dF y(0, 1);
- gfx::Vector2dF testVector(0.5, 0.5);
+ FloatSize x(1, 0);
+ FloatSize y(0, 1);
+ FloatSize testVector(0.5, 0.5);
// Orthogonal vectors are at an angle of 90 degress.
EXPECT_EQ(90, MathUtil::smallestAngleBetweenVectors(x, y));
@@ -155,31 +154,31 @@ TEST(MathUtilTest, smallestAngleBetweenVectors)
EXPECT_FLOAT_EQ(180, MathUtil::smallestAngleBetweenVectors(testVector, -testVector));
// The test vector is at a known angle.
- EXPECT_FLOAT_EQ(45, std::floor(MathUtil::smallestAngleBetweenVectors(testVector, x)));
- EXPECT_FLOAT_EQ(45, std::floor(MathUtil::smallestAngleBetweenVectors(testVector, y)));
+ EXPECT_FLOAT_EQ(45, floor(MathUtil::smallestAngleBetweenVectors(testVector, x)));
+ EXPECT_FLOAT_EQ(45, floor(MathUtil::smallestAngleBetweenVectors(testVector, y)));
}
TEST(MathUtilTest, vectorProjection)
{
- gfx::Vector2dF x(1, 0);
- gfx::Vector2dF y(0, 1);
- gfx::Vector2dF testVector(0.3f, 0.7f);
+ FloatSize x(1, 0);
+ FloatSize y(0, 1);
+ FloatSize testVector(0.3f, 0.7f);
// Orthogonal vectors project to a zero vector.
- EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), MathUtil::projectVector(x, y));
- EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), MathUtil::projectVector(y, x));
+ EXPECT_EQ(FloatSize(0, 0), MathUtil::projectVector(x, y));
+ EXPECT_EQ(FloatSize(0, 0), MathUtil::projectVector(y, x));
// Projecting a vector onto the orthonormal basis gives the corresponding component of the
// vector.
- EXPECT_VECTOR_EQ(gfx::Vector2dF(testVector.x(), 0), MathUtil::projectVector(testVector, x));
- EXPECT_VECTOR_EQ(gfx::Vector2dF(0, testVector.y()), MathUtil::projectVector(testVector, y));
+ EXPECT_EQ(FloatSize(testVector.width(), 0), MathUtil::projectVector(testVector, x));
+ EXPECT_EQ(FloatSize(0, testVector.height()), MathUtil::projectVector(testVector, y));
// Finally check than an arbitrary vector projected to another one gives a vector parallel to
// the second vector.
- gfx::Vector2dF targetVector(0.5, 0.2f);
- gfx::Vector2dF projectedVector = MathUtil::projectVector(testVector, targetVector);
- EXPECT_EQ(projectedVector.x() / targetVector.x(),
- projectedVector.y() / targetVector.y());
+ FloatSize targetVector(0.5, 0.2f);
+ FloatSize projectedVector = MathUtil::projectVector(testVector, targetVector);
+ EXPECT_EQ(projectedVector.width() / targetVector.width(),
+ projectedVector.height() / targetVector.height());
}
} // namespace
diff --git a/cc/page_scale_animation.cc b/cc/page_scale_animation.cc
index 49948ab..59424d4 100644
--- a/cc/page_scale_animation.cc
+++ b/cc/page_scale_animation.cc
@@ -6,21 +6,22 @@
#include "cc/page_scale_animation.h"
-#include "cc/geometry.h"
+#include "FloatPoint.h"
+#include "FloatSize.h"
+#include "IntPoint.h"
+#include "IntSize.h"
#include "ui/gfx/rect_f.h"
-#include "ui/gfx/vector2d_conversions.h"
-#include "ui/gfx/vector2d_f.h"
#include <math.h>
namespace cc {
-scoped_ptr<PageScaleAnimation> PageScaleAnimation::create(gfx::Vector2d scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime)
+scoped_ptr<PageScaleAnimation> PageScaleAnimation::create(const IntSize& scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime)
{
return make_scoped_ptr(new PageScaleAnimation(scrollStart, pageScaleStart, windowSize, contentSize, startTime));
}
-PageScaleAnimation::PageScaleAnimation(gfx::Vector2d scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime)
+PageScaleAnimation::PageScaleAnimation(const IntSize& scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime)
: m_scrollStart(scrollStart)
, m_pageScaleStart(pageScaleStart)
, m_windowSize(windowSize)
@@ -37,13 +38,13 @@ PageScaleAnimation::~PageScaleAnimation()
{
}
-void PageScaleAnimation::zoomTo(gfx::Vector2d finalScroll, float finalPageScale, double duration)
+void PageScaleAnimation::zoomTo(const IntSize& finalScroll, float finalPageScale, double duration)
{
if (m_pageScaleStart != finalPageScale) {
// For uniform-looking zooming, infer the anchor (point that remains in
// place throughout the zoom) from the start and end rects.
- gfx::RectF startRect(gfx::PointAtOffsetFromOrigin(m_scrollStart), m_windowSize);
- gfx::RectF endRect(gfx::PointAtOffsetFromOrigin(finalScroll), m_windowSize);
+ gfx::RectF startRect(cc::FloatPoint(cc::IntPoint(m_scrollStart)), m_windowSize);
+ gfx::RectF endRect(cc::FloatPoint(cc::IntPoint(finalScroll)), m_windowSize);
endRect.Scale(m_pageScaleStart / finalPageScale);
// The anchor is the point which is at the same ratio of the sides of
@@ -60,7 +61,7 @@ void PageScaleAnimation::zoomTo(gfx::Vector2d finalScroll, float finalPageScale,
float ratioX = (startRect.x() - endRect.x()) / (endRect.width() - startRect.width());
float ratioY = (startRect.y() - endRect.y()) / (endRect.height() - startRect.height());
- gfx::Vector2d anchor(m_windowSize.width() * ratioX, m_windowSize.height() * ratioY);
+ IntSize anchor(m_windowSize.width() * ratioX, m_windowSize.height() * ratioY);
zoomWithAnchor(anchor, finalPageScale, duration);
} else {
// If this is a pure translation, then there exists no anchor. Linearly
@@ -72,17 +73,16 @@ void PageScaleAnimation::zoomTo(gfx::Vector2d finalScroll, float finalPageScale,
}
}
-void PageScaleAnimation::zoomWithAnchor(gfx::Vector2d anchor, float finalPageScale, double duration)
+void PageScaleAnimation::zoomWithAnchor(const IntSize& anchor, float finalPageScale, double duration)
{
m_scrollEnd = m_scrollStart + anchor;
- m_scrollEnd = gfx::ToFlooredVector2d(cc::ScaleVector2d(m_scrollEnd, finalPageScale / m_pageScaleStart));
+ m_scrollEnd.scale(finalPageScale / m_pageScaleStart);
m_scrollEnd -= anchor;
- m_scrollEnd = ClampFromBelow(m_scrollEnd, gfx::Vector2d());
+ m_scrollEnd.clampNegativeToZero();
gfx::SizeF scaledContentSize = m_contentSize.Scale(finalPageScale / m_pageScaleStart);
- gfx::Vector2d maxScrollOffset = gfx::ToRoundedVector2d(BottomRight(gfx::RectF(scaledContentSize)) - BottomRight(gfx::Rect(m_windowSize)));
- m_scrollEnd = m_scrollEnd;
- m_scrollEnd = ClampFromAbove(m_scrollEnd, maxScrollOffset);
+ IntSize maxScrollPosition = roundedIntSize(cc::FloatSize(scaledContentSize) - cc::IntSize(m_windowSize));
+ m_scrollEnd = m_scrollEnd.shrunkTo(maxScrollPosition);
m_anchor = anchor;
m_pageScaleEnd = finalPageScale;
@@ -90,7 +90,7 @@ void PageScaleAnimation::zoomWithAnchor(gfx::Vector2d anchor, float finalPageSca
m_anchorMode = true;
}
-gfx::Vector2d PageScaleAnimation::scrollOffsetAtTime(double time) const
+IntSize PageScaleAnimation::scrollOffsetAtTime(double time) const
{
return scrollOffsetAtRatio(progressRatioForTime(time));
}
@@ -113,7 +113,7 @@ float PageScaleAnimation::progressRatioForTime(double time) const
return (time - m_startTime) / m_duration;
}
-gfx::Vector2d PageScaleAnimation::scrollOffsetAtRatio(float ratio) const
+IntSize PageScaleAnimation::scrollOffsetAtRatio(float ratio) const
{
if (ratio <= 0)
return m_scrollStart;
@@ -121,23 +121,23 @@ gfx::Vector2d PageScaleAnimation::scrollOffsetAtRatio(float ratio) const
return m_scrollEnd;
float currentPageScale = pageScaleAtRatio(ratio);
- gfx::Vector2d currentScrollOffset;
+ IntSize currentScrollOffset;
if (m_anchorMode) {
// Keep the anchor stable on the screen at the current scale.
- gfx::Vector2dF documentAnchor = m_scrollStart + m_anchor;
- documentAnchor.Scale(currentPageScale / m_pageScaleStart);
- currentScrollOffset = gfx::ToRoundedVector2d(documentAnchor - m_anchor);
+ IntSize documentAnchor = m_scrollStart + m_anchor;
+ documentAnchor.scale(currentPageScale / m_pageScaleStart);
+ currentScrollOffset = documentAnchor - m_anchor;
} else {
// First move both scroll offsets to the current coordinate space.
- gfx::Vector2dF scaledStartScroll(m_scrollStart);
- scaledStartScroll.Scale(currentPageScale / m_pageScaleStart);
- gfx::Vector2dF scaledEndScroll(m_scrollEnd);
- scaledEndScroll.Scale(currentPageScale / m_pageScaleEnd);
+ FloatSize scaledStartScroll(m_scrollStart);
+ scaledStartScroll.scale(currentPageScale / m_pageScaleStart);
+ FloatSize scaledEndScroll(m_scrollEnd);
+ scaledEndScroll.scale(currentPageScale / m_pageScaleEnd);
// Linearly interpolate between them.
- gfx::Vector2dF delta = scaledEndScroll - scaledStartScroll;
- delta.Scale(ratio);
- currentScrollOffset = gfx::ToRoundedVector2d(scaledStartScroll + delta);
+ FloatSize delta = scaledEndScroll - scaledStartScroll;
+ delta.scale(ratio);
+ currentScrollOffset = roundedIntSize(scaledStartScroll + delta);
}
return currentScrollOffset;
diff --git a/cc/page_scale_animation.h b/cc/page_scale_animation.h
index c4c2940..5f4bbac 100644
--- a/cc/page_scale_animation.h
+++ b/cc/page_scale_animation.h
@@ -6,8 +6,7 @@
#define CC_PAGE_SCALE_ANIMATION_H_
#include "base/memory/scoped_ptr.h"
-#include "ui/gfx/size.h"
-#include "ui/gfx/vector2d.h"
+#include "IntSize.h"
namespace cc {
@@ -20,7 +19,7 @@ public:
// Construct with the starting page scale and scroll offset (which is in
// pageScaleStart space). The window size is the user-viewable area
// in pixels.
- static scoped_ptr<PageScaleAnimation> create(gfx::Vector2d scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime);
+ static scoped_ptr<PageScaleAnimation> create(const IntSize& scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime);
~PageScaleAnimation();
// The following methods initialize the animation. Call one of them
@@ -28,16 +27,16 @@ public:
// Zoom while explicitly specifying the top-left scroll position. The
// scroll offset is in finalPageScale coordinates.
- void zoomTo(gfx::Vector2d finalScroll, float finalPageScale, double duration);
+ void zoomTo(const IntSize& finalScroll, float finalPageScale, double duration);
// Zoom based on a specified onscreen anchor, which will remain at the same
// position on the screen throughout the animation. The anchor is in local
// space relative to scrollStart.
- void zoomWithAnchor(gfx::Vector2d anchor, float finalPageScale, double duration);
+ void zoomWithAnchor(const IntSize& anchor, float finalPageScale, double duration);
// Call these functions while the animation is in progress to output the
// current state.
- gfx::Vector2d scrollOffsetAtTime(double time) const;
+ IntSize scrollOffsetAtTime(double time) const;
float pageScaleAtTime(double time) const;
bool isAnimationCompleteAtTime(double time) const;
@@ -46,25 +45,25 @@ public:
double startTime() const { return m_startTime; }
double duration() const { return m_duration; }
double endTime() const { return m_startTime + m_duration; }
- gfx::Vector2d finalScrollOffset() const { return m_scrollEnd; }
+ const IntSize& finalScrollOffset() const { return m_scrollEnd; }
float finalPageScale() const { return m_pageScaleEnd; }
protected:
- PageScaleAnimation(gfx::Vector2d scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime);
+ PageScaleAnimation(const IntSize& scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime);
private:
float progressRatioForTime(double time) const;
- gfx::Vector2d scrollOffsetAtRatio(float ratio) const;
+ IntSize scrollOffsetAtRatio(float ratio) const;
float pageScaleAtRatio(float ratio) const;
- gfx::Vector2d m_scrollStart;
+ IntSize m_scrollStart;
float m_pageScaleStart;
gfx::Size m_windowSize;
gfx::Size m_contentSize;
bool m_anchorMode;
- gfx::Vector2d m_anchor;
- gfx::Vector2d m_scrollEnd;
+ IntSize m_anchor;
+ IntSize m_scrollEnd;
float m_pageScaleEnd;
double m_startTime;
diff --git a/cc/proxy.h b/cc/proxy.h
index ac61540..8b5287d 100644
--- a/cc/proxy.h
+++ b/cc/proxy.h
@@ -13,12 +13,12 @@
namespace gfx {
class Rect;
-class Vector2d;
}
namespace cc {
class Thread;
+class IntSize;
struct RenderingStats;
struct RendererCapabilities;
@@ -40,7 +40,7 @@ public:
virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) = 0;
- virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration) = 0;
+ virtual void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration) = 0;
virtual void finishAllRendering() = 0;
diff --git a/cc/scrollbar_animation_controller.cc b/cc/scrollbar_animation_controller.cc
index 5a603945..7335e2c 100644
--- a/cc/scrollbar_animation_controller.cc
+++ b/cc/scrollbar_animation_controller.cc
@@ -77,20 +77,20 @@ gfx::Size ScrollbarAnimationController::getScrollLayerBounds(const LayerImpl* sc
void ScrollbarAnimationController::updateScrollOffsetAtTime(LayerImpl* scrollLayer, double)
{
- m_currentOffset = scrollLayer->scrollOffset() + scrollLayer->scrollDelta();
+ m_currentPos = scrollLayer->scrollPosition() + scrollLayer->scrollDelta();
m_totalSize = getScrollLayerBounds(scrollLayer);
- m_maximum = scrollLayer->maxScrollOffset();
+ m_maximum = scrollLayer->maxScrollPosition();
if (m_horizontalScrollbarLayer) {
- m_horizontalScrollbarLayer->setCurrentPos(m_currentOffset.x());
+ m_horizontalScrollbarLayer->setCurrentPos(m_currentPos.x());
m_horizontalScrollbarLayer->setTotalSize(m_totalSize.width());
- m_horizontalScrollbarLayer->setMaximum(m_maximum.x());
+ m_horizontalScrollbarLayer->setMaximum(m_maximum.width());
}
if (m_verticalScrollbarLayer) {
- m_verticalScrollbarLayer->setCurrentPos(m_currentOffset.y());
+ m_verticalScrollbarLayer->setCurrentPos(m_currentPos.y());
m_verticalScrollbarLayer->setTotalSize(m_totalSize.height());
- m_verticalScrollbarLayer->setMaximum(m_maximum.y());
+ m_verticalScrollbarLayer->setMaximum(m_maximum.height());
}
}
diff --git a/cc/scrollbar_animation_controller.h b/cc/scrollbar_animation_controller.h
index eaf2913..c26b464 100644
--- a/cc/scrollbar_animation_controller.h
+++ b/cc/scrollbar_animation_controller.h
@@ -7,9 +7,12 @@
#include "base/memory/scoped_ptr.h"
#include "cc/cc_export.h"
-#include "ui/gfx/size.h"
-#include "ui/gfx/vector2d.h"
-#include "ui/gfx/vector2d_f.h"
+#include "FloatPoint.h"
+#include "IntSize.h"
+
+namespace gfx {
+class Size;
+}
namespace cc {
@@ -36,9 +39,9 @@ public:
void setVerticalScrollbarLayer(ScrollbarLayerImpl* layer) { m_verticalScrollbarLayer = layer; }
ScrollbarLayerImpl* verticalScrollbarLayer() const { return m_verticalScrollbarLayer; }
- gfx::Vector2dF currentOffset() const { return m_currentOffset; }
+ FloatPoint currentPos() const { return m_currentPos; }
gfx::Size totalSize() const { return m_totalSize; }
- gfx::Vector2d maximum() const { return m_maximum; }
+ IntSize maximum() const { return m_maximum; }
virtual void didPinchGestureBeginAtTime(double monotonicTime) { }
virtual void didPinchGestureUpdateAtTime(double monotonicTime) { }
@@ -55,9 +58,9 @@ private:
ScrollbarLayerImpl* m_horizontalScrollbarLayer;
ScrollbarLayerImpl* m_verticalScrollbarLayer;
- gfx::Vector2dF m_currentOffset;
+ FloatPoint m_currentPos;
gfx::Size m_totalSize;
- gfx::Vector2d m_maximum;
+ IntSize m_maximum;
};
} // namespace cc
diff --git a/cc/scrollbar_animation_controller_linear_fade.cc b/cc/scrollbar_animation_controller_linear_fade.cc
index 0b3870c..6d721bf 100644
--- a/cc/scrollbar_animation_controller_linear_fade.cc
+++ b/cc/scrollbar_animation_controller_linear_fade.cc
@@ -51,10 +51,10 @@ void ScrollbarAnimationControllerLinearFade::didPinchGestureEndAtTime(double mon
void ScrollbarAnimationControllerLinearFade::updateScrollOffsetAtTime(LayerImpl* scrollLayer, double monotonicTime)
{
- gfx::Vector2dF previousPos = currentOffset();
+ FloatPoint previousPos = currentPos();
ScrollbarAnimationController::updateScrollOffsetAtTime(scrollLayer, monotonicTime);
- if (previousPos == currentOffset())
+ if (previousPos == currentPos())
return;
m_lastAwakenTime = monotonicTime;
diff --git a/cc/scrollbar_animation_controller_linear_fade_unittest.cc b/cc/scrollbar_animation_controller_linear_fade_unittest.cc
index 592d793..32537cb 100644
--- a/cc/scrollbar_animation_controller_linear_fade_unittest.cc
+++ b/cc/scrollbar_animation_controller_linear_fade_unittest.cc
@@ -23,8 +23,8 @@ protected:
m_contentLayer = m_scrollLayer->children()[0];
m_scrollbarLayer = ScrollbarLayerImpl::create(3);
- m_scrollLayer->setMaxScrollOffset(gfx::Vector2d(50, 50));
- m_contentLayer->setBounds(gfx::Size(50, 50));
+ m_scrollLayer->setMaxScrollPosition(IntSize(50, 50));
+ m_contentLayer->setBounds(IntSize(50, 50));
m_scrollbarController = ScrollbarAnimationControllerLinearFade::create(m_scrollLayer.get(), 2, 3);
m_scrollbarController->setHorizontalScrollbarLayer(m_scrollbarLayer.get());
@@ -50,13 +50,13 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyHiddenInBegin)
TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByScroll)
{
- m_scrollLayer->setScrollDelta(gfx::Vector2d(1, 1));
+ m_scrollLayer->setScrollDelta(IntSize(1, 1));
m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 0);
m_scrollbarController->animate(0);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
m_scrollbarController->animate(1);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
- m_scrollLayer->setScrollDelta(gfx::Vector2d(2, 2));
+ m_scrollLayer->setScrollDelta(IntSize(2, 2));
m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 1);
m_scrollbarController->animate(2);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
@@ -68,7 +68,7 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByScroll)
EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity());
m_scrollbarController->animate(5);
EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity());
- m_scrollLayer->setScrollDelta(gfx::Vector2d(3, 3));
+ m_scrollLayer->setScrollDelta(IntSize(3, 3));
m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 5);
m_scrollbarController->animate(6);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
@@ -90,7 +90,7 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyForceAwakenByPinch)
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
m_scrollbarController->animate(1);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
- m_scrollLayer->setScrollDelta(gfx::Vector2d(1, 1));
+ m_scrollLayer->setScrollDelta(IntSize(1, 1));
m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 1);
m_scrollbarController->animate(2);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
diff --git a/cc/scrollbar_geometry_fixed_thumb.cc b/cc/scrollbar_geometry_fixed_thumb.cc
index 13a9678..cbf0adb4 100644
--- a/cc/scrollbar_geometry_fixed_thumb.cc
+++ b/cc/scrollbar_geometry_fixed_thumb.cc
@@ -30,9 +30,9 @@ void ScrollbarGeometryFixedThumb::update(WebScrollbar* scrollbar)
int length = ScrollbarGeometryStub::thumbLength(scrollbar);
if (scrollbar->orientation() == WebScrollbar::Horizontal)
- m_thumbSize = gfx::Size(length, scrollbar->size().height);
+ m_thumbSize = IntSize(length, scrollbar->size().height);
else
- m_thumbSize = gfx::Size(scrollbar->size().width, length);
+ m_thumbSize = IntSize(scrollbar->size().width, length);
}
WebScrollbarThemeGeometry* ScrollbarGeometryFixedThumb::clone() const
diff --git a/cc/scrollbar_geometry_fixed_thumb.h b/cc/scrollbar_geometry_fixed_thumb.h
index 1480372..1deed9d 100644
--- a/cc/scrollbar_geometry_fixed_thumb.h
+++ b/cc/scrollbar_geometry_fixed_thumb.h
@@ -5,9 +5,9 @@
#ifndef CC_SCROLLBAR_GEOMETRY_FIXED_THUMB_H_
#define CC_SCROLLBAR_GEOMETRY_FIXED_THUMB_H_
+#include "IntSize.h"
#include "cc/cc_export.h"
#include "cc/scrollbar_geometry_stub.h"
-#include "ui/gfx/size.h"
namespace cc {
@@ -32,7 +32,7 @@ public:
private:
explicit ScrollbarGeometryFixedThumb(scoped_ptr<WebKit::WebScrollbarThemeGeometry>);
- gfx::Size m_thumbSize;
+ IntSize m_thumbSize;
};
}
diff --git a/cc/scrollbar_layer_unittest.cc b/cc/scrollbar_layer_unittest.cc
index 8cb3cc0..fb68734 100644
--- a/cc/scrollbar_layer_unittest.cc
+++ b/cc/scrollbar_layer_unittest.cc
@@ -97,9 +97,9 @@ TEST(ScrollbarLayerTest, scrollOffsetSynchronization)
layerTreeRoot->addChild(contentLayer);
layerTreeRoot->addChild(scrollbarLayer);
- layerTreeRoot->setScrollOffset(gfx::Vector2d(10, 20));
- layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(30, 50));
- contentLayer->setBounds(gfx::Size(100, 200));
+ layerTreeRoot->setScrollPosition(IntPoint(10, 20));
+ layerTreeRoot->setMaxScrollPosition(IntSize(30, 50));
+ contentLayer->setBounds(IntSize(100, 200));
scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), 0);
@@ -109,9 +109,9 @@ TEST(ScrollbarLayerTest, scrollOffsetSynchronization)
EXPECT_EQ(100, ccScrollbarLayer->totalSize());
EXPECT_EQ(30, ccScrollbarLayer->maximum());
- layerTreeRoot->setScrollOffset(gfx::Vector2d(100, 200));
- layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(300, 500));
- contentLayer->setBounds(gfx::Size(1000, 2000));
+ layerTreeRoot->setScrollPosition(IntPoint(100, 200));
+ layerTreeRoot->setMaxScrollPosition(IntSize(300, 500));
+ contentLayer->setBounds(IntSize(1000, 2000));
ScrollbarAnimationController* scrollbarController = layerImplTreeRoot->scrollbarAnimationController();
layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), 0);
@@ -121,7 +121,7 @@ TEST(ScrollbarLayerTest, scrollOffsetSynchronization)
EXPECT_EQ(1000, ccScrollbarLayer->totalSize());
EXPECT_EQ(300, ccScrollbarLayer->maximum());
- layerImplTreeRoot->scrollBy(gfx::Vector2d(12, 34));
+ layerImplTreeRoot->scrollBy(FloatSize(12, 34));
EXPECT_EQ(112, ccScrollbarLayer->currentPos());
EXPECT_EQ(1000, ccScrollbarLayer->totalSize());
diff --git a/cc/single_thread_proxy.cc b/cc/single_thread_proxy.cc
index b9cf353..7fe679f 100644
--- a/cc/single_thread_proxy.cc
+++ b/cc/single_thread_proxy.cc
@@ -62,9 +62,9 @@ bool SingleThreadProxy::compositeAndReadback(void *pixels, const gfx::Rect& rect
return true;
}
-void SingleThreadProxy::startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration)
+void SingleThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration)
{
- m_layerTreeHostImpl->startPageScaleAnimation(targetOffset, useAnchor, scale, base::TimeTicks::Now(), duration);
+ m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scale, base::TimeTicks::Now(), duration);
}
void SingleThreadProxy::finishAllRendering()
diff --git a/cc/single_thread_proxy.h b/cc/single_thread_proxy.h
index db73ee4..f91d7b6 100644
--- a/cc/single_thread_proxy.h
+++ b/cc/single_thread_proxy.h
@@ -23,7 +23,7 @@ public:
// Proxy implementation
virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) OVERRIDE;
- virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE;
+ virtual void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE;
virtual void finishAllRendering() OVERRIDE;
virtual bool isStarted() const OVERRIDE;
virtual bool initializeContext() OVERRIDE;
diff --git a/cc/stubs/FloatPoint.h b/cc/stubs/FloatPoint.h
new file mode 100644
index 0000000..df1fe9f
--- /dev/null
+++ b/cc/stubs/FloatPoint.h
@@ -0,0 +1,6 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Temporary forwarding header
+#include "cc/stubs/float_point.h"
diff --git a/cc/stubs/FloatSize.h b/cc/stubs/FloatSize.h
new file mode 100644
index 0000000..f5d5c4e
--- /dev/null
+++ b/cc/stubs/FloatSize.h
@@ -0,0 +1,6 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Temporary forwarding header
+#include "cc/stubs/float_size.h"
diff --git a/cc/stubs/IntPoint.h b/cc/stubs/IntPoint.h
new file mode 100644
index 0000000..d996ea8
--- /dev/null
+++ b/cc/stubs/IntPoint.h
@@ -0,0 +1,6 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Temporary forwarding header
+#include "cc/stubs/int_point.h"
diff --git a/cc/stubs/IntSize.h b/cc/stubs/IntSize.h
new file mode 100644
index 0000000..4508c69
--- /dev/null
+++ b/cc/stubs/IntSize.h
@@ -0,0 +1,6 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Temporary forwarding header
+#include "cc/stubs/int_size.h"
diff --git a/cc/stubs/float_point.h b/cc/stubs/float_point.h
new file mode 100644
index 0000000..c5f5191
--- /dev/null
+++ b/cc/stubs/float_point.h
@@ -0,0 +1,58 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_STUBS_FLOATPOINT_H_
+#define CC_STUBS_FLOATPOINT_H_
+
+#include "FloatSize.h"
+#include "IntPoint.h"
+#if INSIDE_WEBKIT_BUILD
+#include "Source/WebCore/platform/graphics/FloatPoint.h"
+#else
+#include "third_party/WebKit/Source/WebCore/platform/graphics/FloatPoint.h"
+#endif
+#include "ui/gfx/point_f.h"
+
+namespace cc {
+
+class FloatPoint : public WebCore::FloatPoint {
+public:
+ FloatPoint() { }
+
+ FloatPoint(float width, float height)
+ : WebCore::FloatPoint(width, height)
+ {
+ }
+
+ FloatPoint(FloatSize size)
+ : WebCore::FloatPoint(size)
+ {
+ }
+
+ FloatPoint(IntPoint point)
+ : WebCore::FloatPoint(point)
+ {
+ }
+
+ FloatPoint(WebCore::IntPoint point)
+ : WebCore::FloatPoint(point)
+ {
+ }
+
+ FloatPoint(WebCore::FloatPoint point)
+ : WebCore::FloatPoint(point.x(), point.y())
+ {
+ }
+
+ explicit FloatPoint(gfx::PointF point)
+ : WebCore::FloatPoint(point.x(), point.y())
+ {
+ }
+
+ operator gfx::PointF() const { return gfx::PointF(x(), y()); }
+};
+
+}
+
+#endif
diff --git a/cc/stubs/float_size.h b/cc/stubs/float_size.h
new file mode 100644
index 0000000..2193ac0
--- /dev/null
+++ b/cc/stubs/float_size.h
@@ -0,0 +1,59 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_STUBS_FLOATSIZE_H_
+#define CC_STUBS_FLOATSIZE_H_
+
+#include "IntSize.h"
+#if INSIDE_WEBKIT_BUILD
+#include "Source/WebCore/platform/graphics/FloatSize.h"
+#else
+#include "third_party/WebKit/Source/WebCore/platform/graphics/FloatSize.h"
+#endif
+#include "ui/gfx/size_f.h"
+#include "ui/gfx/vector2d_f.h"
+
+namespace cc {
+class FloatSize : public WebCore::FloatSize {
+public:
+ FloatSize() { }
+
+ FloatSize(float width, float height)
+ : WebCore::FloatSize(width, height)
+ {
+ }
+
+ FloatSize(IntSize size)
+ : WebCore::FloatSize(size.width(), size.height())
+ {
+ }
+
+ FloatSize(WebCore::FloatSize size)
+ : WebCore::FloatSize(size.width(), size.height())
+ {
+ }
+
+ FloatSize(WebCore::IntSize size)
+ : WebCore::FloatSize(size.width(), size.height())
+ {
+ }
+
+ explicit FloatSize(gfx::SizeF size)
+ : WebCore::FloatSize(size.width(), size.height())
+ {
+ }
+
+ explicit FloatSize(gfx::Vector2dF vector)
+ : WebCore::FloatSize(vector.x(), vector.y())
+ {
+ }
+
+ operator gfx::SizeF() const { return gfx::SizeF(width(), height()); }
+
+ operator gfx::Vector2dF() const { return gfx::Vector2dF(width(), height()); }
+};
+
+}
+
+#endif
diff --git a/cc/stubs/int_point.h b/cc/stubs/int_point.h
new file mode 100644
index 0000000..068c662
--- /dev/null
+++ b/cc/stubs/int_point.h
@@ -0,0 +1,47 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_STUBS_INTPOINT_H_
+#define CC_STUBS_INTPOINT_H_
+
+#include "IntSize.h"
+#if INSIDE_WEBKIT_BUILD
+#include "Source/WebCore/platform/graphics/IntPoint.h"
+#else
+#include "third_party/WebKit/Source/WebCore/platform/graphics/IntPoint.h"
+#endif
+#include "ui/gfx/point.h"
+
+namespace cc {
+
+class IntPoint : public WebCore::IntPoint {
+public:
+ IntPoint() { }
+
+ IntPoint(int width, int height)
+ : WebCore::IntPoint(width, height)
+ {
+ }
+
+ IntPoint(IntSize size)
+ : WebCore::IntPoint(size.width(), size.height())
+ {
+ }
+
+ IntPoint(WebCore::IntPoint point)
+ : WebCore::IntPoint(point.x(), point.y())
+ {
+ }
+
+ explicit IntPoint(gfx::Point point)
+ : WebCore::IntPoint(point.x(), point.y())
+ {
+ }
+
+ operator gfx::Point() const { return gfx::Point(x(), y()); }
+};
+
+}
+
+#endif
diff --git a/cc/stubs/int_size.h b/cc/stubs/int_size.h
new file mode 100644
index 0000000..9e1c3e6
--- /dev/null
+++ b/cc/stubs/int_size.h
@@ -0,0 +1,50 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_STUBS_INTSIZE_H_
+#define CC_STUBS_INTSIZE_H_
+
+#if INSIDE_WEBKIT_BUILD
+#include "Source/WebCore/platform/graphics/IntSize.h"
+#else
+#include "third_party/WebKit/Source/WebCore/platform/graphics/IntSize.h"
+#endif
+#include "ui/gfx/size.h"
+#include "ui/gfx/vector2d.h"
+
+namespace cc {
+
+class IntSize : public WebCore::IntSize {
+public:
+ IntSize() { }
+
+ IntSize(int width, int height)
+ : WebCore::IntSize(width, height)
+ {
+ }
+
+ IntSize(WebCore::IntSize size)
+ : WebCore::IntSize(size.width(), size.height())
+ {
+
+ }
+
+ explicit IntSize(gfx::Size size)
+ : WebCore::IntSize(size.width(), size.height())
+ {
+ }
+
+ explicit IntSize(gfx::Vector2d vector)
+ : WebCore::IntSize(vector.x(), vector.y())
+ {
+ }
+
+ operator gfx::Size() const { return gfx::Size(width(), height()); }
+
+ operator gfx::Vector2d() const { return gfx::Vector2d(width(), height()); }
+};
+
+}
+
+#endif
diff --git a/cc/test/fake_layer_tree_host_client.h b/cc/test/fake_layer_tree_host_client.h
index 78e7a8f..8140495 100644
--- a/cc/test/fake_layer_tree_host_client.h
+++ b/cc/test/fake_layer_tree_host_client.h
@@ -20,7 +20,7 @@ public:
virtual void didBeginFrame() OVERRIDE { }
virtual void animate(double monotonicFrameBeginTime) OVERRIDE { }
virtual void layout() OVERRIDE { }
- virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float pageScale) OVERRIDE { }
+ virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) OVERRIDE { }
virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() OVERRIDE;
virtual void didRecreateOutputSurface(bool success) OVERRIDE { }
diff --git a/cc/test/geometry_test_utils.h b/cc/test/geometry_test_utils.h
index 52cb814..7877a64 100644
--- a/cc/test/geometry_test_utils.h
+++ b/cc/test/geometry_test_utils.h
@@ -13,38 +13,32 @@ namespace WebKitTests {
// These are macros instead of functions so that we get useful line numbers where a test failed.
#define EXPECT_FLOAT_RECT_EQ(expected, actual) \
-do { \
+{ \
EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \
EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \
EXPECT_FLOAT_EQ((expected).width(), (actual).width()); \
EXPECT_FLOAT_EQ((expected).height(), (actual).height()); \
-} while (false)
+}
#define EXPECT_RECT_EQ(expected, actual) \
-do { \
+{ \
EXPECT_EQ((expected).x(), (actual).x()); \
EXPECT_EQ((expected).y(), (actual).y()); \
EXPECT_EQ((expected).width(), (actual).width()); \
EXPECT_EQ((expected).height(), (actual).height()); \
-} while (false)
+}
#define EXPECT_SIZE_EQ(expected, actual) \
-do { \
+{ \
EXPECT_EQ((expected).width(), (actual).width()); \
EXPECT_EQ((expected).height(), (actual).height()); \
-} while (false)
+}
#define EXPECT_POINT_EQ(expected, actual) \
-do { \
+{ \
EXPECT_EQ((expected).x(), (actual).x()); \
EXPECT_EQ((expected).y(), (actual).y()); \
-} while (false)
-
-#define EXPECT_VECTOR_EQ(expected, actual) \
-do { \
- EXPECT_EQ((expected).x(), (actual).x()); \
- EXPECT_EQ((expected).y(), (actual).y()); \
-} while (false)
+}
// This is a function rather than a macro because when this is included as a macro
// in bulk, it causes a significant slow-down in compilation time. This problem
diff --git a/cc/test/layer_tree_test_common.cc b/cc/test/layer_tree_test_common.cc
index 1842d17..65a2904 100644
--- a/cc/test/layer_tree_test_common.cc
+++ b/cc/test/layer_tree_test_common.cc
@@ -219,7 +219,7 @@ public:
m_testHooks->layout();
}
- virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
+ virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE
{
m_testHooks->applyScrollAndScale(scrollDelta, scale);
}
diff --git a/cc/test/layer_tree_test_common.h b/cc/test/layer_tree_test_common.h
index 0e02cfa..ad044d5 100644
--- a/cc/test/layer_tree_test_common.h
+++ b/cc/test/layer_tree_test_common.h
@@ -34,7 +34,7 @@ public:
virtual void drawLayersOnThread(cc::LayerTreeHostImpl*) { }
virtual void animateLayers(cc::LayerTreeHostImpl*, base::TimeTicks monotonicTime) { }
virtual void willAnimateLayers(cc::LayerTreeHostImpl*, base::TimeTicks monotonicTime) { }
- virtual void applyScrollAndScale(gfx::Vector2d, float) { }
+ virtual void applyScrollAndScale(const cc::IntSize&, float) { }
virtual void animate(base::TimeTicks monotonicTime) { }
virtual void layout() { }
virtual void didRecreateOutputSurface(bool succeeded) { }
diff --git a/cc/thread_proxy.cc b/cc/thread_proxy.cc
index 76272e7..ac58216 100644
--- a/cc/thread_proxy.cc
+++ b/cc/thread_proxy.cc
@@ -117,17 +117,17 @@ void ThreadProxy::requestReadbackOnImplThread(ReadbackRequest* request)
m_schedulerOnImplThread->setNeedsForcedRedraw();
}
-void ThreadProxy::startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration)
+void ThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration)
{
DCHECK(Proxy::isMainThread());
- Proxy::implThread()->postTask(base::Bind(&ThreadProxy::requestStartPageScaleAnimationOnImplThread, base::Unretained(this), targetOffset, useAnchor, scale, duration));
+ Proxy::implThread()->postTask(base::Bind(&ThreadProxy::requestStartPageScaleAnimationOnImplThread, base::Unretained(this), targetPosition, useAnchor, scale, duration));
}
-void ThreadProxy::requestStartPageScaleAnimationOnImplThread(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration)
+void ThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPosition, bool useAnchor, float scale, base::TimeDelta duration)
{
DCHECK(Proxy::isImplThread());
if (m_layerTreeHostImpl.get())
- m_layerTreeHostImpl->startPageScaleAnimation(targetOffset, useAnchor, scale, base::TimeTicks::Now(), duration);
+ m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scale, base::TimeTicks::Now(), duration);
}
void ThreadProxy::finishAllRendering()
diff --git a/cc/thread_proxy.h b/cc/thread_proxy.h
index 7e14347..1a24ec5 100644
--- a/cc/thread_proxy.h
+++ b/cc/thread_proxy.h
@@ -30,7 +30,7 @@ public:
// Proxy implementation
virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) OVERRIDE;
- virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE;
+ virtual void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE;
virtual void finishAllRendering() OVERRIDE;
virtual bool isStarted() const OVERRIDE;
virtual bool initializeContext() OVERRIDE;
@@ -111,7 +111,7 @@ private:
void beginFrameCompleteOnImplThread(CompletionEvent*, ResourceUpdateQueue*);
void beginFrameAbortedOnImplThread();
void requestReadbackOnImplThread(ReadbackRequest*);
- void requestStartPageScaleAnimationOnImplThread(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration);
+ void requestStartPageScaleAnimationOnImplThread(IntSize targetPosition, bool useAnchor, float scale, base::TimeDelta duration);
void finishAllRenderingOnImplThread(CompletionEvent*);
void initializeImplOnImplThread(CompletionEvent*, InputHandler*);
void setSurfaceReadyOnImplThread();