This is preparation for https://android-git.corp.google.com/g/#/c/134488/4
Refactoring only, no functional change.
Bug:
5262656
Change-Id: I44e362cf35fc5080f7d9fba34183188d3a2a6331
m_position.set(0, 0);
m_anchorPoint.set(SK_ScalarHalf, SK_ScalarHalf);
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;
m_hasOverflowChildren = false;
m_position = src.m_position;
m_anchorPoint = src.m_anchorPoint;
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;
m_hasOverflowChildren = src.m_hasOverflowChildren;
- this->removeChildren();
#ifdef DEBUG_TRACK_NEW_DELETE
gLayerAllocCount -= 1;
#ifdef DEBUG_TRACK_NEW_DELETE
gLayerAllocCount -= 1;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-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();
}
int Layer::countChildren() const {
return m_children.count();
}
SkASSERT(index >= 0);
fParent->m_children.remove(index);
fParent = NULL;
SkASSERT(index >= 0);
fParent->m_children.remove(index);
fParent = NULL;
- this->unref(); // this call might delete us
+ unref(); // this call might delete us
SkScalar tx = SkScalarMul(m_anchorPoint.fX, m_size.width());
SkScalar ty = SkScalarMul(m_anchorPoint.fY, m_size.height());
matrix->preTranslate(tx, ty);
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 {
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());
void Layer::draw(SkCanvas* canvas, SkScalar opacity) {
#if 0
SkString str1, str2;
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",
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
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;
if (opacity <= 0) {
// SkDebugf("---- abort drawing %p opacity %g\n", this, opacity);
return;
// apply our local transform
{
SkMatrix tmp;
// 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);
}
// 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
{
#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);
SkPaint p;
p.setAntiAlias(true);
p.setStyle(SkPaint::kStroke_Style);
- int count = this->countChildren();
+ int count = countChildren();
- canvas->concat(this->getChildrenMatrix());
+ canvas->concat(getChildrenMatrix());
for (int i = 0; i < count; i++) {
for (int i = 0; i < count; i++) {
- this->getChild(i)->draw(canvas, opacity);
+ getChild(i)->draw(canvas, opacity);
Layer(const Layer&);
virtual ~Layer();
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; }
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(); }
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 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; }
bool m_hasOverflowChildren;
private:
bool m_hasOverflowChildren;
private:
- enum Flags {
- kInheritFromRootTransform_Flag = 0x01
- };
-
Layer* fParent;
SkScalar m_opacity;
SkSize m_size;
Layer* fParent;
SkScalar m_opacity;
SkSize m_size;
// The point in the layer used as the origin for local transformations,
// expressed as a fraction of the layer size.
SkPoint m_anchorPoint;
// 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;
SkTDArray<Layer*> m_children;
m_fixedRect = viewRect;
m_isFixed = true;
m_renderLayerPos = renderLayerPos;
m_fixedRect = viewRect;
m_isFixed = true;
m_renderLayerPos = renderLayerPos;
- setInheritFromRootTransform(true);
+ setShouldInheritFromRootTransform(true);
}
void setBackgroundColor(SkColor color);
}
void setBackgroundColor(SkColor color);
stream->write8(type);
// Start with Layer fields
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());
stream->writeScalar(layer->getOpacity());
stream->writeScalar(layer->getSize().width());
stream->writeScalar(layer->getSize().height());
- layer->setInheritFromRootTransform(stream->readBool());
+ layer->setShouldInheritFromRootTransform(stream->readBool());
layer->setOpacity(stream->readScalar());
layer->setSize(stream->readScalar(), stream->readScalar());
layer->setPosition(stream->readScalar(), stream->readScalar());
layer->setOpacity(stream->readScalar());
layer->setSize(stream->readScalar(), stream->readScalar());
layer->setPosition(stream->readScalar(), stream->readScalar());