summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-09-21 15:36:17 +0100
committerSteve Block <steveblock@google.com>2011-09-21 15:43:06 +0100
commit06ab37f33e994114ce0ec9fbb35fe48249ed6dbc (patch)
tree270a154abc1284e2069d232adda54f7869087e73 /Source
parent4532a944648e51d89583017239beefb88dca2a91 (diff)
downloadexternal_webkit-06ab37f33e994114ce0ec9fbb35fe48249ed6dbc.zip
external_webkit-06ab37f33e994114ce0ec9fbb35fe48249ed6dbc.tar.gz
external_webkit-06ab37f33e994114ce0ec9fbb35fe48249ed6dbc.tar.bz2
Clean up style and add some comments in Layer
This is preparation for https://android-git.corp.google.com/g/#/c/134488/4 Refactoring only, no functional change. Bug: 5262656 Change-Id: I44e362cf35fc5080f7d9fba34183188d3a2a6331
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/platform/graphics/android/Layer.cpp68
-rw-r--r--Source/WebCore/platform/graphics/android/Layer.h25
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.h2
-rw-r--r--Source/WebKit/android/jni/ViewStateSerializer.cpp4
4 files changed, 38 insertions, 61 deletions
diff --git a/Source/WebCore/platform/graphics/android/Layer.cpp b/Source/WebCore/platform/graphics/android/Layer.cpp
index 22c40f1..361cb4e 100644
--- a/Source/WebCore/platform/graphics/android/Layer.cpp
+++ b/Source/WebCore/platform/graphics/android/Layer.cpp
@@ -18,9 +18,9 @@ Layer::Layer() {
m_position.set(0, 0);
m_anchorPoint.set(SK_ScalarHalf, SK_ScalarHalf);
- fMatrix.reset();
- fChildrenMatrix.reset();
- fFlags = 0;
+ m_matrix.reset();
+ m_childrenMatrix.reset();
+ m_shouldInheritFromRootTransform = false;
m_hasOverflowChildren = false;
@@ -37,9 +37,9 @@ Layer::Layer(const Layer& src) : INHERITED() {
m_position = src.m_position;
m_anchorPoint = src.m_anchorPoint;
- fMatrix = src.fMatrix;
- fChildrenMatrix = src.fChildrenMatrix;
- fFlags = src.fFlags;
+ m_matrix = src.m_matrix;
+ m_childrenMatrix = src.m_childrenMatrix;
+ m_shouldInheritFromRootTransform = src.m_shouldInheritFromRootTransform;
m_hasOverflowChildren = src.m_hasOverflowChildren;
@@ -50,7 +50,7 @@ Layer::Layer(const Layer& src) : INHERITED() {
}
Layer::~Layer() {
- this->removeChildren();
+ removeChildren();
#ifdef DEBUG_TRACK_NEW_DELETE
gLayerAllocCount -= 1;
@@ -60,28 +60,6 @@ Layer::~Layer() {
///////////////////////////////////////////////////////////////////////////////
-bool Layer::isInheritFromRootTransform() const {
- return (fFlags & kInheritFromRootTransform_Flag) != 0;
-}
-
-void Layer::setInheritFromRootTransform(bool doInherit) {
- if (doInherit) {
- fFlags |= kInheritFromRootTransform_Flag;
- } else {
- fFlags &= ~kInheritFromRootTransform_Flag;
- }
-}
-
-void Layer::setMatrix(const SkMatrix& matrix) {
- fMatrix = matrix;
-}
-
-void Layer::setChildrenMatrix(const SkMatrix& matrix) {
- fChildrenMatrix = matrix;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
int Layer::countChildren() const {
return m_children.count();
}
@@ -111,7 +89,7 @@ void Layer::detachFromParent() {
SkASSERT(index >= 0);
fParent->m_children.remove(index);
fParent = NULL;
- this->unref(); // this call might delete us
+ unref(); // this call might delete us
}
}
@@ -142,15 +120,15 @@ void Layer::getLocalTransform(SkMatrix* matrix) const {
SkScalar tx = SkScalarMul(m_anchorPoint.fX, m_size.width());
SkScalar ty = SkScalarMul(m_anchorPoint.fY, m_size.height());
matrix->preTranslate(tx, ty);
- matrix->preConcat(this->getMatrix());
+ matrix->preConcat(getMatrix());
matrix->preTranslate(-tx, -ty);
}
void Layer::localToGlobal(SkMatrix* matrix) const {
- this->getLocalTransform(matrix);
+ getLocalTransform(matrix);
- if (this->isInheritFromRootTransform()) {
- matrix->postConcat(this->getRootLayer()->getMatrix());
+ if (shouldInheritFromRootTransform()) {
+ matrix->postConcat(getRootLayer()->getMatrix());
return;
}
@@ -176,14 +154,14 @@ void Layer::onDraw(SkCanvas*, SkScalar opacity) {
void Layer::draw(SkCanvas* canvas, SkScalar opacity) {
#if 0
SkString str1, str2;
- // this->getMatrix().toDumpString(&str1);
- // this->getChildrenMatrix().toDumpString(&str2);
+ // getMatrix().toDumpString(&str1);
+ // getChildrenMatrix().toDumpString(&str2);
SkDebugf("--- drawlayer %p opacity %g size [%g %g] pos [%g %g] matrix %s children %s\n",
- this, opacity * this->getOpacity(), m_size.width(), m_size.height(),
+ this, opacity * getOpacity(), m_size.width(), m_size.height(),
m_position.fX, m_position.fY, str1.c_str(), str2.c_str());
#endif
- opacity = SkScalarMul(opacity, this->getOpacity());
+ opacity = SkScalarMul(opacity, getOpacity());
if (opacity <= 0) {
// SkDebugf("---- abort drawing %p opacity %g\n", this, opacity);
return;
@@ -194,19 +172,19 @@ void Layer::draw(SkCanvas* canvas, SkScalar opacity) {
// apply our local transform
{
SkMatrix tmp;
- this->getLocalTransform(&tmp);
- if (this->isInheritFromRootTransform()) {
+ getLocalTransform(&tmp);
+ if (shouldInheritFromRootTransform()) {
// should we also apply the root's childrenMatrix?
canvas->setMatrix(getRootLayer()->getMatrix());
}
canvas->concat(tmp);
}
- this->onDraw(canvas, opacity);
+ onDraw(canvas, opacity);
#ifdef DEBUG_DRAW_LAYER_BOUNDS
{
- SkRect r = SkRect::MakeSize(this->getSize());
+ SkRect r = SkRect::MakeSize(getSize());
SkPaint p;
p.setAntiAlias(true);
p.setStyle(SkPaint::kStroke_Style);
@@ -218,11 +196,11 @@ void Layer::draw(SkCanvas* canvas, SkScalar opacity) {
}
#endif
- int count = this->countChildren();
+ int count = countChildren();
if (count > 0) {
- canvas->concat(this->getChildrenMatrix());
+ canvas->concat(getChildrenMatrix());
for (int i = 0; i < count; i++) {
- this->getChild(i)->draw(canvas, opacity);
+ getChild(i)->draw(canvas, opacity);
}
}
}
diff --git a/Source/WebCore/platform/graphics/android/Layer.h b/Source/WebCore/platform/graphics/android/Layer.h
index 107c457..7b27349 100644
--- a/Source/WebCore/platform/graphics/android/Layer.h
+++ b/Source/WebCore/platform/graphics/android/Layer.h
@@ -34,24 +34,27 @@ public:
Layer(const Layer&);
virtual ~Layer();
- bool isInheritFromRootTransform() const;
+ // Whether the layer should apply its tranform directly onto the root
+ // layer, rather than using the transforms of all ancestor layers. This is
+ // used for fixed position layers.
+ bool shouldInheritFromRootTransform() const { return m_shouldInheritFromRootTransform; }
SkScalar getOpacity() const { return m_opacity; }
const SkSize& getSize() const { return m_size; }
const SkPoint& getPosition() const { return m_position; }
const SkPoint& getAnchorPoint() const { return m_anchorPoint; }
- const SkMatrix& getMatrix() const { return fMatrix; }
- const SkMatrix& getChildrenMatrix() const { return fChildrenMatrix; }
+ const SkMatrix& getMatrix() const { return m_matrix; }
+ const SkMatrix& getChildrenMatrix() const { return m_childrenMatrix; }
SkScalar getWidth() const { return m_size.width(); }
SkScalar getHeight() const { return m_size.height(); }
- void setInheritFromRootTransform(bool);
+ void setShouldInheritFromRootTransform(bool inherit) { m_shouldInheritFromRootTransform = inherit; }
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 setAnchorPoint(SkScalar x, SkScalar y) { m_anchorPoint.set(x, y); }
- void setMatrix(const SkMatrix&);
- void setChildrenMatrix(const SkMatrix&);
+ void setMatrix(const SkMatrix& matrix) { m_matrix = matrix; }
+ void setChildrenMatrix(const SkMatrix& matrix) { m_childrenMatrix = matrix; }
// children
@@ -118,10 +121,6 @@ protected:
bool m_hasOverflowChildren;
private:
- enum Flags {
- kInheritFromRootTransform_Flag = 0x01
- };
-
Layer* fParent;
SkScalar m_opacity;
SkSize m_size;
@@ -130,9 +129,9 @@ private:
// The point in the layer used as the origin for local transformations,
// expressed as a fraction of the layer size.
SkPoint m_anchorPoint;
- SkMatrix fMatrix;
- SkMatrix fChildrenMatrix;
- uint32_t fFlags;
+ SkMatrix m_matrix;
+ SkMatrix m_childrenMatrix;
+ bool m_shouldInheritFromRootTransform;
SkTDArray<Layer*> m_children;
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h
index 8078762..31bb185 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h
@@ -170,7 +170,7 @@ public:
m_fixedRect = viewRect;
m_isFixed = true;
m_renderLayerPos = renderLayerPos;
- setInheritFromRootTransform(true);
+ setShouldInheritFromRootTransform(true);
}
void setBackgroundColor(SkColor color);
diff --git a/Source/WebKit/android/jni/ViewStateSerializer.cpp b/Source/WebKit/android/jni/ViewStateSerializer.cpp
index 794c118..b3556c3 100644
--- a/Source/WebKit/android/jni/ViewStateSerializer.cpp
+++ b/Source/WebKit/android/jni/ViewStateSerializer.cpp
@@ -257,7 +257,7 @@ void serializeLayer(LayerAndroid* layer, SkWStream* stream)
stream->write8(type);
// Start with Layer fields
- stream->writeBool(layer->isInheritFromRootTransform());
+ stream->writeBool(layer->shouldInheritFromRootTransform());
stream->writeScalar(layer->getOpacity());
stream->writeScalar(layer->getSize().width());
stream->writeScalar(layer->getSize().height());
@@ -338,7 +338,7 @@ LayerAndroid* deserializeLayer(SkStream* stream)
}
// Layer fields
- layer->setInheritFromRootTransform(stream->readBool());
+ layer->setShouldInheritFromRootTransform(stream->readBool());
layer->setOpacity(stream->readScalar());
layer->setSize(stream->readScalar(), stream->readScalar());
layer->setPosition(stream->readScalar(), stream->readScalar());