summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--webkit/compositor_bindings/compositor_bindings.gyp2
-rw-r--r--webkit/compositor_bindings/web_content_layer_impl.cc1
-rw-r--r--webkit/compositor_bindings/web_layer_impl.cc9
-rw-r--r--webkit/compositor_bindings/web_layer_tree_view_impl.cc7
-rw-r--r--webkit/compositor_bindings/web_layer_tree_view_impl.h2
-rw-r--r--webkit/compositor_bindings/web_to_ccinput_handler_adapter.cc9
-rw-r--r--webkit/compositor_bindings/webcore_convert.cc38
-rw-r--r--webkit/compositor_bindings/webcore_convert.h26
56 files changed, 596 insertions, 844 deletions
diff --git a/cc/DEPS b/cc/DEPS
index cf10e4c..56c6cf7 100644
--- a/cc/DEPS
+++ b/cc/DEPS
@@ -5,22 +5,7 @@ include_rules = [
"+third_party/khronos/GLES2/gl2ext.h",
"+ui/gfx",
"+media",
-# 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
+# http://crbug.com/147395
"+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 1e5e25a..9198927 100644
--- a/cc/geometry.h
+++ b/cc/geometry.h
@@ -5,9 +5,10 @@
#ifndef CC_GEOMETRY_H_
#define CC_GEOMETRY_H_
-#include "ui/gfx/size.h"
+#include "ui/gfx/rect.h"
+#include "ui/gfx/rect_f.h"
+#include "ui/gfx/vector2d.h"
#include "ui/gfx/vector2d_f.h"
-#include <cmath>
namespace cc {
@@ -16,6 +17,67 @@ 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 5f6a706..6898c1f 100644
--- a/cc/input_handler.h
+++ b/cc/input_handler.h
@@ -11,13 +11,11 @@
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.
//
@@ -36,7 +34,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(const gfx::Point&, ScrollInputType) = 0;
+ virtual ScrollStatus scrollBegin(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
@@ -45,17 +43,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(const gfx::Point&, const IntSize&) = 0;
+ virtual void scrollBy(gfx::Point, gfx::Vector2d) = 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, const IntPoint& anchor) = 0;
+ virtual void pinchGestureUpdate(float magnifyDelta, gfx::Point anchor) = 0;
virtual void pinchGestureEnd() = 0;
- virtual void startPageScaleAnimation(const IntSize& targetPosition,
+ virtual void startPageScaleAnimation(gfx::Vector2d targetOffset,
bool anchorPoint,
float pageScale,
base::TimeTicks startTime,
diff --git a/cc/layer.cc b/cc/layer.cc
index 1377dec..b11c5e6 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::setScrollPosition(const IntPoint& scrollPosition)
+void Layer::setScrollOffset(gfx::Vector2d scrollOffset)
{
- if (m_scrollPosition == scrollPosition)
+ if (m_scrollOffset == scrollOffset)
return;
- m_scrollPosition = scrollPosition;
+ m_scrollOffset = scrollOffset;
if (m_layerScrollClient)
m_layerScrollClient->didScroll();
setNeedsCommit();
}
-void Layer::setMaxScrollPosition(const IntSize& maxScrollPosition)
+void Layer::setMaxScrollOffset(gfx::Vector2d maxScrollOffset)
{
- if (m_maxScrollPosition == maxScrollPosition)
+ if (m_maxScrollOffset == maxScrollOffset)
return;
- m_maxScrollPosition = maxScrollPosition;
+ m_maxScrollOffset = maxScrollOffset;
setNeedsCommit();
}
@@ -587,8 +587,8 @@ void Layer::pushPropertiesTo(LayerImpl* layer)
layer->setFixedToContainerLayer(m_fixedToContainerLayer);
layer->setPreserves3D(preserves3D());
layer->setUseParentBackfaceVisibility(m_useParentBackfaceVisibility);
- layer->setScrollPosition(m_scrollPosition);
- layer->setMaxScrollPosition(m_maxScrollPosition);
+ layer->setScrollOffset(m_scrollOffset);
+ layer->setMaxScrollOffset(m_maxScrollOffset);
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(IntSize());
+ layer->setSentScrollDelta(gfx::Vector2d());
layer->setStackingOrderChanged(m_stackingOrderChanged);
diff --git a/cc/layer.h b/cc/layer.h
index d827ed4..3375b65 100644
--- a/cc/layer.h
+++ b/cc/layer.h
@@ -5,7 +5,6 @@
#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"
@@ -129,11 +128,11 @@ public:
const gfx::Rect& visibleContentRect() const { return m_visibleContentRect; }
void setVisibleContentRect(const gfx::Rect& visibleContentRect) { m_visibleContentRect = visibleContentRect; }
- void setScrollPosition(const IntPoint&);
- const IntPoint& scrollPosition() const { return m_scrollPosition; }
+ void setScrollOffset(gfx::Vector2d);
+ gfx::Vector2d scrollOffset() const { return m_scrollOffset; }
- void setMaxScrollPosition(const IntSize&);
- const IntSize& maxScrollPosition() const { return m_maxScrollPosition; }
+ void setMaxScrollOffset(gfx::Vector2d);
+ gfx::Vector2d maxScrollOffset() const { return m_maxScrollOffset; }
void setScrollable(bool);
bool scrollable() const { return m_scrollable; }
@@ -156,7 +155,7 @@ public:
bool forceRenderSurface() const { return m_forceRenderSurface; }
void setForceRenderSurface(bool);
- IntSize scrollDelta() const { return IntSize(); }
+ gfx::Vector2d scrollDelta() const { return gfx::Vector2d(); }
void setImplTransform(const WebKit::WebTransformationMatrix&);
const WebKit::WebTransformationMatrix& implTransform() const { return m_implTransform; }
@@ -344,8 +343,8 @@ private:
// Uses layer's content space.
gfx::Rect m_visibleContentRect;
- IntPoint m_scrollPosition;
- IntSize m_maxScrollPosition;
+ gfx::Vector2d m_scrollOffset;
+ gfx::Vector2d m_maxScrollOffset;
bool m_scrollable;
bool m_shouldScrollOnMainThread;
bool m_haveWheelEventHandlers;
diff --git a/cc/layer_impl.cc b/cc/layer_impl.cc
index 54e45fad..0b57f67 100644
--- a/cc/layer_impl.cc
+++ b/cc/layer_impl.cc
@@ -9,6 +9,7 @@
#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"
@@ -179,13 +180,15 @@ ResourceProvider::ResourceId LayerImpl::contentsResourceId() const
return 0;
}
-FloatSize LayerImpl::scrollBy(const FloatSize& scroll)
+gfx::Vector2dF LayerImpl::scrollBy(const gfx::Vector2dF& scroll)
{
- IntSize minDelta = -toSize(m_scrollPosition);
- IntSize maxDelta = m_maxScrollPosition - toSize(m_scrollPosition);
+ gfx::Vector2dF minDelta = -m_scrollOffset;
+ gfx::Vector2dF maxDelta = m_maxScrollOffset - m_scrollOffset;
// Clamp newDelta so that position + delta stays within scroll bounds.
- FloatSize newDelta = (m_scrollDelta + scroll).expandedTo(minDelta).shrunkTo(maxDelta);
- FloatSize unscrolled = m_scrollDelta + scroll - newDelta;
+ gfx::Vector2dF newDelta = (m_scrollDelta + scroll);
+ newDelta = ClampFromBelow(newDelta, minDelta);
+ newDelta = ClampFromAbove(newDelta, maxDelta);
+ gfx::Vector2dF unscrolled = m_scrollDelta + scroll - newDelta;
if (m_scrollDelta == newDelta)
return unscrolled;
@@ -623,16 +626,16 @@ void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY)
m_layerPropertyChanged = true;
}
-void LayerImpl::setScrollPosition(const IntPoint& scrollPosition)
+void LayerImpl::setScrollOffset(gfx::Vector2d scrollOffset)
{
- if (m_scrollPosition == scrollPosition)
+ if (m_scrollOffset == scrollOffset)
return;
- m_scrollPosition = scrollPosition;
+ m_scrollOffset = scrollOffset;
noteLayerPropertyChangedForSubtree();
}
-void LayerImpl::setScrollDelta(const FloatSize& scrollDelta)
+void LayerImpl::setScrollDelta(const gfx::Vector2dF& scrollDelta)
{
if (m_scrollDelta == scrollDelta)
return;
@@ -670,9 +673,9 @@ void LayerImpl::didLoseContext()
{
}
-void LayerImpl::setMaxScrollPosition(const IntSize& maxScrollPosition)
+void LayerImpl::setMaxScrollOffset(gfx::Vector2d maxScrollOffset)
{
- m_maxScrollPosition = maxScrollPosition;
+ m_maxScrollOffset = maxScrollOffset;
if (!m_scrollbarAnimationController)
return;
diff --git a/cc/layer_impl.h b/cc/layer_impl.h
index d51f3d0..c467d82 100644
--- a/cc/layer_impl.h
+++ b/cc/layer_impl.h
@@ -7,8 +7,6 @@
#include <string>
-#include "FloatSize.h"
-#include "IntPoint.h"
#include "Region.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -187,23 +185,23 @@ public:
float contentsScaleY() const { return m_contentsScaleY; }
void setContentsScale(float contentsScaleX, float contentsScaleY);
- const IntPoint& scrollPosition() const { return m_scrollPosition; }
- void setScrollPosition(const IntPoint&);
+ gfx::Vector2d scrollOffset() const { return m_scrollOffset; }
+ void setScrollOffset(gfx::Vector2d);
- const IntSize& maxScrollPosition() const {return m_maxScrollPosition; }
- void setMaxScrollPosition(const IntSize&);
+ gfx::Vector2d maxScrollOffset() const {return m_maxScrollOffset; }
+ void setMaxScrollOffset(gfx::Vector2d);
- const FloatSize& scrollDelta() const { return m_scrollDelta; }
- void setScrollDelta(const FloatSize&);
+ const gfx::Vector2dF& scrollDelta() const { return m_scrollDelta; }
+ void setScrollDelta(const gfx::Vector2dF&);
const WebKit::WebTransformationMatrix& implTransform() const { return m_implTransform; }
void setImplTransform(const WebKit::WebTransformationMatrix& transform);
- const IntSize& sentScrollDelta() const { return m_sentScrollDelta; }
- void setSentScrollDelta(const IntSize& sentScrollDelta) { m_sentScrollDelta = sentScrollDelta; }
+ const gfx::Vector2d& sentScrollDelta() const { return m_sentScrollDelta; }
+ void setSentScrollDelta(const gfx::Vector2d& sentScrollDelta) { m_sentScrollDelta = sentScrollDelta; }
// Returns the delta of the scroll that was outside of the bounds of the initial scroll
- FloatSize scrollBy(const FloatSize& scroll);
+ gfx::Vector2dF scrollBy(const gfx::Vector2dF& scroll);
bool scrollable() const { return m_scrollable; }
void setScrollable(bool scrollable) { m_scrollable = scrollable; }
@@ -316,7 +314,7 @@ private:
gfx::Size m_contentBounds;
float m_contentsScaleX;
float m_contentsScaleY;
- IntPoint m_scrollPosition;
+ gfx::Vector2d m_scrollOffset;
bool m_scrollable;
bool m_shouldScrollOnMainThread;
bool m_haveWheelEventHandlers;
@@ -356,9 +354,9 @@ private:
// This is true if the layer should be fixed to the closest ancestor container.
bool m_fixedToContainerLayer;
- FloatSize m_scrollDelta;
- IntSize m_sentScrollDelta;
- IntSize m_maxScrollPosition;
+ gfx::Vector2dF m_scrollDelta;
+ gfx::Vector2d m_sentScrollDelta;
+ gfx::Vector2d m_maxScrollOffset;
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 b852078..eafbc88 100644
--- a/cc/layer_impl_unittest.cc
+++ b/cc/layer_impl_unittest.cc
@@ -76,6 +76,7 @@ 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);
@@ -94,7 +95,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->setMaxScrollPosition(cc::IntSize(arbitrarySize)));
+ EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setMaxScrollOffset(arbitraryVector2d));
// Changing these properties affects the entire subtree of layers.
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setAnchorPoint(arbitraryPointF));
@@ -109,9 +110,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(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->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->setImplTransform(arbitraryTransform));
// Changing these properties only affects the layer itself.
@@ -149,8 +150,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(cc::IntSize()));
- EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScrollPosition(cc::IntPoint(arbitraryPoint)));
+ 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->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 f9eae12..65200d7 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(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration)
+void LayerTreeHost::startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration)
{
- m_proxy->startPageScaleAnimation(targetPosition, useAnchor, scale, duration);
+ m_proxy->startPageScaleAnimation(targetOffset, 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());
- IntSize rootScrollDelta;
+ gfx::Vector2d 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->setScrollPosition(layer->scrollPosition() + info.scrolls[i].scrollDelta);
+ layer->setScrollOffset(layer->scrollOffset() + 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 7dd334c..74e999b 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(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration);
+ void startPageScaleAnimation(gfx::Vector2d targetOffset, 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 3bec0328..f6cb702 100644
--- a/cc/layer_tree_host_client.h
+++ b/cc/layer_tree_host_client.h
@@ -7,13 +7,16 @@
#include "base/memory/scoped_ptr.h"
+namespace gfx {
+class Vector2d;
+}
+
namespace WebKit {
class WebCompositorOutputSurface;
}
namespace cc {
class InputHandler;
-class IntSize;
class LayerTreeHostClient {
public:
@@ -22,7 +25,7 @@ public:
virtual void didBeginFrame() = 0;
virtual void animate(double frameBeginTime) = 0;
virtual void layout() = 0;
- virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) = 0;
+ virtual void applyScrollAndScale(gfx::Vector2d 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 a119b89..ae73d1d 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().width(), scrollingLayer->scrollDelta().height()); // Step 2
+ scrollCompensationForThisLayer.translate(scrollingLayer->scrollDelta().x(), scrollingLayer->scrollDelta().y()); // 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() - gfx::Vector2d(layer->scrollDelta().width(), layer->scrollDelta().height());
+ gfx::PointF position = layer->position() - layer->scrollDelta();
WebTransformationMatrix layerLocalTransform;
// LT = Tr[origin] * Tr[origin2anchor]
diff --git a/cc/layer_tree_host_common.h b/cc/layer_tree_host_common.h
index 78ec5e4..cc5e621 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 "IntSize.h"
+#include "ui/gfx/vector2d.h"
#include <public/WebTransformationMatrix.h>
namespace cc {
@@ -46,7 +46,7 @@ public:
struct ScrollUpdateInfo {
int layerId;
- IntSize scrollDelta;
+ gfx::Vector2d scrollDelta;
};
};
diff --git a/cc/layer_tree_host_common_unittest.cc b/cc/layer_tree_host_common_unittest.cc
index e18137a..962d39c 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(IntSize(0, 0));
+ child->setScrollDelta(gfx::Vector2d(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(IntSize(10, 10));
+ child->setScrollDelta(gfx::Vector2d(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(IntSize(0, 0));
+ child->setScrollDelta(gfx::Vector2d(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(IntSize(10, 20));
+ child->setScrollDelta(gfx::Vector2d(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(IntSize(0, 0));
+ child->setScrollDelta(gfx::Vector2d(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(IntSize(10, 10));
+ child->setScrollDelta(gfx::Vector2d(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(IntSize(0, 0));
+ child->setScrollDelta(gfx::Vector2d(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(IntSize(10, 20));
+ child->setScrollDelta(gfx::Vector2d(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(IntSize(0, 0));
+ child->setScrollDelta(gfx::Vector2d(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(IntSize(10, 0));
- grandChild->setScrollDelta(IntSize(5, 0));
+ child->setScrollDelta(gfx::Vector2d(10, 0));
+ grandChild->setScrollDelta(gfx::Vector2d(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(IntSize(0, 0));
+ child->setScrollDelta(gfx::Vector2d(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(IntSize(10, 30));
+ child->setScrollDelta(gfx::Vector2d(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(IntSize(0, 0));
+ child->setScrollDelta(gfx::Vector2d(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(IntSize(10, 30));
+ child->setScrollDelta(gfx::Vector2d(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(IntSize(0, 0));
+ child->setScrollDelta(gfx::Vector2d(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(IntSize(10, 10));
+ child->setScrollDelta(gfx::Vector2d(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(IntSize(0, 0));
+ child->setScrollDelta(gfx::Vector2d(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(IntSize(10, 10));
+ child->setScrollDelta(gfx::Vector2d(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(IntSize(0, 0));
+ root->setScrollDelta(gfx::Vector2d(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(IntSize(10, 20));
+ root->setScrollDelta(gfx::Vector2d(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 73568ff..2f5ee5c 100644
--- a/cc/layer_tree_host_impl.cc
+++ b/cc/layer_tree_host_impl.cc
@@ -14,6 +14,7 @@
#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"
@@ -32,6 +33,7 @@
#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;
@@ -101,12 +103,12 @@ gfx::RectF PinchZoomViewport::bounds() const
scaledViewportSize = scaledViewportSize.Scale(1 / totalPageScaleFactor());
gfx::RectF bounds(gfx::PointF(), scaledViewportSize);
- bounds.set_origin(m_pinchViewportScrollDelta);
+ bounds.Offset(m_pinchViewportScrollDelta);
return bounds;
}
-FloatSize PinchZoomViewport::applyScroll(const gfx::Vector2dF& delta)
+gfx::Vector2dF PinchZoomViewport::applyScroll(const gfx::Vector2dF& delta)
{
gfx::Vector2dF overflow;
gfx::RectF pinchedBounds = bounds();
@@ -131,9 +133,9 @@ FloatSize PinchZoomViewport::applyScroll(const gfx::Vector2dF& delta)
overflow.set_y(pinchedBounds.bottom() - m_layoutViewportSize.height());
pinchedBounds.Offset(0, m_layoutViewportSize.height() - pinchedBounds.bottom());
}
- m_pinchViewportScrollDelta = cc::FloatPoint(pinchedBounds.origin());
+ m_pinchViewportScrollDelta = pinchedBounds.OffsetFromOrigin();
- return cc::FloatSize(overflow);
+ return overflow;
}
WebTransformationMatrix PinchZoomViewport::implTransform() const
@@ -249,7 +251,7 @@ void LayerTreeHostImpl::commitComplete()
TRACE_EVENT0("cc", "LayerTreeHostImpl::commitComplete");
// Recompute max scroll position; must be after layer content bounds are
// updated.
- updateMaxScrollPosition();
+ updateMaxScrollOffset();
m_client->sendManagedMemoryStats();
}
@@ -290,26 +292,26 @@ void LayerTreeHostImpl::animate(base::TimeTicks monotonicTime, base::Time wallCl
animateScrollbars(monotonicTime);
}
-void LayerTreeHostImpl::startPageScaleAnimation(const IntSize& targetPosition, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta duration)
+void LayerTreeHostImpl::startPageScaleAnimation(gfx::Vector2d targetOffset, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta duration)
{
if (!m_rootScrollLayerImpl)
return;
- IntSize scrollTotal = flooredIntSize(m_rootScrollLayerImpl->scrollPosition() + m_rootScrollLayerImpl->scrollDelta());
- scrollTotal.scale(m_pinchZoomViewport.pageScaleDelta());
+ gfx::Vector2dF scrollTotal = m_rootScrollLayerImpl->scrollOffset() + 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(scrollTotal, scaleTotal, cc::IntSize(m_deviceViewportSize), scaledContentSize, startTimeSeconds);
+ m_pageScaleAnimation = PageScaleAnimation::create(gfx::ToFlooredVector2d(scrollTotal), scaleTotal, m_deviceViewportSize, scaledContentSize, startTimeSeconds);
if (anchorPoint) {
- IntSize windowAnchor(targetPosition);
- windowAnchor.scale(scaleTotal / pageScale);
+ gfx::Vector2dF windowAnchor = targetOffset;
+ windowAnchor.Scale(scaleTotal / pageScale);
windowAnchor -= scrollTotal;
- m_pageScaleAnimation->zoomWithAnchor(windowAnchor, pageScale, duration.InSecondsF());
+ m_pageScaleAnimation->zoomWithAnchor(gfx::ToFlooredVector2d(windowAnchor), pageScale, duration.InSecondsF());
} else
- m_pageScaleAnimation->zoomTo(targetPosition, pageScale, duration.InSecondsF());
+ m_pageScaleAnimation->zoomTo(targetOffset, pageScale, duration.InSecondsF());
m_client->setNeedsRedrawOnImplThread();
m_client->setNeedsCommitOnImplThread();
@@ -890,9 +892,9 @@ void LayerTreeHostImpl::setViewportSize(const gfx::Size& layoutViewportSize, con
m_layoutViewportSize = layoutViewportSize;
m_deviceViewportSize = deviceViewportSize;
- m_pinchZoomViewport.setLayoutViewportSize(FloatSize(layoutViewportSize));
+ m_pinchZoomViewport.setLayoutViewportSize(layoutViewportSize);
- updateMaxScrollPosition();
+ updateMaxScrollOffset();
if (m_renderer)
m_renderer->viewportChanged();
@@ -907,8 +909,8 @@ static void adjustScrollsForPageScaleChange(LayerImpl* layerImpl, float pageScal
if (layerImpl->scrollable()) {
// We need to convert impl-side scroll deltas to pageScale space.
- FloatSize scrollDelta = layerImpl->scrollDelta();
- scrollDelta.scale(pageScaleChange);
+ gfx::Vector2dF scrollDelta = layerImpl->scrollDelta();
+ scrollDelta.Scale(pageScaleChange);
layerImpl->setScrollDelta(scrollDelta);
}
@@ -922,7 +924,7 @@ void LayerTreeHostImpl::setDeviceScaleFactor(float deviceScaleFactor)
return;
m_deviceScaleFactor = deviceScaleFactor;
- updateMaxScrollPosition();
+ updateMaxScrollOffset();
}
float LayerTreeHostImpl::pageScaleFactor() const
@@ -952,10 +954,10 @@ void LayerTreeHostImpl::setPageScaleDelta(float delta)
{
m_pinchZoomViewport.setPageScaleDelta(delta);
- updateMaxScrollPosition();
+ updateMaxScrollOffset();
}
-void LayerTreeHostImpl::updateMaxScrollPosition()
+void LayerTreeHostImpl::updateMaxScrollOffset()
{
if (!m_rootScrollLayerImpl || !m_rootScrollLayerImpl->children().size())
return;
@@ -981,14 +983,14 @@ void LayerTreeHostImpl::updateMaxScrollPosition()
viewBounds = viewBounds.Scale(1 / m_pinchZoomViewport.pageScaleDelta());
}
- IntSize maxScroll = cc::IntSize(contentBounds) - expandedIntSize(cc::FloatSize(viewBounds));
- maxScroll.scale(1 / m_deviceScaleFactor);
+ gfx::Vector2dF maxScroll = BottomRight(gfx::Rect(contentBounds)) - BottomRight(gfx::RectF(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.clampNegativeToZero();
+ maxScroll = ClampFromBelow(maxScroll, gfx::Vector2dF());
- m_rootScrollLayerImpl->setMaxScrollPosition(maxScroll);
+ m_rootScrollLayerImpl->setMaxScrollOffset(gfx::ToFlooredVector2d(maxScroll));
}
void LayerTreeHostImpl::setNeedsRedraw()
@@ -1017,7 +1019,7 @@ bool LayerTreeHostImpl::ensureRenderSurfaceLayerList()
return m_renderSurfaceLayerList.size();
}
-InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(const gfx::Point& viewportPoint, InputHandlerClient::ScrollInputType type)
+InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewportPoint, InputHandlerClient::ScrollInputType type)
{
TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin");
@@ -1070,7 +1072,7 @@ InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(const gfx::Point
return ScrollIgnored;
}
-static FloatSize scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewport, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, const gfx::PointF& viewportPoint, const FloatSize& viewportDelta)
+static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewport, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF viewportPoint, gfx::Vector2dF viewportDelta)
{
// Layers with non-invertible screen space transforms should not have passed the scroll hit
// test in the first place.
@@ -1079,8 +1081,8 @@ static FloatSize scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewport,
gfx::PointF screenSpacePoint = viewportPoint.Scale(scaleFromViewportToScreenSpace);
- FloatSize screenSpaceDelta = viewportDelta;
- screenSpaceDelta.scale(scaleFromViewportToScreenSpace, scaleFromViewportToScreenSpace);
+ gfx::Vector2dF screenSpaceDelta = viewportDelta;
+ screenSpaceDelta.Scale(scaleFromViewportToScreenSpace);
// First project the scroll start and end points to local layer space to find the scroll delta
// in layer coordinates.
@@ -1093,7 +1095,7 @@ static FloatSize scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewport,
DCHECK(!startClipped);
DCHECK(!endClipped);
if (startClipped || endClipped)
- return FloatSize();
+ return gfx::Vector2dF();
// localStartPoint and localEndPoint are in content space but we want to move them to layer space for scrolling.
float widthScale = 1 / layerImpl.contentsScaleX();
@@ -1102,8 +1104,8 @@ static FloatSize scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewport,
localEndPoint = localEndPoint.Scale(widthScale, heightScale);
// Apply the scroll delta.
- FloatSize previousDelta(layerImpl.scrollDelta());
- FloatSize unscrolled = layerImpl.scrollBy(cc::FloatSize(localEndPoint - localStartPoint));
+ gfx::Vector2dF previousDelta = layerImpl.scrollDelta();
+ gfx::Vector2dF unscrolled = layerImpl.scrollBy(localEndPoint - localStartPoint);
if (viewport)
viewport->applyScroll(unscrolled);
@@ -1116,32 +1118,32 @@ static FloatSize scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewport,
gfx::PointF actualScreenSpaceEndPoint = MathUtil::mapPoint(layerImpl.screenSpaceTransform(), actualLocalContentEndPoint, endClipped);
DCHECK(!endClipped);
if (endClipped)
- return FloatSize();
+ return gfx::Vector2dF();
gfx::PointF actualViewportEndPoint = actualScreenSpaceEndPoint.Scale(1 / scaleFromViewportToScreenSpace);
- return cc::FloatSize(actualViewportEndPoint - viewportPoint);
+ return actualViewportEndPoint - viewportPoint;
}
-static FloatSize scrollLayerWithLocalDelta(LayerImpl& layerImpl, const FloatSize& localDelta)
+static gfx::Vector2dF scrollLayerWithLocalDelta(LayerImpl& layerImpl, gfx::Vector2dF localDelta)
{
- FloatSize previousDelta(layerImpl.scrollDelta());
+ gfx::Vector2dF previousDelta(layerImpl.scrollDelta());
layerImpl.scrollBy(localDelta);
return layerImpl.scrollDelta() - previousDelta;
}
-void LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint, const IntSize& scrollDelta)
+void LayerTreeHostImpl::scrollBy(gfx::Point viewportPoint, gfx::Vector2d scrollDelta)
{
TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy");
if (!m_currentlyScrollingLayerImpl)
return;
- FloatSize pendingDelta(scrollDelta);
+ gfx::Vector2dF pendingDelta = scrollDelta;
for (LayerImpl* layerImpl = m_currentlyScrollingLayerImpl; layerImpl; layerImpl = layerImpl->parent()) {
if (!layerImpl->scrollable())
continue;
PinchZoomViewport* viewport = layerImpl == m_rootScrollLayerImpl ? &m_pinchZoomViewport : 0;
- FloatSize appliedDelta;
+ gfx::Vector2dF appliedDelta;
if (m_scrollDeltaIsInViewportSpace) {
float scaleFromViewportToScreenSpace = m_deviceScaleFactor;
appliedDelta = scrollLayerWithViewportSpaceDelta(viewport, *layerImpl, scaleFromViewportToScreenSpace, viewportPoint, pendingDelta);
@@ -1150,27 +1152,27 @@ void LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint, const IntSize&
// If the layer wasn't able to move, try the next one in the hierarchy.
float moveThresholdSquared = 0.1f * 0.1f;
- if (appliedDelta.diagonalLengthSquared() < moveThresholdSquared)
+ if (appliedDelta.LengthSquared() < 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 = FloatSize();
+ pendingDelta = gfx::Vector2d();
break;
}
// Allow further movement only on an axis perpendicular to the direction in which the layer
// moved.
- FloatSize perpendicularAxis(-appliedDelta.height(), appliedDelta.width());
+ gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x());
pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis);
- if (flooredIntSize(pendingDelta).isZero())
+ if (gfx::ToFlooredVector2d(pendingDelta).IsZero())
break;
}
- if (!scrollDelta.isZero() && flooredIntSize(pendingDelta).isEmpty()) {
+ if (!scrollDelta.IsZero() && gfx::ToFlooredVector2d(pendingDelta).IsZero()) {
m_client->setNeedsCommitOnImplThread();
m_client->setNeedsRedrawOnImplThread();
}
@@ -1190,42 +1192,40 @@ void LayerTreeHostImpl::scrollEnd()
void LayerTreeHostImpl::pinchGestureBegin()
{
m_pinchGestureActive = true;
- m_previousPinchAnchor = IntPoint();
+ m_previousPinchAnchor = gfx::Point();
if (m_rootScrollLayerImpl && m_rootScrollLayerImpl->scrollbarAnimationController())
m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureBegin();
}
-void LayerTreeHostImpl::pinchGestureUpdate(float magnifyDelta,
- const IntPoint& anchor)
+void LayerTreeHostImpl::pinchGestureUpdate(float magnifyDelta, gfx::Point anchor)
{
TRACE_EVENT0("cc", "LayerTreeHostImpl::pinchGestureUpdate");
if (!m_rootScrollLayerImpl)
return;
- if (m_previousPinchAnchor == IntPoint::zero())
+ if (m_previousPinchAnchor == gfx::Point())
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();
- FloatPoint previousScaleAnchor(m_previousPinchAnchor.x() / pageScaleDelta,
- m_previousPinchAnchor.y() / pageScaleDelta);
+ gfx::PointF previousScaleAnchor = m_previousPinchAnchor.Scale(1 / pageScaleDelta);
setPageScaleDelta(pageScaleDelta * magnifyDelta);
pageScaleDelta = m_pinchZoomViewport.pageScaleDelta();
- FloatPoint newScaleAnchor(anchor.x() / pageScaleDelta, anchor.y() / pageScaleDelta);
- FloatSize move = previousScaleAnchor - newScaleAnchor;
+ gfx::PointF newScaleAnchor = anchor.Scale(1 / pageScaleDelta);
+ gfx::Vector2dF 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));
}
- FloatSize scrollOverflow = Settings::pageScalePinchZoomEnabled() ? m_pinchZoomViewport.applyScroll(move) : move;
- m_rootScrollLayerImpl->scrollBy(roundedIntSize(scrollOverflow));
+ gfx::Vector2dF scrollOverflow = Settings::pageScalePinchZoomEnabled() ? m_pinchZoomViewport.applyScroll(move) : move;
+ m_rootScrollLayerImpl->scrollBy(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();
- IntSize scrollOffset = m_pageScaleAnimation->finalScrollOffset();
- scrollOffset.scale(m_pinchZoomViewport.pageScaleFactor() / pageScale);
- makeScrollAndScaleSet(scrollInfo, scrollOffset, pageScale);
+ gfx::Vector2dF scrollOffset = m_pageScaleAnimation->finalScrollOffset();
+ scrollOffset.Scale(m_pinchZoomViewport.pageScaleFactor() / pageScale);
+ makeScrollAndScaleSet(scrollInfo, gfx::ToRoundedVector2d(scrollOffset), pageScale);
}
void LayerTreeHostImpl::computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo)
@@ -1266,31 +1266,32 @@ void LayerTreeHostImpl::computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo)
// Compute where the scroll offset/page scale would be if fully pinch-zoomed
// out from the anchor point.
- IntSize scrollBegin = flooredIntSize(m_rootScrollLayerImpl->scrollPosition() + m_rootScrollLayerImpl->scrollDelta());
- scrollBegin.scale(m_pinchZoomViewport.pageScaleDelta());
+ gfx::Vector2dF scrollBegin = m_rootScrollLayerImpl->scrollOffset() + 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);
- 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);
+ 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);
- makeScrollAndScaleSet(scrollInfo, roundedIntSize(scrollEnd), m_pinchZoomViewport.minPageScaleFactor());
+ makeScrollAndScaleSet(scrollInfo, gfx::ToRoundedVector2d(scrollEnd), m_pinchZoomViewport.minPageScaleFactor());
}
-void LayerTreeHostImpl::makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, const IntSize& scrollOffset, float pageScale)
+void LayerTreeHostImpl::makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx::Vector2d scrollOffset, float pageScale)
{
if (!m_rootScrollLayerImpl)
return;
LayerTreeHostCommon::ScrollUpdateInfo scroll;
scroll.layerId = m_rootScrollLayerImpl->id();
- scroll.scrollDelta = scrollOffset - toSize(m_rootScrollLayerImpl->scrollPosition());
+ scroll.scrollDelta = scrollOffset - m_rootScrollLayerImpl->scrollOffset();
scrollInfo->scrolls.push_back(scroll);
m_rootScrollLayerImpl->setSentScrollDelta(scroll.scrollDelta);
scrollInfo->pageScaleDelta = pageScale / m_pinchZoomViewport.pageScaleFactor();
@@ -1302,8 +1303,8 @@ static void collectScrollDeltas(ScrollAndScaleSet* scrollInfo, LayerImpl* layerI
if (!layerImpl)
return;
- if (!layerImpl->scrollDelta().isZero()) {
- IntSize scrollDelta = flooredIntSize(layerImpl->scrollDelta());
+ if (!layerImpl->scrollDelta().IsZero()) {
+ gfx::Vector2d scrollDelta = gfx::ToFlooredVector2d(layerImpl->scrollDelta());
LayerTreeHostCommon::ScrollUpdateInfo scroll;
scroll.layerId = layerImpl->id();
scroll.scrollDelta = scrollDelta;
@@ -1360,11 +1361,11 @@ void LayerTreeHostImpl::animatePageScale(base::TimeTicks time)
return;
double monotonicTime = (time - base::TimeTicks()).InSecondsF();
- IntSize scrollTotal = flooredIntSize(m_rootScrollLayerImpl->scrollPosition() + m_rootScrollLayerImpl->scrollDelta());
+ gfx::Vector2dF scrollTotal = m_rootScrollLayerImpl->scrollOffset() + m_rootScrollLayerImpl->scrollDelta();
setPageScaleDelta(m_pageScaleAnimation->pageScaleAtTime(monotonicTime) / m_pinchZoomViewport.pageScaleFactor());
- IntSize nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monotonicTime);
- nextScroll.scale(1 / m_pinchZoomViewport.pageScaleDelta());
+ gfx::Vector2dF 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 bfbef47..9af0553 100644
--- a/cc/layer_tree_host_impl.h
+++ b/cc/layer_tree_host_impl.h
@@ -5,7 +5,6 @@
#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"
@@ -78,14 +77,14 @@ public:
// Returns the bounds and offset of the scaled and translated viewport to use for pinch-zoom.
gfx::RectF bounds() const;
- const FloatPoint& scrollDelta() const { return m_pinchViewportScrollDelta; }
+ const gfx::Vector2dF& 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.
- FloatSize applyScroll(const gfx::Vector2dF&);
+ gfx::Vector2dF applyScroll(const gfx::Vector2dF&);
WebKit::WebTransformationMatrix implTransform() const;
@@ -96,7 +95,7 @@ private:
float m_maxPageScaleFactor;
float m_minPageScaleFactor;
- FloatPoint m_pinchViewportScrollDelta;
+ gfx::Vector2dF m_pinchViewportScrollDelta;
gfx::SizeF m_layoutViewportSize;
};
@@ -111,13 +110,13 @@ public:
virtual ~LayerTreeHostImpl();
// InputHandlerClient implementation
- virtual InputHandlerClient::ScrollStatus scrollBegin(const gfx::Point&, InputHandlerClient::ScrollInputType) OVERRIDE;
- virtual void scrollBy(const gfx::Point&, const IntSize&) OVERRIDE;
+ virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandlerClient::ScrollInputType) OVERRIDE;
+ virtual void scrollBy(gfx::Point, gfx::Vector2d) OVERRIDE;
virtual void scrollEnd() OVERRIDE;
virtual void pinchGestureBegin() OVERRIDE;
- virtual void pinchGestureUpdate(float, const IntPoint&) OVERRIDE;
+ virtual void pinchGestureUpdate(float, gfx::Point) OVERRIDE;
virtual void pinchGestureEnd() OVERRIDE;
- virtual void startPageScaleAnimation(const IntSize& targetPosition, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta duration) OVERRIDE;
+ virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta duration) OVERRIDE;
virtual void scheduleAnimation() OVERRIDE;
struct CC_EXPORT FrameData : public RenderPassSink {
@@ -213,7 +212,7 @@ public:
scoped_ptr<ScrollAndScaleSet> processScrollDeltas();
WebKit::WebTransformationMatrix implTransform() const;
- void startPageScaleAnimation(const IntSize& tragetPosition, bool useAnchor, float scale, base::TimeDelta duration);
+ void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration);
SkColor backgroundColor() const { return m_backgroundColor; }
void setBackgroundColor(SkColor color) { m_backgroundColor = color; }
@@ -285,10 +284,10 @@ protected:
private:
void computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo);
void computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo);
- void makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, const IntSize& scrollOffset, float pageScale);
+ void makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx::Vector2d scrollOffset, float pageScale);
void setPageScaleDelta(float);
- void updateMaxScrollPosition();
+ void updateMaxScrollOffset();
void trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, const LayerList& renderSurfaceLayerList);
// Returns false if the frame should not be displayed. This function should
@@ -331,7 +330,7 @@ private:
// If this is true, it is necessary to traverse the layer tree ticking the animators.
bool m_needsAnimateLayers;
bool m_pinchGestureActive;
- IntPoint m_previousPinchAnchor;
+ gfx::Point 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 f6c2bff..6613dbf 100644
--- a/cc/layer_tree_host_impl_unittest.cc
+++ b/cc/layer_tree_host_impl_unittest.cc
@@ -10,6 +10,7 @@
#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"
@@ -40,6 +41,7 @@
#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>
@@ -122,20 +124,19 @@ public:
static void expectClearedScrollDeltasRecursive(LayerImpl* layer)
{
- ASSERT_EQ(layer->scrollDelta(), IntSize());
+ ASSERT_EQ(layer->scrollDelta(), gfx::Vector2d());
for (size_t i = 0; i < layer->children().size(); ++i)
expectClearedScrollDeltasRecursive(layer->children()[i]);
}
- static void expectContains(const ScrollAndScaleSet& scrollInfo, int id, const IntSize& scrollDelta)
+ static void expectContains(const ScrollAndScaleSet& scrollInfo, int id, const gfx::Vector2d& scrollDelta)
{
int timesEncountered = 0;
for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) {
if (scrollInfo.scrolls[i].layerId != id)
continue;
- EXPECT_EQ(scrollDelta.width(), scrollInfo.scrolls[i].scrollDelta.width());
- EXPECT_EQ(scrollDelta.height(), scrollInfo.scrolls[i].scrollDelta.height());
+ EXPECT_VECTOR_EQ(scrollDelta, scrollInfo.scrolls[i].scrollDelta);
timesEncountered++;
}
@@ -146,8 +147,8 @@ public:
{
scoped_ptr<LayerImpl> root = LayerImpl::create(1);
root->setScrollable(true);
- root->setScrollPosition(IntPoint(0, 0));
- root->setMaxScrollPosition(cc::IntSize(contentSize));
+ root->setScrollOffset(gfx::Vector2d(0, 0));
+ root->setMaxScrollOffset(gfx::Vector2d(contentSize.width(), contentSize.height()));
root->setBounds(contentSize);
root->setContentBounds(contentSize);
root->setPosition(gfx::PointF(0, 0));
@@ -170,7 +171,7 @@ public:
layer->setDrawsContent(true);
layer->setBounds(size);
layer->setContentBounds(size);
- layer->setMaxScrollPosition(IntSize(size.width() * 2, size.height() * 2));
+ layer->setMaxScrollOffset(gfx::Vector2d(size.width() * 2, size.height() * 2));
return layer.Pass();
}
@@ -299,13 +300,13 @@ TEST_P(LayerTreeHostImplTest, scrollDeltaTreeButNoChanges)
TEST_P(LayerTreeHostImplTest, scrollDeltaRepeatedScrolls)
{
- IntPoint scrollPosition(20, 30);
- IntSize scrollDelta(11, -15);
+ gfx::Vector2d scrollOffset(20, 30);
+ gfx::Vector2d scrollDelta(11, -15);
{
scoped_ptr<LayerImpl> root = LayerImpl::create(1);
- root->setScrollPosition(scrollPosition);
+ root->setScrollOffset(scrollOffset);
root->setScrollable(true);
- root->setMaxScrollPosition(IntSize(100, 100));
+ root->setMaxScrollOffset(gfx::Vector2d(100, 100));
root->scrollBy(scrollDelta);
m_hostImpl->setRootLayer(root.Pass());
}
@@ -315,17 +316,17 @@ TEST_P(LayerTreeHostImplTest, scrollDeltaRepeatedScrolls)
scrollInfo = m_hostImpl->processScrollDeltas();
ASSERT_EQ(scrollInfo->scrolls.size(), 1u);
- EXPECT_EQ(root->sentScrollDelta(), scrollDelta);
+ EXPECT_VECTOR_EQ(root->sentScrollDelta(), scrollDelta);
expectContains(*scrollInfo, root->id(), scrollDelta);
- IntSize scrollDelta2(-5, 27);
+ gfx::Vector2d scrollDelta2(-5, 27);
root->scrollBy(scrollDelta2);
scrollInfo = m_hostImpl->processScrollDeltas();
ASSERT_EQ(scrollInfo->scrolls.size(), 1u);
- EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2);
+ EXPECT_VECTOR_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2);
expectContains(*scrollInfo, root->id(), scrollDelta + scrollDelta2);
- root->scrollBy(IntSize());
+ root->scrollBy(gfx::Vector2d());
scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2);
}
@@ -337,7 +338,7 @@ TEST_P(LayerTreeHostImplTest, scrollRootCallsCommitAndRedraw)
initializeRendererAndDrawFrame();
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
- m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10));
+ m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10));
m_hostImpl->scrollEnd();
EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit);
@@ -379,7 +380,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.
- IntSize scrollDelta(0, 10);
+ gfx::Vector2d scrollDelta(0, 10);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd();
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
@@ -442,10 +443,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(), IntSize(0, 10));
+ m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10));
m_hostImpl->scrollEnd();
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Gesture), InputHandlerClient::ScrollStarted);
- m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10));
+ m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10));
m_hostImpl->scrollEnd();
}
@@ -461,14 +462,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(), IntSize(0, 1));
+ m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(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, maxScrollPositionChangedByDeviceScaleFactor)
+TEST_P(LayerTreeHostImplTest, maxScrollOffsetChangedByDeviceScaleFactor)
{
setupScrollAndContentsLayers(gfx::Size(100, 100));
@@ -477,12 +478,12 @@ TEST_P(LayerTreeHostImplTest, maxScrollPositionChangedByDeviceScaleFactor)
gfx::Size deviceViewport(gfx::ToFlooredSize(layoutViewport.Scale(deviceScaleFactor)));
m_hostImpl->setViewportSize(layoutViewport, deviceViewport);
m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
- EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(25, 25));
+ EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), gfx::Vector2d(25, 25));
deviceScaleFactor = 1;
m_hostImpl->setViewportSize(layoutViewport, layoutViewport);
m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
- EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(75, 75));
+ EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), gfx::Vector2d(75, 75));
}
TEST_P(LayerTreeHostImplTest, implPinchZoom)
@@ -505,11 +506,11 @@ TEST_P(LayerTreeHostImplTest, implPinchZoom)
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform);
- scrollLayer->setScrollDelta(IntSize());
+ scrollLayer->setScrollDelta(gfx::Vector2d());
float pageScaleDelta = 2;
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50));
+ m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50));
m_hostImpl->pinchGestureEnd();
EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit);
@@ -517,7 +518,7 @@ TEST_P(LayerTreeHostImplTest, implPinchZoom)
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
- EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(50, 50));
+ EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), gfx::Vector2d(50, 50));
}
// Scrolling after a pinch gesture should always be in local space. The scroll deltas do not
@@ -525,14 +526,14 @@ TEST_P(LayerTreeHostImplTest, implPinchZoom)
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform);
- scrollLayer->setScrollDelta(IntSize());
+ scrollLayer->setScrollDelta(gfx::Vector2d());
float pageScaleDelta = 2;
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0));
+ m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0));
m_hostImpl->pinchGestureEnd();
- IntSize scrollDelta(0, 10);
+ gfx::Vector2d 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();
@@ -559,11 +560,11 @@ TEST_P(LayerTreeHostImplTest, pinchGesture)
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform);
- scrollLayer->setScrollDelta(IntSize());
+ scrollLayer->setScrollDelta(gfx::Vector2d());
float pageScaleDelta = 2;
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50));
+ m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50));
m_hostImpl->pinchGestureEnd();
EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit);
@@ -576,11 +577,11 @@ TEST_P(LayerTreeHostImplTest, pinchGesture)
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform);
- scrollLayer->setScrollDelta(IntSize());
+ scrollLayer->setScrollDelta(gfx::Vector2d());
float pageScaleDelta = 10;
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50));
+ m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50));
m_hostImpl->pinchGestureEnd();
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
@@ -591,12 +592,12 @@ TEST_P(LayerTreeHostImplTest, pinchGesture)
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform);
- scrollLayer->setScrollDelta(IntSize());
- scrollLayer->setScrollPosition(IntPoint(50, 50));
+ scrollLayer->setScrollDelta(gfx::Vector2d());
+ scrollLayer->setScrollOffset(gfx::Vector2d(50, 50));
float pageScaleDelta = 0.1f;
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0));
+ m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0));
m_hostImpl->pinchGestureEnd();
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
@@ -604,7 +605,7 @@ TEST_P(LayerTreeHostImplTest, pinchGesture)
if (!Settings::pageScalePinchZoomEnabled()) {
// Pushed to (0,0) via clamping against contents layer size.
- expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50));
+ expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50));
} else {
EXPECT_TRUE(scrollInfo->scrolls.empty());
}
@@ -614,18 +615,18 @@ TEST_P(LayerTreeHostImplTest, pinchGesture)
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform);
- scrollLayer->setScrollDelta(IntSize());
- scrollLayer->setScrollPosition(IntPoint(20, 20));
+ scrollLayer->setScrollDelta(gfx::Vector2d());
+ scrollLayer->setScrollOffset(gfx::Vector2d(20, 20));
float pageScaleDelta = 1;
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(10, 10));
- m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(20, 20));
+ m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10));
+ m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20));
m_hostImpl->pinchGestureEnd();
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
- expectContains(*scrollInfo, scrollLayer->id(), IntSize(-10, -10));
+ expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-10, -10));
}
}
@@ -650,9 +651,9 @@ TEST_P(LayerTreeHostImplTest, pageScaleAnimation)
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform);
- scrollLayer->setScrollPosition(IntPoint(50, 50));
+ scrollLayer->setScrollOffset(gfx::Vector2d(50, 50));
- m_hostImpl->startPageScaleAnimation(IntSize(0, 0), false, 2, startTime, duration);
+ m_hostImpl->startPageScaleAnimation(gfx::Vector2d(0, 0), false, 2, startTime, duration);
m_hostImpl->animate(halfwayThroughAnimation, base::Time());
EXPECT_TRUE(m_didRequestRedraw);
m_hostImpl->animate(endTime, base::Time());
@@ -660,16 +661,16 @@ TEST_P(LayerTreeHostImplTest, pageScaleAnimation)
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, 2);
- expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50));
+ expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50));
}
// Anchor zoom-out
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform);
- scrollLayer->setScrollPosition(IntPoint(50, 50));
+ scrollLayer->setScrollOffset(gfx::Vector2d(50, 50));
- m_hostImpl->startPageScaleAnimation(IntSize(25, 25), true, minPageScale, startTime, duration);
+ m_hostImpl->startPageScaleAnimation(gfx::Vector2d(25, 25), true, minPageScale, startTime, duration);
m_hostImpl->animate(endTime, base::Time());
EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit);
@@ -677,7 +678,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(), IntSize(-50, -50));
+ expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50));
}
}
@@ -699,7 +700,7 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming)
const float zoomInDelta = 2;
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(zoomInDelta, IntPoint(50, 50));
+ m_hostImpl->pinchGestureUpdate(zoomInDelta, gfx::Point(50, 50));
// Because we are pinch zooming in, we shouldn't get any scroll or page
// scale deltas.
@@ -712,7 +713,7 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming)
scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, zoomInDelta);
if (!Settings::pageScalePinchZoomEnabled()) {
- expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
+ expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25));
} else {
EXPECT_TRUE(scrollInfo->scrolls.empty());
}
@@ -724,14 +725,14 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming)
const float zoomOutDelta = 0.75;
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(zoomOutDelta, IntPoint(50, 50));
+ m_hostImpl->pinchGestureUpdate(zoomOutDelta, gfx::Point(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(), IntSize(0, 0));
+ expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(0, 0));
} else {
EXPECT_EQ(scrollInfo->pageScaleDelta, 1);
EXPECT_TRUE(scrollInfo->scrolls.empty());
@@ -742,10 +743,10 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming)
scrollInfo = m_hostImpl->processScrollDeltas();
if (Settings::pageScalePinchZoomEnabled()) {
EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
- expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
+ expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25));
} else {
EXPECT_EQ(scrollInfo->pageScaleDelta, zoomOutDelta);
- expectContains(*scrollInfo, scrollLayer->id(), IntSize(8, 8));
+ expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(8, 8));
}
}
}
@@ -768,7 +769,7 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPage
// Start a page scale animation.
const float pageScaleDelta = 2;
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- m_hostImpl->startPageScaleAnimation(IntSize(50, 50), false, pageScaleDelta, startTime, duration);
+ m_hostImpl->startPageScaleAnimation(gfx::Vector2d(50, 50), false, pageScaleDelta, startTime, duration);
// We should immediately get the final zoom and scroll values for the
// animation.
@@ -777,14 +778,14 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPage
if (!Settings::pageScalePinchZoomEnabled()) {
EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
- expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
+ expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25));
} else {
EXPECT_EQ(scrollInfo->pageScaleDelta, 1);
EXPECT_TRUE(scrollInfo->scrolls.empty());
}
// Scrolling during the animation is ignored.
- const IntSize scrollDelta(0, 10);
+ const gfx::Vector2d 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();
@@ -794,7 +795,7 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPage
m_hostImpl->animate(endTime, base::Time());
scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
- expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
+ expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25));
}
class DidDrawCheckLayer : public TiledLayerImpl {
@@ -1049,7 +1050,7 @@ TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot)
scoped_ptr<LayerImpl> scrollLayer = LayerImpl::create(2);
scrollLayer->setScrollable(true);
- scrollLayer->setMaxScrollPosition(cc::IntSize(surfaceSize));
+ scrollLayer->setMaxScrollOffset(gfx::Vector2d(surfaceSize.width(), surfaceSize.height()));
scrollLayer->setBounds(surfaceSize);
scrollLayer->setContentBounds(surfaceSize);
scrollLayer->setPosition(gfx::PointF(0, 0));
@@ -1061,7 +1062,7 @@ TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot)
initializeRendererAndDrawFrame();
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
- m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10));
+ m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10));
m_hostImpl->scrollEnd();
EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit);
@@ -1079,7 +1080,7 @@ TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw)
initializeRendererAndDrawFrame();
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
- m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10));
+ m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10));
m_hostImpl->scrollEnd();
EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit);
@@ -1150,9 +1151,9 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread)
m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
initializeRendererAndDrawFrame();
- IntSize scrollDelta(0, 10);
- IntSize expectedScrollDelta(scrollDelta);
- IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition());
+ gfx::Vector2d scrollDelta(0, 10);
+ gfx::Vector2d expectedScrollDelta(scrollDelta);
+ gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd();
@@ -1162,13 +1163,13 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread)
if (!Settings::pageScalePinchZoomEnabled()) {
// The scale should apply to the scroll delta.
- expectedScrollDelta.scale(pageScale);
+ expectedScrollDelta = gfx::ToFlooredVector2d(cc::ScaleVector2d(expectedScrollDelta, 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()->maxScrollPosition(), expectedMaxScroll);
+ EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
// The page scale delta remains constant because the impl thread did not scale.
EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix());
@@ -1184,16 +1185,16 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
initializeRendererAndDrawFrame();
- IntSize scrollDelta(0, 10);
- IntSize expectedScrollDelta(scrollDelta);
- IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition());
+ gfx::Vector2d scrollDelta(0, 10);
+ gfx::Vector2d expectedScrollDelta(scrollDelta);
+ gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
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, IntPoint());
+ m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
m_hostImpl->pinchGestureEnd();
m_hostImpl->updateRootScrollLayerImplTransform();
@@ -1202,7 +1203,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()->maxScrollPosition(), expectedMaxScroll);
+ EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
// The page scale delta should match the new scale on the impl side.
WebTransformationMatrix expectedScale;
@@ -1231,7 +1232,7 @@ TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
// Set new page scale on impl thread by pinching.
m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint());
+ m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point());
m_hostImpl->pinchGestureEnd();
m_hostImpl->updateRootScrollLayerImplTransform();
@@ -1271,9 +1272,9 @@ TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
LayerImpl* child = m_hostImpl->rootLayer()->children()[0];
- IntSize scrollDelta(0, 10);
- IntSize expectedScrollDelta(scrollDelta);
- IntSize expectedMaxScroll(child->maxScrollPosition());
+ gfx::Vector2d scrollDelta(0, 10);
+ gfx::Vector2d expectedScrollDelta(scrollDelta);
+ gfx::Vector2d expectedMaxScroll(child->maxScrollOffset());
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd();
@@ -1285,13 +1286,13 @@ TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
if (!Settings::pageScalePinchZoomEnabled()) {
// The scale should apply to the scroll delta.
- expectedScrollDelta.scale(pageScale);
+ expectedScrollDelta = gfx::ToFlooredVector2d(cc::ScaleVector2d(expectedScrollDelta, pageScale));
}
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta);
// The scroll range should not have changed.
- EXPECT_EQ(child->maxScrollPosition(), expectedMaxScroll);
+ EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll);
// The page scale delta remains constant because the impl thread did not scale.
WebTransformationMatrix identityTransform;
@@ -1307,10 +1308,10 @@ TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit)
scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize);
- grandChild->setScrollPosition(IntPoint(0, 5));
+ grandChild->setScrollOffset(gfx::Vector2d(0, 5));
scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize);
- child->setScrollPosition(IntPoint(3, 0));
+ child->setScrollOffset(gfx::Vector2d(3, 0));
child->addChild(grandChild.Pass());
root->addChild(child.Pass());
@@ -1318,7 +1319,7 @@ TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit)
m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
initializeRendererAndDrawFrame();
{
- IntSize scrollDelta(-8, -7);
+ gfx::Vector2d 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();
@@ -1328,10 +1329,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(), IntSize(0, -5));
+ expectContains(*scrollInfo.get(), grandChild->id(), gfx::Vector2d(0, -5));
// The child should have only scrolled on the other axis.
- expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0));
+ expectContains(*scrollInfo.get(), child->id(), gfx::Vector2d(-3, 0));
}
}
@@ -1350,7 +1351,7 @@ TEST_P(LayerTreeHostImplTest, scrollEventBubbling)
m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
initializeRendererAndDrawFrame();
{
- IntSize scrollDelta(0, 4);
+ gfx::Vector2d 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();
@@ -1392,18 +1393,18 @@ TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer)
initializeRendererAndDrawFrame();
// Scroll to the right in screen coordinates with a gesture.
- IntSize gestureScrollDelta(10, 0);
+ gfx::Vector2d 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(), IntSize(0, gestureScrollDelta.width()));
+ expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector2d(0, gestureScrollDelta.x()));
// Reset and scroll down with the wheel.
- m_hostImpl->rootLayer()->setScrollDelta(FloatSize());
- IntSize wheelScrollDelta(0, 10);
+ m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF());
+ gfx::Vector2d 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();
@@ -1428,7 +1429,7 @@ TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
child->setTransform(rotateTransform);
// Only allow vertical scrolling.
- child->setMaxScrollPosition(IntSize(0, child->contentBounds().height()));
+ child->setMaxScrollOffset(gfx::Vector2d(0, child->contentBounds().height()));
m_hostImpl->rootLayer()->addChild(child.Pass());
gfx::Size surfaceSize(50, 50);
@@ -1437,14 +1438,14 @@ TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
{
// Scroll down in screen coordinates with a gesture.
- IntSize gestureScrollDelta(0, 10);
+ gfx::Vector2d 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.
- IntSize expectedScrollDelta(0, gestureScrollDelta.height() * cosf(deg2rad(childLayerAngle)));
+ gfx::Vector2d expectedScrollDelta(0, gestureScrollDelta.y() * cosf(deg2rad(childLayerAngle)));
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta);
@@ -1455,21 +1456,21 @@ TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
{
// Now reset and scroll the same amount horizontally.
- m_hostImpl->rootLayer()->children()[1]->setScrollDelta(FloatSize());
- IntSize gestureScrollDelta(10, 0);
+ m_hostImpl->rootLayer()->children()[1]->setScrollDelta(gfx::Vector2dF());
+ gfx::Vector2d 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.
- IntSize expectedScrollDelta(0, -gestureScrollDelta.width() * sinf(deg2rad(childLayerAngle)));
+ gfx::Vector2d expectedScrollDelta(0, -gestureScrollDelta.x() * 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.
- IntSize expectedRootScrollDelta(gestureScrollDelta.width() * pow(cosf(deg2rad(childLayerAngle)), 2), 0);
+ gfx::Vector2d expectedRootScrollDelta(gestureScrollDelta.x() * pow(cosf(deg2rad(childLayerAngle)), 2), 0);
expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedRootScrollDelta);
}
}
@@ -1489,18 +1490,18 @@ TEST_P(LayerTreeHostImplTest, scrollScaledLayer)
initializeRendererAndDrawFrame();
// Scroll down in screen coordinates with a gesture.
- IntSize scrollDelta(0, 10);
+ gfx::Vector2d 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(), IntSize(0, scrollDelta.height() / scale));
+ expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector2d(0, scrollDelta.y() / scale));
// Reset and scroll down with the wheel.
- m_hostImpl->rootLayer()->setScrollDelta(FloatSize());
- IntSize wheelScrollDelta(0, 10);
+ m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF());
+ gfx::Vector2d 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 704158e..893ebee 100644
--- a/cc/layer_tree_host_unittest.cc
+++ b/cc/layer_tree_host_unittest.cc
@@ -24,6 +24,7 @@
#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>
@@ -834,8 +835,8 @@ SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAnimationFinishedEvents)
class LayerTreeHostTestScrollSimple : public LayerTreeHostTest {
public:
LayerTreeHostTestScrollSimple()
- : m_initialScroll(IntPoint(10, 20))
- , m_secondScroll(IntPoint(40, 5))
+ : m_initialScroll(10, 20)
+ , m_secondScroll(40, 5)
, m_scrollAmount(2, -1)
, m_scrolls(0)
{
@@ -844,7 +845,7 @@ public:
virtual void beginTest() OVERRIDE
{
m_layerTreeHost->rootLayer()->setScrollable(true);
- m_layerTreeHost->rootLayer()->setScrollPosition(m_initialScroll);
+ m_layerTreeHost->rootLayer()->setScrollOffset(m_initialScroll);
postSetNeedsCommitToMainThread();
}
@@ -852,39 +853,39 @@ public:
{
Layer* root = m_layerTreeHost->rootLayer();
if (!m_layerTreeHost->commitNumber())
- EXPECT_EQ(root->scrollPosition(), m_initialScroll);
+ EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll);
else {
- EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount);
+ EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll + m_scrollAmount);
// Pretend like Javascript updated the scroll position itself.
- root->setScrollPosition(m_secondScroll);
+ root->setScrollOffset(m_secondScroll);
}
}
virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
{
LayerImpl* root = impl->rootLayer();
- EXPECT_EQ(root->scrollDelta(), IntSize());
+ EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d());
root->setScrollable(true);
- root->setMaxScrollPosition(IntSize(100, 100));
+ root->setMaxScrollOffset(gfx::Vector2d(100, 100));
root->scrollBy(m_scrollAmount);
if (!impl->sourceFrameNumber()) {
- EXPECT_EQ(root->scrollPosition(), m_initialScroll);
- EXPECT_EQ(root->scrollDelta(), m_scrollAmount);
+ EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll);
+ EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount);
postSetNeedsCommitToMainThread();
} else if (impl->sourceFrameNumber() == 1) {
- EXPECT_EQ(root->scrollPosition(), m_secondScroll);
- EXPECT_EQ(root->scrollDelta(), m_scrollAmount);
+ EXPECT_VECTOR_EQ(root->scrollOffset(), m_secondScroll);
+ EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount);
endTest();
}
}
- virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE
+ virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
{
- IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition();
- m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta);
+ gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset();
+ m_layerTreeHost->rootLayer()->setScrollOffset(offset + scrollDelta);
m_scrolls++;
}
@@ -893,9 +894,9 @@ public:
EXPECT_EQ(1, m_scrolls);
}
private:
- IntPoint m_initialScroll;
- IntPoint m_secondScroll;
- IntSize m_scrollAmount;
+ gfx::Vector2d m_initialScroll;
+ gfx::Vector2d m_secondScroll;
+ gfx::Vector2d m_scrollAmount;
int m_scrolls;
};
@@ -907,7 +908,7 @@ TEST_F(LayerTreeHostTestScrollSimple, runMultiThread)
class LayerTreeHostTestScrollMultipleRedraw : public LayerTreeHostTest {
public:
LayerTreeHostTestScrollMultipleRedraw()
- : m_initialScroll(IntPoint(40, 10))
+ : m_initialScroll(40, 10)
, m_scrollAmount(-3, 17)
, m_scrolls(0)
{
@@ -916,7 +917,7 @@ public:
virtual void beginTest() OVERRIDE
{
m_layerTreeHost->rootLayer()->setScrollable(true);
- m_layerTreeHost->rootLayer()->setScrollPosition(m_initialScroll);
+ m_layerTreeHost->rootLayer()->setScrollOffset(m_initialScroll);
postSetNeedsCommitToMainThread();
}
@@ -924,48 +925,48 @@ public:
{
Layer* root = m_layerTreeHost->rootLayer();
if (!m_layerTreeHost->commitNumber())
- EXPECT_EQ(root->scrollPosition(), m_initialScroll);
+ EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll);
else if (m_layerTreeHost->commitNumber() == 1)
- EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount + m_scrollAmount);
+ EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll + m_scrollAmount + m_scrollAmount);
else if (m_layerTreeHost->commitNumber() == 2)
- EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount + m_scrollAmount);
+ EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll + m_scrollAmount + m_scrollAmount);
}
virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
{
LayerImpl* root = impl->rootLayer();
root->setScrollable(true);
- root->setMaxScrollPosition(IntSize(100, 100));
+ root->setMaxScrollOffset(gfx::Vector2d(100, 100));
if (!impl->sourceFrameNumber() && impl->sourceAnimationFrameNumber() == 1) {
// First draw after first commit.
- EXPECT_EQ(root->scrollDelta(), IntSize());
+ EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d());
root->scrollBy(m_scrollAmount);
- EXPECT_EQ(root->scrollDelta(), m_scrollAmount);
+ EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount);
- EXPECT_EQ(root->scrollPosition(), m_initialScroll);
+ EXPECT_VECTOR_EQ(root->scrollOffset(), 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_EQ(root->scrollDelta(), m_scrollAmount + m_scrollAmount);
+ EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount + m_scrollAmount);
- EXPECT_EQ(root->scrollPosition(), m_initialScroll);
+ EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll);
postSetNeedsCommitToMainThread();
} else if (impl->sourceFrameNumber() == 1) {
// Third or later draw after second commit.
EXPECT_GE(impl->sourceAnimationFrameNumber(), 3);
- EXPECT_EQ(root->scrollDelta(), IntSize());
- EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount + m_scrollAmount);
+ EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d());
+ EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll + m_scrollAmount + m_scrollAmount);
endTest();
}
}
- virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE
+ virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
{
- IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition();
- m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta);
+ gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset();
+ m_layerTreeHost->rootLayer()->setScrollOffset(offset + scrollDelta);
m_scrolls++;
}
@@ -974,8 +975,8 @@ public:
EXPECT_EQ(1, m_scrolls);
}
private:
- IntPoint m_initialScroll;
- IntSize m_scrollAmount;
+ gfx::Vector2d m_initialScroll;
+ gfx::Vector2d m_scrollAmount;
int m_scrolls;
};
@@ -1029,20 +1030,20 @@ public:
virtual void beginTest() OVERRIDE
{
m_layerTreeHost->rootLayer()->setScrollable(true);
- m_layerTreeHost->rootLayer()->setScrollPosition(IntPoint());
+ m_layerTreeHost->rootLayer()->setScrollOffset(gfx::Vector2d());
postSetNeedsCommitToMainThread();
postSetNeedsRedrawToMainThread();
}
void requestStartPageScaleAnimation()
{
- layerTreeHost()->startPageScaleAnimation(IntSize(), false, 1.25, base::TimeDelta());
+ layerTreeHost()->startPageScaleAnimation(gfx::Vector2d(), false, 1.25, base::TimeDelta());
}
virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
{
impl->rootLayer()->setScrollable(true);
- impl->rootLayer()->setScrollPosition(IntPoint());
+ impl->rootLayer()->setScrollOffset(gfx::Vector2d());
impl->setPageScaleFactorAndLimits(impl->pageScaleFactor(), 0.5, 2);
// We request animation only once.
@@ -1052,10 +1053,10 @@ public:
}
}
- virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE
+ virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
{
- IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition();
- m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta);
+ gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset();
+ m_layerTreeHost->rootLayer()->setScrollOffset(offset + scrollDelta);
m_layerTreeHost->setPageScaleFactorAndLimits(scale, 0.5, 2);
}
@@ -2090,36 +2091,36 @@ public:
virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
{
LayerImpl* root = impl->rootLayer();
- root->setMaxScrollPosition(IntSize(100, 100));
+ root->setMaxScrollOffset(gfx::Vector2d(100, 100));
// Check that a fractional scroll delta is correctly accumulated over multiple commits.
if (!impl->sourceFrameNumber()) {
- EXPECT_EQ(root->scrollPosition(), IntPoint(0, 0));
- EXPECT_EQ(root->scrollDelta(), FloatSize(0, 0));
+ EXPECT_VECTOR_EQ(root->scrollOffset(), gfx::Vector2d(0, 0));
+ EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d(0, 0));
postSetNeedsCommitToMainThread();
} else if (impl->sourceFrameNumber() == 1) {
- EXPECT_EQ(root->scrollPosition(), flooredIntPoint(m_scrollAmount));
- EXPECT_EQ(root->scrollDelta(), FloatSize(fmod(m_scrollAmount.width(), 1), 0));
+ EXPECT_VECTOR_EQ(root->scrollOffset(), gfx::ToFlooredVector2d(m_scrollAmount));
+ EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2dF(fmod(m_scrollAmount.x(), 1), 0));
postSetNeedsCommitToMainThread();
} else if (impl->sourceFrameNumber() == 2) {
- EXPECT_EQ(root->scrollPosition(), flooredIntPoint(m_scrollAmount + m_scrollAmount));
- EXPECT_EQ(root->scrollDelta(), FloatSize(fmod(2 * m_scrollAmount.width(), 1), 0));
+ 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));
endTest();
}
root->scrollBy(m_scrollAmount);
}
- virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE
+ virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
{
- IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition();
- m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta);
+ gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset();
+ m_layerTreeHost->rootLayer()->setScrollOffset(offset + scrollDelta);
}
virtual void afterTest() OVERRIDE
{
}
private:
- FloatSize m_scrollAmount;
+ gfx::Vector2dF m_scrollAmount;
};
TEST_F(LayerTreeHostTestFractionalScroll, runMultiThread)
@@ -2223,8 +2224,8 @@ class LayerTreeHostTestScrollChildLayer : public LayerTreeHostTest, public WebLa
public:
LayerTreeHostTestScrollChildLayer(float deviceScaleFactor)
: m_deviceScaleFactor(deviceScaleFactor)
- , m_initialScroll(IntPoint(10, 20))
- , m_secondScroll(IntPoint(40, 5))
+ , m_initialScroll(10, 20)
+ , m_secondScroll(40, 5)
, m_scrollAmount(2, -1)
, m_rootScrolls(0)
{
@@ -2246,7 +2247,7 @@ public:
m_rootScrollLayer->setIsDrawable(true);
m_rootScrollLayer->setScrollable(true);
- m_rootScrollLayer->setMaxScrollPosition(IntSize(100, 100));
+ m_rootScrollLayer->setMaxScrollOffset(gfx::Vector2d(100, 100));
m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer);
m_childLayer = ContentLayer::create(&m_mockDelegate);
@@ -2260,42 +2261,42 @@ public:
m_childLayer->setIsDrawable(true);
m_childLayer->setScrollable(true);
- m_childLayer->setMaxScrollPosition(IntSize(100, 100));
+ m_childLayer->setMaxScrollOffset(gfx::Vector2d(100, 100));
m_rootScrollLayer->addChild(m_childLayer);
- m_childLayer->setScrollPosition(m_initialScroll);
+ m_childLayer->setScrollOffset(m_initialScroll);
postSetNeedsCommitToMainThread();
}
virtual void didScroll() OVERRIDE
{
- m_finalScrollPosition = m_childLayer->scrollPosition();
+ m_finalScrollOffset = m_childLayer->scrollOffset();
}
- virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE
+ virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
{
- IntPoint position = m_rootScrollLayer->scrollPosition();
- m_rootScrollLayer->setScrollPosition(position + scrollDelta);
+ gfx::Vector2d offset = m_rootScrollLayer->scrollOffset();
+ m_rootScrollLayer->setScrollOffset(offset + scrollDelta);
m_rootScrolls++;
}
virtual void layout() OVERRIDE
{
- EXPECT_EQ(IntPoint(), m_rootScrollLayer->scrollPosition());
+ EXPECT_VECTOR_EQ(gfx::Vector2d(), m_rootScrollLayer->scrollOffset());
switch (m_layerTreeHost->commitNumber()) {
case 0:
- EXPECT_POINT_EQ(m_initialScroll, m_childLayer->scrollPosition());
+ EXPECT_VECTOR_EQ(m_initialScroll, m_childLayer->scrollOffset());
break;
case 1:
- EXPECT_POINT_EQ(m_initialScroll + m_scrollAmount, m_childLayer->scrollPosition());
+ EXPECT_VECTOR_EQ(m_initialScroll + m_scrollAmount, m_childLayer->scrollOffset());
// Pretend like Javascript updated the scroll position itself.
- m_childLayer->setScrollPosition(m_secondScroll);
+ m_childLayer->setScrollOffset(m_secondScroll);
break;
case 2:
- EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, m_childLayer->scrollPosition());
+ EXPECT_VECTOR_EQ(m_secondScroll + m_scrollAmount, m_childLayer->scrollOffset());
break;
}
}
@@ -2306,8 +2307,8 @@ public:
LayerImpl* rootScrollLayer = root->children()[0];
LayerImpl* childLayer = rootScrollLayer->children()[0];
- EXPECT_SIZE_EQ(root->scrollDelta(), IntSize());
- EXPECT_SIZE_EQ(rootScrollLayer->scrollDelta(), IntSize());
+ EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d());
+ EXPECT_VECTOR_EQ(rootScrollLayer->scrollDelta(), gfx::Vector2d());
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());
@@ -2320,8 +2321,8 @@ public:
impl->scrollBy(gfx::Point(), m_scrollAmount);
impl->scrollEnd();
- EXPECT_POINT_EQ(m_initialScroll, childLayer->scrollPosition());
- EXPECT_SIZE_EQ(m_scrollAmount, childLayer->scrollDelta());
+ EXPECT_VECTOR_EQ(m_initialScroll, childLayer->scrollOffset());
+ EXPECT_VECTOR_EQ(m_scrollAmount, childLayer->scrollDelta());
break;
case 1:
// Wheel scroll on impl thread.
@@ -2329,12 +2330,12 @@ public:
impl->scrollBy(gfx::Point(), m_scrollAmount);
impl->scrollEnd();
- EXPECT_POINT_EQ(m_secondScroll, childLayer->scrollPosition());
- EXPECT_SIZE_EQ(m_scrollAmount, childLayer->scrollDelta());
+ EXPECT_VECTOR_EQ(m_secondScroll, childLayer->scrollOffset());
+ EXPECT_VECTOR_EQ(m_scrollAmount, childLayer->scrollDelta());
break;
case 2:
- EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, childLayer->scrollPosition());
- EXPECT_SIZE_EQ(IntSize(0, 0), childLayer->scrollDelta());
+ EXPECT_VECTOR_EQ(m_secondScroll + m_scrollAmount, childLayer->scrollOffset());
+ EXPECT_VECTOR_EQ(gfx::Vector2d(0, 0), childLayer->scrollDelta());
endTest();
}
@@ -2343,16 +2344,16 @@ public:
virtual void afterTest() OVERRIDE
{
EXPECT_EQ(0, m_rootScrolls);
- EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, m_finalScrollPosition);
+ EXPECT_VECTOR_EQ(m_secondScroll + m_scrollAmount, m_finalScrollOffset);
}
private:
float m_deviceScaleFactor;
- IntPoint m_initialScroll;
- IntPoint m_secondScroll;
- IntSize m_scrollAmount;
+ gfx::Vector2d m_initialScroll;
+ gfx::Vector2d m_secondScroll;
+ gfx::Vector2d m_scrollAmount;
int m_rootScrolls;
- IntPoint m_finalScrollPosition;
+ gfx::Vector2d m_finalScrollOffset;
MockContentLayerClient m_mockDelegate;
scoped_refptr<Layer> m_rootScrollLayer;
@@ -2383,8 +2384,8 @@ class LayerTreeHostTestScrollRootScrollLayer : public LayerTreeHostTest {
public:
LayerTreeHostTestScrollRootScrollLayer(float deviceScaleFactor)
: m_deviceScaleFactor(deviceScaleFactor)
- , m_initialScroll(IntPoint(10, 20))
- , m_secondScroll(IntPoint(40, 5))
+ , m_initialScroll(10, 20)
+ , m_secondScroll(40, 5)
, m_scrollAmount(2, -1)
, m_rootScrolls(0)
{
@@ -2399,25 +2400,25 @@ public:
m_layerTreeHost->setDeviceScaleFactor(m_deviceScaleFactor);
m_rootScrollLayer = ContentLayer::create(&m_mockDelegate);
- m_rootScrollLayer->setBounds(IntSize(110, 110));
+ m_rootScrollLayer->setBounds(gfx::Size(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->setMaxScrollPosition(IntSize(100, 100));
+ m_rootScrollLayer->setMaxScrollOffset(gfx::Vector2d(100, 100));
m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer);
- m_rootScrollLayer->setScrollPosition(m_initialScroll);
+ m_rootScrollLayer->setScrollOffset(m_initialScroll);
postSetNeedsCommitToMainThread();
}
- virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE
+ virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
{
- IntPoint position = m_rootScrollLayer->scrollPosition();
- m_rootScrollLayer->setScrollPosition(position + scrollDelta);
+ gfx::Vector2d offset = m_rootScrollLayer->scrollOffset();
+ m_rootScrollLayer->setScrollOffset(offset + scrollDelta);
m_rootScrolls++;
}
@@ -2425,16 +2426,16 @@ public:
{
switch (m_layerTreeHost->commitNumber()) {
case 0:
- EXPECT_POINT_EQ(m_initialScroll, m_rootScrollLayer->scrollPosition());
+ EXPECT_VECTOR_EQ(m_initialScroll, m_rootScrollLayer->scrollOffset());
break;
case 1:
- EXPECT_POINT_EQ(m_initialScroll + m_scrollAmount, m_rootScrollLayer->scrollPosition());
+ EXPECT_VECTOR_EQ(m_initialScroll + m_scrollAmount, m_rootScrollLayer->scrollOffset());
// Pretend like Javascript updated the scroll position itself.
- m_rootScrollLayer->setScrollPosition(m_secondScroll);
+ m_rootScrollLayer->setScrollOffset(m_secondScroll);
break;
case 2:
- EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, m_rootScrollLayer->scrollPosition());
+ EXPECT_VECTOR_EQ(m_secondScroll + m_scrollAmount, m_rootScrollLayer->scrollOffset());
break;
}
}
@@ -2444,7 +2445,7 @@ public:
LayerImpl* root = impl->rootLayer();
LayerImpl* rootScrollLayer = root->children()[0];
- EXPECT_SIZE_EQ(root->scrollDelta(), IntSize());
+ EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d());
EXPECT_EQ(rootScrollLayer->bounds().width() * m_deviceScaleFactor, rootScrollLayer->contentBounds().width());
EXPECT_EQ(rootScrollLayer->bounds().height() * m_deviceScaleFactor, rootScrollLayer->contentBounds().height());
@@ -2455,8 +2456,8 @@ public:
impl->scrollBy(gfx::Point(), m_scrollAmount);
impl->scrollEnd();
- EXPECT_POINT_EQ(m_initialScroll, rootScrollLayer->scrollPosition());
- EXPECT_SIZE_EQ(m_scrollAmount, rootScrollLayer->scrollDelta());
+ EXPECT_VECTOR_EQ(m_initialScroll, rootScrollLayer->scrollOffset());
+ EXPECT_VECTOR_EQ(m_scrollAmount, rootScrollLayer->scrollDelta());
break;
case 1:
// Wheel scroll on impl thread.
@@ -2464,12 +2465,12 @@ public:
impl->scrollBy(gfx::Point(), m_scrollAmount);
impl->scrollEnd();
- EXPECT_POINT_EQ(m_secondScroll, rootScrollLayer->scrollPosition());
- EXPECT_SIZE_EQ(m_scrollAmount, rootScrollLayer->scrollDelta());
+ EXPECT_VECTOR_EQ(m_secondScroll, rootScrollLayer->scrollOffset());
+ EXPECT_VECTOR_EQ(m_scrollAmount, rootScrollLayer->scrollDelta());
break;
case 2:
- EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, rootScrollLayer->scrollPosition());
- EXPECT_SIZE_EQ(IntSize(0, 0), rootScrollLayer->scrollDelta());
+ EXPECT_VECTOR_EQ(m_secondScroll + m_scrollAmount, rootScrollLayer->scrollOffset());
+ EXPECT_VECTOR_EQ(gfx::Vector2d(0, 0), rootScrollLayer->scrollDelta());
endTest();
}
@@ -2482,9 +2483,9 @@ public:
private:
float m_deviceScaleFactor;
- IntPoint m_initialScroll;
- IntPoint m_secondScroll;
- IntSize m_scrollAmount;
+ gfx::Vector2d m_initialScroll;
+ gfx::Vector2d m_secondScroll;
+ gfx::Vector2d m_scrollAmount;
int m_rootScrolls;
MockContentLayerClient m_mockDelegate;
diff --git a/cc/layer_unittest.cc b/cc/layer_unittest.cc
index aadf11e..88db65b 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->setScrollPosition(IntPoint(10, 10)));
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollOffset(gfx::Vector2d(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 23fd588..a48dc4e 100644
--- a/cc/math_util.cc
+++ b/cc/math_util.cc
@@ -6,12 +6,14 @@
#include "cc/math_util.h"
-#include "FloatSize.h"
+#include <cmath>
+#include <limits>
+
#include "ui/gfx/quad_f.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/rect_f.h"
-#include <cmath>
+#include "ui/gfx/vector2d_f.h"
#include <public/WebTransformationMatrix.h>
using WebKit::WebTransformationMatrix;
@@ -378,19 +380,24 @@ gfx::Vector2dF MathUtil::computeTransform2dScaleComponents(const WebTransformati
return gfx::Vector2dF(xScale, yScale);
}
-float MathUtil::smallestAngleBetweenVectors(const FloatSize& v1, const FloatSize& v2)
+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 dotProduct = (v1.width() * v2.width() + v1.height() * v2.height()) / (v1.diagonalLength() * v2.diagonalLength());
+ double dotProduct = gfx::DotProduct(v1, v2) / v1.Length() / v2.Length();
// Clamp to compensate for rounding errors.
- dotProduct = std::max(-1.f, std::min(1.f, dotProduct));
- return rad2deg(acosf(dotProduct));
+ dotProduct = std::max(-1.0, std::min(1.0, dotProduct));
+ return static_cast<float>(rad2deg(std::acos(dotProduct)));
}
-FloatSize MathUtil::projectVector(const FloatSize& source, const FloatSize& destination)
+gfx::Vector2dF MathUtil::projectVector(gfx::Vector2dF source, gfx::Vector2dF destination)
{
- float sourceDotDestination = source.width() * destination.width() + source.height() * destination.height();
- float projectedLength = sourceDotDestination / destination.diagonalLengthSquared();
- return FloatSize(projectedLength * destination.width(), projectedLength * destination.height());
+ float projectedLength = gfx::DotProduct(source, destination) / destination.LengthSquared();
+ return gfx::Vector2dF(projectedLength * destination.x(), projectedLength * destination.y());
}
} // namespace cc
diff --git a/cc/math_util.h b/cc/math_util.h
index 7d22c6c..1caf659 100644
--- a/cc/math_util.h
+++ b/cc/math_util.h
@@ -18,12 +18,11 @@ 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)
@@ -104,10 +103,10 @@ public:
// Returns the smallest angle between the given two vectors in degrees. Neither vector is
// assumed to be normalized.
- static float smallestAngleBetweenVectors(const FloatSize&, const FloatSize&);
+ static float smallestAngleBetweenVectors(gfx::Vector2dF, gfx::Vector2dF);
// Projects the |source| vector onto |destination|. Neither vector is assumed to be normalized.
- static FloatSize projectVector(const FloatSize& source, const FloatSize& destination);
+ static gfx::Vector2dF projectVector(gfx::Vector2dF source, gfx::Vector2dF destination);
};
} // namespace cc
diff --git a/cc/math_util_unittest.cc b/cc/math_util_unittest.cc
index 0b3ddcd..3fef272 100644
--- a/cc/math_util_unittest.cc
+++ b/cc/math_util_unittest.cc
@@ -6,7 +6,8 @@
#include "cc/math_util.h"
-#include "FloatSize.h"
+#include <cmath>
+
#include "cc/test/geometry_test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -136,9 +137,9 @@ TEST(MathUtilTest, verifyEnclosingRectOfVerticesUsesCorrectInitialBounds)
TEST(MathUtilTest, smallestAngleBetweenVectors)
{
- FloatSize x(1, 0);
- FloatSize y(0, 1);
- FloatSize testVector(0.5, 0.5);
+ gfx::Vector2dF x(1, 0);
+ gfx::Vector2dF y(0, 1);
+ gfx::Vector2dF testVector(0.5, 0.5);
// Orthogonal vectors are at an angle of 90 degress.
EXPECT_EQ(90, MathUtil::smallestAngleBetweenVectors(x, y));
@@ -154,31 +155,31 @@ TEST(MathUtilTest, smallestAngleBetweenVectors)
EXPECT_FLOAT_EQ(180, MathUtil::smallestAngleBetweenVectors(testVector, -testVector));
// The test vector is at a known angle.
- EXPECT_FLOAT_EQ(45, floor(MathUtil::smallestAngleBetweenVectors(testVector, x)));
- EXPECT_FLOAT_EQ(45, floor(MathUtil::smallestAngleBetweenVectors(testVector, y)));
+ EXPECT_FLOAT_EQ(45, std::floor(MathUtil::smallestAngleBetweenVectors(testVector, x)));
+ EXPECT_FLOAT_EQ(45, std::floor(MathUtil::smallestAngleBetweenVectors(testVector, y)));
}
TEST(MathUtilTest, vectorProjection)
{
- FloatSize x(1, 0);
- FloatSize y(0, 1);
- FloatSize testVector(0.3f, 0.7f);
+ gfx::Vector2dF x(1, 0);
+ gfx::Vector2dF y(0, 1);
+ gfx::Vector2dF testVector(0.3f, 0.7f);
// Orthogonal vectors project to a zero vector.
- EXPECT_EQ(FloatSize(0, 0), MathUtil::projectVector(x, y));
- EXPECT_EQ(FloatSize(0, 0), MathUtil::projectVector(y, x));
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), MathUtil::projectVector(x, y));
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), MathUtil::projectVector(y, x));
// Projecting a vector onto the orthonormal basis gives the corresponding component of the
// vector.
- EXPECT_EQ(FloatSize(testVector.width(), 0), MathUtil::projectVector(testVector, x));
- EXPECT_EQ(FloatSize(0, testVector.height()), MathUtil::projectVector(testVector, y));
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(testVector.x(), 0), MathUtil::projectVector(testVector, x));
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(0, testVector.y()), MathUtil::projectVector(testVector, y));
// Finally check than an arbitrary vector projected to another one gives a vector parallel to
// the second vector.
- FloatSize targetVector(0.5, 0.2f);
- FloatSize projectedVector = MathUtil::projectVector(testVector, targetVector);
- EXPECT_EQ(projectedVector.width() / targetVector.width(),
- projectedVector.height() / targetVector.height());
+ gfx::Vector2dF targetVector(0.5, 0.2f);
+ gfx::Vector2dF projectedVector = MathUtil::projectVector(testVector, targetVector);
+ EXPECT_EQ(projectedVector.x() / targetVector.x(),
+ projectedVector.y() / targetVector.y());
}
} // namespace
diff --git a/cc/page_scale_animation.cc b/cc/page_scale_animation.cc
index 59424d4..49948ab 100644
--- a/cc/page_scale_animation.cc
+++ b/cc/page_scale_animation.cc
@@ -6,22 +6,21 @@
#include "cc/page_scale_animation.h"
-#include "FloatPoint.h"
-#include "FloatSize.h"
-#include "IntPoint.h"
-#include "IntSize.h"
+#include "cc/geometry.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(const IntSize& scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime)
+scoped_ptr<PageScaleAnimation> PageScaleAnimation::create(gfx::Vector2d 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(const IntSize& scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime)
+PageScaleAnimation::PageScaleAnimation(gfx::Vector2d scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime)
: m_scrollStart(scrollStart)
, m_pageScaleStart(pageScaleStart)
, m_windowSize(windowSize)
@@ -38,13 +37,13 @@ PageScaleAnimation::~PageScaleAnimation()
{
}
-void PageScaleAnimation::zoomTo(const IntSize& finalScroll, float finalPageScale, double duration)
+void PageScaleAnimation::zoomTo(gfx::Vector2d 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(cc::FloatPoint(cc::IntPoint(m_scrollStart)), m_windowSize);
- gfx::RectF endRect(cc::FloatPoint(cc::IntPoint(finalScroll)), m_windowSize);
+ gfx::RectF startRect(gfx::PointAtOffsetFromOrigin(m_scrollStart), m_windowSize);
+ gfx::RectF endRect(gfx::PointAtOffsetFromOrigin(finalScroll), m_windowSize);
endRect.Scale(m_pageScaleStart / finalPageScale);
// The anchor is the point which is at the same ratio of the sides of
@@ -61,7 +60,7 @@ void PageScaleAnimation::zoomTo(const IntSize& finalScroll, float finalPageScale
float ratioX = (startRect.x() - endRect.x()) / (endRect.width() - startRect.width());
float ratioY = (startRect.y() - endRect.y()) / (endRect.height() - startRect.height());
- IntSize anchor(m_windowSize.width() * ratioX, m_windowSize.height() * ratioY);
+ gfx::Vector2d 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
@@ -73,16 +72,17 @@ void PageScaleAnimation::zoomTo(const IntSize& finalScroll, float finalPageScale
}
}
-void PageScaleAnimation::zoomWithAnchor(const IntSize& anchor, float finalPageScale, double duration)
+void PageScaleAnimation::zoomWithAnchor(gfx::Vector2d anchor, float finalPageScale, double duration)
{
m_scrollEnd = m_scrollStart + anchor;
- m_scrollEnd.scale(finalPageScale / m_pageScaleStart);
+ m_scrollEnd = gfx::ToFlooredVector2d(cc::ScaleVector2d(m_scrollEnd, finalPageScale / m_pageScaleStart));
m_scrollEnd -= anchor;
- m_scrollEnd.clampNegativeToZero();
+ m_scrollEnd = ClampFromBelow(m_scrollEnd, gfx::Vector2d());
gfx::SizeF scaledContentSize = m_contentSize.Scale(finalPageScale / m_pageScaleStart);
- IntSize maxScrollPosition = roundedIntSize(cc::FloatSize(scaledContentSize) - cc::IntSize(m_windowSize));
- m_scrollEnd = m_scrollEnd.shrunkTo(maxScrollPosition);
+ gfx::Vector2d maxScrollOffset = gfx::ToRoundedVector2d(BottomRight(gfx::RectF(scaledContentSize)) - BottomRight(gfx::Rect(m_windowSize)));
+ m_scrollEnd = m_scrollEnd;
+ m_scrollEnd = ClampFromAbove(m_scrollEnd, maxScrollOffset);
m_anchor = anchor;
m_pageScaleEnd = finalPageScale;
@@ -90,7 +90,7 @@ void PageScaleAnimation::zoomWithAnchor(const IntSize& anchor, float finalPageSc
m_anchorMode = true;
}
-IntSize PageScaleAnimation::scrollOffsetAtTime(double time) const
+gfx::Vector2d 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;
}
-IntSize PageScaleAnimation::scrollOffsetAtRatio(float ratio) const
+gfx::Vector2d PageScaleAnimation::scrollOffsetAtRatio(float ratio) const
{
if (ratio <= 0)
return m_scrollStart;
@@ -121,23 +121,23 @@ IntSize PageScaleAnimation::scrollOffsetAtRatio(float ratio) const
return m_scrollEnd;
float currentPageScale = pageScaleAtRatio(ratio);
- IntSize currentScrollOffset;
+ gfx::Vector2d currentScrollOffset;
if (m_anchorMode) {
// Keep the anchor stable on the screen at the current scale.
- IntSize documentAnchor = m_scrollStart + m_anchor;
- documentAnchor.scale(currentPageScale / m_pageScaleStart);
- currentScrollOffset = documentAnchor - m_anchor;
+ gfx::Vector2dF documentAnchor = m_scrollStart + m_anchor;
+ documentAnchor.Scale(currentPageScale / m_pageScaleStart);
+ currentScrollOffset = gfx::ToRoundedVector2d(documentAnchor - m_anchor);
} else {
// First move both scroll offsets to the current coordinate space.
- FloatSize scaledStartScroll(m_scrollStart);
- scaledStartScroll.scale(currentPageScale / m_pageScaleStart);
- FloatSize scaledEndScroll(m_scrollEnd);
- scaledEndScroll.scale(currentPageScale / m_pageScaleEnd);
+ gfx::Vector2dF scaledStartScroll(m_scrollStart);
+ scaledStartScroll.Scale(currentPageScale / m_pageScaleStart);
+ gfx::Vector2dF scaledEndScroll(m_scrollEnd);
+ scaledEndScroll.Scale(currentPageScale / m_pageScaleEnd);
// Linearly interpolate between them.
- FloatSize delta = scaledEndScroll - scaledStartScroll;
- delta.scale(ratio);
- currentScrollOffset = roundedIntSize(scaledStartScroll + delta);
+ gfx::Vector2dF delta = scaledEndScroll - scaledStartScroll;
+ delta.Scale(ratio);
+ currentScrollOffset = gfx::ToRoundedVector2d(scaledStartScroll + delta);
}
return currentScrollOffset;
diff --git a/cc/page_scale_animation.h b/cc/page_scale_animation.h
index 5f4bbac..c4c2940 100644
--- a/cc/page_scale_animation.h
+++ b/cc/page_scale_animation.h
@@ -6,7 +6,8 @@
#define CC_PAGE_SCALE_ANIMATION_H_
#include "base/memory/scoped_ptr.h"
-#include "IntSize.h"
+#include "ui/gfx/size.h"
+#include "ui/gfx/vector2d.h"
namespace cc {
@@ -19,7 +20,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(const IntSize& scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime);
+ static scoped_ptr<PageScaleAnimation> create(gfx::Vector2d scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime);
~PageScaleAnimation();
// The following methods initialize the animation. Call one of them
@@ -27,16 +28,16 @@ public:
// Zoom while explicitly specifying the top-left scroll position. The
// scroll offset is in finalPageScale coordinates.
- void zoomTo(const IntSize& finalScroll, float finalPageScale, double duration);
+ void zoomTo(gfx::Vector2d 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(const IntSize& anchor, float finalPageScale, double duration);
+ void zoomWithAnchor(gfx::Vector2d anchor, float finalPageScale, double duration);
// Call these functions while the animation is in progress to output the
// current state.
- IntSize scrollOffsetAtTime(double time) const;
+ gfx::Vector2d scrollOffsetAtTime(double time) const;
float pageScaleAtTime(double time) const;
bool isAnimationCompleteAtTime(double time) const;
@@ -45,25 +46,25 @@ public:
double startTime() const { return m_startTime; }
double duration() const { return m_duration; }
double endTime() const { return m_startTime + m_duration; }
- const IntSize& finalScrollOffset() const { return m_scrollEnd; }
+ gfx::Vector2d finalScrollOffset() const { return m_scrollEnd; }
float finalPageScale() const { return m_pageScaleEnd; }
protected:
- PageScaleAnimation(const IntSize& scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime);
+ PageScaleAnimation(gfx::Vector2d scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime);
private:
float progressRatioForTime(double time) const;
- IntSize scrollOffsetAtRatio(float ratio) const;
+ gfx::Vector2d scrollOffsetAtRatio(float ratio) const;
float pageScaleAtRatio(float ratio) const;
- IntSize m_scrollStart;
+ gfx::Vector2d m_scrollStart;
float m_pageScaleStart;
gfx::Size m_windowSize;
gfx::Size m_contentSize;
bool m_anchorMode;
- IntSize m_anchor;
- IntSize m_scrollEnd;
+ gfx::Vector2d m_anchor;
+ gfx::Vector2d m_scrollEnd;
float m_pageScaleEnd;
double m_startTime;
diff --git a/cc/proxy.h b/cc/proxy.h
index 8b5287d..ac61540 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(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration) = 0;
+ virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, 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 7335e2c..5a603945 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_currentPos = scrollLayer->scrollPosition() + scrollLayer->scrollDelta();
+ m_currentOffset = scrollLayer->scrollOffset() + scrollLayer->scrollDelta();
m_totalSize = getScrollLayerBounds(scrollLayer);
- m_maximum = scrollLayer->maxScrollPosition();
+ m_maximum = scrollLayer->maxScrollOffset();
if (m_horizontalScrollbarLayer) {
- m_horizontalScrollbarLayer->setCurrentPos(m_currentPos.x());
+ m_horizontalScrollbarLayer->setCurrentPos(m_currentOffset.x());
m_horizontalScrollbarLayer->setTotalSize(m_totalSize.width());
- m_horizontalScrollbarLayer->setMaximum(m_maximum.width());
+ m_horizontalScrollbarLayer->setMaximum(m_maximum.x());
}
if (m_verticalScrollbarLayer) {
- m_verticalScrollbarLayer->setCurrentPos(m_currentPos.y());
+ m_verticalScrollbarLayer->setCurrentPos(m_currentOffset.y());
m_verticalScrollbarLayer->setTotalSize(m_totalSize.height());
- m_verticalScrollbarLayer->setMaximum(m_maximum.height());
+ m_verticalScrollbarLayer->setMaximum(m_maximum.y());
}
}
diff --git a/cc/scrollbar_animation_controller.h b/cc/scrollbar_animation_controller.h
index c26b464..eaf2913 100644
--- a/cc/scrollbar_animation_controller.h
+++ b/cc/scrollbar_animation_controller.h
@@ -7,12 +7,9 @@
#include "base/memory/scoped_ptr.h"
#include "cc/cc_export.h"
-#include "FloatPoint.h"
-#include "IntSize.h"
-
-namespace gfx {
-class Size;
-}
+#include "ui/gfx/size.h"
+#include "ui/gfx/vector2d.h"
+#include "ui/gfx/vector2d_f.h"
namespace cc {
@@ -39,9 +36,9 @@ public:
void setVerticalScrollbarLayer(ScrollbarLayerImpl* layer) { m_verticalScrollbarLayer = layer; }
ScrollbarLayerImpl* verticalScrollbarLayer() const { return m_verticalScrollbarLayer; }
- FloatPoint currentPos() const { return m_currentPos; }
+ gfx::Vector2dF currentOffset() const { return m_currentOffset; }
gfx::Size totalSize() const { return m_totalSize; }
- IntSize maximum() const { return m_maximum; }
+ gfx::Vector2d maximum() const { return m_maximum; }
virtual void didPinchGestureBeginAtTime(double monotonicTime) { }
virtual void didPinchGestureUpdateAtTime(double monotonicTime) { }
@@ -58,9 +55,9 @@ private:
ScrollbarLayerImpl* m_horizontalScrollbarLayer;
ScrollbarLayerImpl* m_verticalScrollbarLayer;
- FloatPoint m_currentPos;
+ gfx::Vector2dF m_currentOffset;
gfx::Size m_totalSize;
- IntSize m_maximum;
+ gfx::Vector2d m_maximum;
};
} // namespace cc
diff --git a/cc/scrollbar_animation_controller_linear_fade.cc b/cc/scrollbar_animation_controller_linear_fade.cc
index 6d721bf..0b3870c 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)
{
- FloatPoint previousPos = currentPos();
+ gfx::Vector2dF previousPos = currentOffset();
ScrollbarAnimationController::updateScrollOffsetAtTime(scrollLayer, monotonicTime);
- if (previousPos == currentPos())
+ if (previousPos == currentOffset())
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 32537cb..592d793 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->setMaxScrollPosition(IntSize(50, 50));
- m_contentLayer->setBounds(IntSize(50, 50));
+ m_scrollLayer->setMaxScrollOffset(gfx::Vector2d(50, 50));
+ m_contentLayer->setBounds(gfx::Size(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(IntSize(1, 1));
+ m_scrollLayer->setScrollDelta(gfx::Vector2d(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(IntSize(2, 2));
+ m_scrollLayer->setScrollDelta(gfx::Vector2d(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(IntSize(3, 3));
+ m_scrollLayer->setScrollDelta(gfx::Vector2d(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(IntSize(1, 1));
+ m_scrollLayer->setScrollDelta(gfx::Vector2d(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 cbf0adb4..13a9678 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 = IntSize(length, scrollbar->size().height);
+ m_thumbSize = gfx::Size(length, scrollbar->size().height);
else
- m_thumbSize = IntSize(scrollbar->size().width, length);
+ m_thumbSize = gfx::Size(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 1deed9d..1480372 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>);
- IntSize m_thumbSize;
+ gfx::Size m_thumbSize;
};
}
diff --git a/cc/scrollbar_layer_unittest.cc b/cc/scrollbar_layer_unittest.cc
index fb68734..8cb3cc0 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->setScrollPosition(IntPoint(10, 20));
- layerTreeRoot->setMaxScrollPosition(IntSize(30, 50));
- contentLayer->setBounds(IntSize(100, 200));
+ layerTreeRoot->setScrollOffset(gfx::Vector2d(10, 20));
+ layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(30, 50));
+ contentLayer->setBounds(gfx::Size(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->setScrollPosition(IntPoint(100, 200));
- layerTreeRoot->setMaxScrollPosition(IntSize(300, 500));
- contentLayer->setBounds(IntSize(1000, 2000));
+ layerTreeRoot->setScrollOffset(gfx::Vector2d(100, 200));
+ layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(300, 500));
+ contentLayer->setBounds(gfx::Size(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(FloatSize(12, 34));
+ layerImplTreeRoot->scrollBy(gfx::Vector2d(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 7fe679f..b9cf353 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(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration)
+void SingleThreadProxy::startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration)
{
- m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scale, base::TimeTicks::Now(), duration);
+ m_layerTreeHostImpl->startPageScaleAnimation(targetOffset, useAnchor, scale, base::TimeTicks::Now(), duration);
}
void SingleThreadProxy::finishAllRendering()
diff --git a/cc/single_thread_proxy.h b/cc/single_thread_proxy.h
index f91d7b6..db73ee4 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(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE;
+ virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, 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
deleted file mode 100644
index df1fe9f..0000000
--- a/cc/stubs/FloatPoint.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// 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
deleted file mode 100644
index f5d5c4e..0000000
--- a/cc/stubs/FloatSize.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// 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
deleted file mode 100644
index d996ea8..0000000
--- a/cc/stubs/IntPoint.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// 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
deleted file mode 100644
index 4508c69..0000000
--- a/cc/stubs/IntSize.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// 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
deleted file mode 100644
index c5f5191..0000000
--- a/cc/stubs/float_point.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// 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
deleted file mode 100644
index 2193ac0..0000000
--- a/cc/stubs/float_size.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// 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
deleted file mode 100644
index 068c662..0000000
--- a/cc/stubs/int_point.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// 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
deleted file mode 100644
index 9e1c3e6..0000000
--- a/cc/stubs/int_size.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// 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 8140495..78e7a8f 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(const IntSize& scrollDelta, float pageScale) OVERRIDE { }
+ virtual void applyScrollAndScale(gfx::Vector2d 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 7877a64..52cb814 100644
--- a/cc/test/geometry_test_utils.h
+++ b/cc/test/geometry_test_utils.h
@@ -13,32 +13,38 @@ 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 65a2904..1842d17 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(const IntSize& scrollDelta, float scale) OVERRIDE
+ virtual void applyScrollAndScale(gfx::Vector2d 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 ad044d5..0e02cfa 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(const cc::IntSize&, float) { }
+ virtual void applyScrollAndScale(gfx::Vector2d, 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 ac58216..76272e7 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(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration)
+void ThreadProxy::startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration)
{
DCHECK(Proxy::isMainThread());
- Proxy::implThread()->postTask(base::Bind(&ThreadProxy::requestStartPageScaleAnimationOnImplThread, base::Unretained(this), targetPosition, useAnchor, scale, duration));
+ Proxy::implThread()->postTask(base::Bind(&ThreadProxy::requestStartPageScaleAnimationOnImplThread, base::Unretained(this), targetOffset, useAnchor, scale, duration));
}
-void ThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPosition, bool useAnchor, float scale, base::TimeDelta duration)
+void ThreadProxy::requestStartPageScaleAnimationOnImplThread(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration)
{
DCHECK(Proxy::isImplThread());
if (m_layerTreeHostImpl.get())
- m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scale, base::TimeTicks::Now(), duration);
+ m_layerTreeHostImpl->startPageScaleAnimation(targetOffset, useAnchor, scale, base::TimeTicks::Now(), duration);
}
void ThreadProxy::finishAllRendering()
diff --git a/cc/thread_proxy.h b/cc/thread_proxy.h
index 1a24ec5..7e14347 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(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE;
+ virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, 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(IntSize targetPosition, bool useAnchor, float scale, base::TimeDelta duration);
+ void requestStartPageScaleAnimationOnImplThread(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration);
void finishAllRenderingOnImplThread(CompletionEvent*);
void initializeImplOnImplThread(CompletionEvent*, InputHandler*);
void setSurfaceReadyOnImplThread();
diff --git a/webkit/compositor_bindings/compositor_bindings.gyp b/webkit/compositor_bindings/compositor_bindings.gyp
index 3b1196b..9f6417c 100644
--- a/webkit/compositor_bindings/compositor_bindings.gyp
+++ b/webkit/compositor_bindings/compositor_bindings.gyp
@@ -86,8 +86,6 @@
],
'sources': [
'<@(webkit_compositor_bindings_sources)',
- 'webcore_convert.cc',
- 'webcore_convert.h',
],
},
],
diff --git a/webkit/compositor_bindings/web_content_layer_impl.cc b/webkit/compositor_bindings/web_content_layer_impl.cc
index af0eecd..b42ca13 100644
--- a/webkit/compositor_bindings/web_content_layer_impl.cc
+++ b/webkit/compositor_bindings/web_content_layer_impl.cc
@@ -12,7 +12,6 @@
#include "third_party/WebKit/Source/Platform/chromium/public/WebFloatRect.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
-#include "webcore_convert.h"
using namespace cc;
diff --git a/webkit/compositor_bindings/web_layer_impl.cc b/webkit/compositor_bindings/web_layer_impl.cc
index c92d989..0fcb74f 100644
--- a/webkit/compositor_bindings/web_layer_impl.cc
+++ b/webkit/compositor_bindings/web_layer_impl.cc
@@ -18,7 +18,6 @@
#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h"
#include "web_animation_impl.h"
-#include "webcore_convert.h"
using cc::ActiveAnimation;
using cc::Layer;
@@ -346,22 +345,22 @@ void WebLayerImpl::setForceRenderSurface(bool forceRenderSurface)
void WebLayerImpl::setScrollPosition(WebPoint position)
{
- m_layer->setScrollPosition(convert(position));
+ m_layer->setScrollOffset(gfx::Point(position).OffsetFromOrigin());
}
WebPoint WebLayerImpl::scrollPosition() const
{
- return WebPoint(m_layer->scrollPosition().x(), m_layer->scrollPosition().y());
+ return gfx::PointAtOffsetFromOrigin(m_layer->scrollOffset());
}
void WebLayerImpl::setMaxScrollPosition(WebSize maxScrollPosition)
{
- m_layer->setMaxScrollPosition(convert(maxScrollPosition));
+ m_layer->setMaxScrollOffset(maxScrollPosition);
}
WebSize WebLayerImpl::maxScrollPosition() const
{
- return convert(m_layer->maxScrollPosition());
+ return m_layer->maxScrollOffset();
}
void WebLayerImpl::setScrollable(bool scrollable)
diff --git a/webkit/compositor_bindings/web_layer_tree_view_impl.cc b/webkit/compositor_bindings/web_layer_tree_view_impl.cc
index 9f3e893..02aa48b 100644
--- a/webkit/compositor_bindings/web_layer_tree_view_impl.cc
+++ b/webkit/compositor_bindings/web_layer_tree_view_impl.cc
@@ -16,7 +16,6 @@
#include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
-#include "webcore_convert.h"
#include "web_layer_impl.h"
#include "web_to_ccinput_handler_adapter.h"
@@ -130,7 +129,7 @@ void WebLayerTreeViewImpl::setPageScaleFactorAndLimits(float pageScaleFactor, fl
void WebLayerTreeViewImpl::startPageScaleAnimation(const WebPoint& scroll, bool useAnchor, float newPageScale, double durationSec)
{
base::TimeDelta duration = base::TimeDelta::FromMicroseconds(durationSec * base::Time::kMicrosecondsPerSecond);
- m_layerTreeHost->startPageScaleAnimation(IntSize(scroll.x, scroll.y), useAnchor, newPageScale, duration);
+ m_layerTreeHost->startPageScaleAnimation(gfx::Vector2d(scroll.x, scroll.y), useAnchor, newPageScale, duration);
}
void WebLayerTreeViewImpl::setNeedsAnimate()
@@ -231,9 +230,9 @@ void WebLayerTreeViewImpl::layout()
m_client->layout();
}
-void WebLayerTreeViewImpl::applyScrollAndScale(const cc::IntSize& scrollDelta, float pageScale)
+void WebLayerTreeViewImpl::applyScrollAndScale(gfx::Vector2d scrollDelta, float pageScale)
{
- m_client->applyScrollAndScale(convert(scrollDelta), pageScale);
+ m_client->applyScrollAndScale(scrollDelta, pageScale);
}
scoped_ptr<WebCompositorOutputSurface> WebLayerTreeViewImpl::createOutputSurface()
diff --git a/webkit/compositor_bindings/web_layer_tree_view_impl.h b/webkit/compositor_bindings/web_layer_tree_view_impl.h
index 42d4a49..0d7de7f 100644
--- a/webkit/compositor_bindings/web_layer_tree_view_impl.h
+++ b/webkit/compositor_bindings/web_layer_tree_view_impl.h
@@ -58,7 +58,7 @@ public:
virtual void didBeginFrame() OVERRIDE;
virtual void animate(double monotonicFrameBeginTime) OVERRIDE;
virtual void layout() OVERRIDE;
- virtual void applyScrollAndScale(const cc::IntSize& scrollDelta, float pageScale) OVERRIDE;
+ virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float pageScale) OVERRIDE;
virtual scoped_ptr<WebCompositorOutputSurface> createOutputSurface() OVERRIDE;
virtual void didRecreateOutputSurface(bool success) OVERRIDE;
virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE;
diff --git a/webkit/compositor_bindings/web_to_ccinput_handler_adapter.cc b/webkit/compositor_bindings/web_to_ccinput_handler_adapter.cc
index 58794b5..3e0d5e2 100644
--- a/webkit/compositor_bindings/web_to_ccinput_handler_adapter.cc
+++ b/webkit/compositor_bindings/web_to_ccinput_handler_adapter.cc
@@ -6,10 +6,7 @@
#include "web_to_ccinput_handler_adapter.h"
-#include "cc/stubs/int_point.h"
-#include "cc/stubs/int_size.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandlerClient.h"
-#include "webcore_convert.h"
#define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, cc_name) \
COMPILE_ASSERT(int(WebKit::webkit_name) == int(cc::cc_name), mismatching_enums)
@@ -54,7 +51,7 @@ public:
virtual void scrollBy(WebPoint point, WebSize offset) OVERRIDE
{
- m_client->scrollBy(point, convert(offset));
+ m_client->scrollBy(point, offset);
}
virtual void scrollEnd() OVERRIDE
@@ -69,7 +66,7 @@ public:
virtual void pinchGestureUpdate(float magnifyDelta, WebPoint anchor) OVERRIDE
{
- m_client->pinchGestureUpdate(magnifyDelta, convert(anchor));
+ m_client->pinchGestureUpdate(magnifyDelta, anchor);
}
virtual void pinchGestureEnd() OVERRIDE
@@ -85,7 +82,7 @@ public:
{
base::TimeTicks startTime = base::TimeTicks::FromInternalValue(startTimeSec * base::Time::kMicrosecondsPerSecond);
base::TimeDelta duration = base::TimeDelta::FromMicroseconds(durationSec * base::Time::kMicrosecondsPerSecond);
- m_client->startPageScaleAnimation(convert(targetPosition), anchorPoint, pageScale, startTime, duration);
+ m_client->startPageScaleAnimation(targetPosition, anchorPoint, pageScale, startTime, duration);
}
virtual void scheduleAnimation() OVERRIDE
diff --git a/webkit/compositor_bindings/webcore_convert.cc b/webkit/compositor_bindings/webcore_convert.cc
deleted file mode 100644
index 5e887c0..0000000
--- a/webkit/compositor_bindings/webcore_convert.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-// 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.
-
-#include "config.h"
-
-#include "webcore_convert.h"
-
-namespace WebKit {
-
-WebCore::FloatPoint convert(const WebFloatPoint& point)
-{
- return WebCore::FloatPoint(point.x, point.y);
-}
-
-WebCore::IntPoint convert(const WebPoint& point)
-{
- return WebCore::IntPoint(point.x, point.y);
-}
-
-WebCore::IntSize convert(const WebSize& size)
-{
- return WebCore::IntSize(size.width, size.height);
-}
-
-WebSize convert(const WebCore::IntSize& size)
-{
- return WebSize(size.width(), size.height());
-}
-
-WebFloatPoint convert(const WebCore::FloatPoint& point)
-{
- return WebFloatPoint(point.x(), point.y());
-}
-
-}
-
-
diff --git a/webkit/compositor_bindings/webcore_convert.h b/webkit/compositor_bindings/webcore_convert.h
deleted file mode 100644
index c81c533..0000000
--- a/webkit/compositor_bindings/webcore_convert.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// 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 WEBKIT_COMPOSITOR_BINDINGS_WEBCORE_CONVERT_H_
-#define WEBKIT_COMPOSITOR_BINDINGS_WEBCORE_CONVERT_H_
-
-#include "FloatPoint.h"
-#include "IntPoint.h"
-#include "IntSize.h"
-#include <public/WebFloatPoint.h>
-#include <public/WebRect.h>
-#include <public/WebPoint.h>
-#include <public/WebSize.h>
-
-namespace WebKit {
-
-WebCore::FloatPoint convert(const WebFloatPoint& point);
-WebCore::IntPoint convert(const WebPoint& point);
-WebCore::IntSize convert(const WebSize& size);
-WebSize convert(const WebCore::IntSize& size);
-WebFloatPoint convert(const WebCore::FloatPoint& point);
-
-}
-
-#endif // WEBKIT_COMPOSITOR_BINDINGS_WEBCORE_CONVERT_H_