summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2012-05-24 13:43:31 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-05-24 13:43:31 -0700
commit9c52999fb17b49c672908e36aabda61abf63fe8f (patch)
treef655896f403886405fed0fed6c2a5a30a732f505
parentc8d518ba99824a76fa842162ea8284a2261fa4a0 (diff)
parentdc5192de2d6f8637cef9be2ae52c8c100b2932e0 (diff)
downloadexternal_webkit-9c52999fb17b49c672908e36aabda61abf63fe8f.zip
external_webkit-9c52999fb17b49c672908e36aabda61abf63fe8f.tar.gz
external_webkit-9c52999fb17b49c672908e36aabda61abf63fe8f.tar.bz2
Merge "Move scrollOffset into Layer class" into jb-dev
-rw-r--r--Source/WebCore/platform/graphics/android/layers/Layer.cpp4
-rw-r--r--Source/WebCore/platform/graphics/android/layers/Layer.h4
-rw-r--r--Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp9
-rw-r--r--Source/WebCore/platform/graphics/android/layers/LayerAndroid.h3
-rw-r--r--Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.cpp6
-rw-r--r--Source/WebKit/android/jni/WebViewCore.cpp2
6 files changed, 15 insertions, 13 deletions
diff --git a/Source/WebCore/platform/graphics/android/layers/Layer.cpp b/Source/WebCore/platform/graphics/android/layers/Layer.cpp
index 48e36fc..6eb1e91 100644
--- a/Source/WebCore/platform/graphics/android/layers/Layer.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/Layer.cpp
@@ -41,6 +41,7 @@ Layer::Layer(const Layer& src) : INHERITED() {
m_opacity = src.m_opacity;
m_size = src.m_size;
m_position = src.m_position;
+ m_scrollOffset = src.m_scrollOffset;
m_anchorPoint = src.m_anchorPoint;
m_matrix = src.m_matrix;
@@ -122,7 +123,8 @@ Layer* Layer::getRootLayer() const {
///////////////////////////////////////////////////////////////////////////////
void Layer::getLocalTransform(SkMatrix* matrix) const {
- matrix->setTranslate(m_position.fX, m_position.fY);
+ matrix->setTranslate(m_position.fX - m_scrollOffset.x(),
+ m_position.fY - m_scrollOffset.y());
SkScalar tx = SkScalarMul(m_anchorPoint.fX, m_size.width());
SkScalar ty = SkScalarMul(m_anchorPoint.fY, m_size.height());
diff --git a/Source/WebCore/platform/graphics/android/layers/Layer.h b/Source/WebCore/platform/graphics/android/layers/Layer.h
index d87c699..cbdab37 100644
--- a/Source/WebCore/platform/graphics/android/layers/Layer.h
+++ b/Source/WebCore/platform/graphics/android/layers/Layer.h
@@ -49,6 +49,7 @@ public:
SkScalar getOpacity() const { return m_opacity; }
const SkSize& getSize() const { return m_size; }
const SkPoint& getPosition() const { return m_position; }
+ const IntPoint& getScrollOffset() const { return m_scrollOffset; }
const SkPoint& getAnchorPoint() const { return m_anchorPoint; }
const SkMatrix& getMatrix() const { return m_matrix; }
const SkMatrix& getChildrenMatrix() const { return m_childrenMatrix; }
@@ -60,6 +61,7 @@ public:
void setOpacity(SkScalar opacity) { m_opacity = opacity; }
void setSize(SkScalar w, SkScalar h) { m_size.set(w, h); }
void setPosition(SkScalar x, SkScalar y) { m_position.set(x, y); }
+ void setScrollOffset(IntPoint scrollOffset) { m_scrollOffset = scrollOffset; }
void setAnchorPoint(SkScalar x, SkScalar y) { m_anchorPoint.set(x, y); }
void setMatrix(const SkMatrix& matrix) { m_matrix = matrix; }
void setChildrenMatrix(const SkMatrix& matrix) { m_childrenMatrix = matrix; }
@@ -167,6 +169,8 @@ private:
SkSize m_size;
// The position of the origin of the layer, relative to the parent layer.
SkPoint m_position;
+ // The scroll offset of the layer
+ IntPoint m_scrollOffset;
// The point in the layer used as the origin for local transformations,
// expressed as a fraction of the layer size.
SkPoint m_anchorPoint;
diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
index b60b791..99af481 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
@@ -112,8 +112,6 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer),
m_visible = layer.m_visible;
m_backgroundColor = layer.m_backgroundColor;
- m_offset = layer.m_offset;
-
m_content = layer.m_content;
SkSafeRef(m_content);
@@ -397,10 +395,11 @@ void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentM
{
IntSize layerSize(getSize().width(), getSize().height());
FloatPoint anchorPoint(getAnchorPoint().fX, getAnchorPoint().fY);
- FloatPoint position(getPosition().fX + m_replicatedLayerPosition.x() - m_offset.x(),
- getPosition().fY + m_replicatedLayerPosition.y() - m_offset.y());
+ FloatPoint position(getPosition().fX + m_replicatedLayerPosition.x() - getScrollOffset().x(),
+ getPosition().fY + m_replicatedLayerPosition.y() - getScrollOffset().y());
float originX = anchorPoint.x() * layerSize.width();
float originY = anchorPoint.y() * layerSize.height();
+
TransformationMatrix localMatrix;
if (!isPositionFixed())
localMatrix = parentMatrix;
@@ -481,7 +480,7 @@ void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentM
TransformationMatrix childMatrix;
childMatrix = localMatrix;
- childMatrix.translate3d(m_offset.x(), m_offset.y(), 0);
+ childMatrix.translate3d(getScrollOffset().x(), getScrollOffset().y(), 0);
if (!m_childrenTransform.isIdentity()) {
childMatrix.translate(getSize().width() * 0.5f, getSize().height() * 0.5f);
childMatrix.multiply(m_childrenTransform);
diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
index 9b239ee..a5c1a6a 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
@@ -171,8 +171,6 @@ public:
void setDrawClip(const FloatRect& rect) { m_clippingRect = rect; }
const FloatRect& drawClip() { return m_clippingRect; }
- const IntPoint& scrollOffset() const { return m_offset; }
- void setScrollOffset(IntPoint offset) { m_offset = offset; }
void setBackgroundColor(SkColor color);
void setMaskLayer(LayerAndroid*);
void setMasksToBounds(bool masksToBounds)
@@ -300,7 +298,6 @@ public:
protected:
virtual void onDraw(SkCanvas*, SkScalar opacity, android::DrawExtra* extra, PaintStyle style);
virtual InvalidateFlags onSetHwAccelerated(bool hwAccelerated) { return InvalidateNone; }
- IntPoint m_offset;
TransformationMatrix m_drawTransform;
int m_uniqueId;
diff --git a/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.cpp
index f28c31d..1178103 100644
--- a/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.cpp
@@ -21,7 +21,7 @@ bool ScrollableLayerAndroid::scrollTo(int x, int y)
SkScalar newX = SkScalarPin(x, scrollBounds.x(), scrollBounds.width());
SkScalar newY = SkScalarPin(y, scrollBounds.y(), scrollBounds.height());
// Check for no change.
- if (newX == m_offset.x() && newY == m_offset.y())
+ if (newX == getScrollOffset().x() && newY == getScrollOffset().y())
return false;
setScrollOffset(IntPoint(newX, newY));
return true;
@@ -39,8 +39,8 @@ void ScrollableLayerAndroid::getScrollBounds(IntRect* out) const
void ScrollableLayerAndroid::getScrollRect(SkIRect* out) const
{
const SkPoint& pos = getPosition();
- out->fLeft = m_scrollLimits.fLeft - pos.fX + m_offset.x();
- out->fTop = m_scrollLimits.fTop - pos.fY + m_offset.y();
+ out->fLeft = m_scrollLimits.fLeft - pos.fX + getScrollOffset().x();
+ out->fTop = m_scrollLimits.fTop - pos.fY + getScrollOffset().y();
out->fRight = getSize().width() - m_scrollLimits.width();
out->fBottom = getSize().height() - m_scrollLimits.height();
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp
index 0add240..9d81edc 100644
--- a/Source/WebKit/android/jni/WebViewCore.cpp
+++ b/Source/WebKit/android/jni/WebViewCore.cpp
@@ -1555,7 +1555,7 @@ void WebViewCore::layerToAbsoluteOffset(const LayerAndroid* layer, IntPoint& off
while (layer) {
const SkPoint& pos = layer->getPosition();
offset.move(pos.fX, pos.fY);
- const IntPoint& scroll = layer->scrollOffset();
+ const IntPoint& scroll = layer->getScrollOffset();
offset.move(-scroll.x(), -scroll.y());
layer = static_cast<LayerAndroid*>(layer->getParent());
}