summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/android/Layer.cpp
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/WebCore/platform/graphics/android/Layer.cpp
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/WebCore/platform/graphics/android/Layer.cpp')
-rw-r--r--Source/WebCore/platform/graphics/android/Layer.cpp68
1 files changed, 23 insertions, 45 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);
}
}
}