aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorMike Reed <reed@google.com>2010-02-19 11:31:47 -0500
committerMike Reed <reed@google.com>2010-02-19 14:38:19 -0500
commit9227689ced438298f7a60c0ae7d7ab81a2c07a55 (patch)
treefba93adebdd9c5c83695b72222f300a30af3784a /src/utils
parentc226875e0c4ba6482b948f078c440b3718f4e2f7 (diff)
downloadexternal_skia-9227689ced438298f7a60c0ae7d7ab81a2c07a55.zip
external_skia-9227689ced438298f7a60c0ae7d7ab81a2c07a55.tar.gz
external_skia-9227689ced438298f7a60c0ae7d7ab81a2c07a55.tar.bz2
remove viewport for layers (not needed in base class)
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/SkLayer.cpp75
1 files changed, 31 insertions, 44 deletions
diff --git a/src/utils/SkLayer.cpp b/src/utils/SkLayer.cpp
index fc1f5e5..603cdd1 100644
--- a/src/utils/SkLayer.cpp
+++ b/src/utils/SkLayer.cpp
@@ -2,44 +2,20 @@
#include "SkCanvas.h"
SkLayer::SkLayer() {
- m_doRotation = false;
- m_isFixed = false;
- m_backgroundColorSet = false;
-
- m_angleTransform = 0;
m_opacity = 1;
-
m_size.set(0, 0);
m_position.set(0, 0);
- m_translation.set(0, 0);
m_anchorPoint.set(0.5, 0.5);
- m_scale.set(1, 1);
-
- m_backgroundColor = 0;
fMatrix.reset();
fChildrenMatrix.reset();
}
SkLayer::SkLayer(const SkLayer& src) {
- m_doRotation = src.m_doRotation;
- m_isFixed = src.m_isFixed;
- m_backgroundColorSet = src.m_backgroundColorSet;
-
- m_angleTransform = src.m_angleTransform;
m_opacity = src.m_opacity;
m_size = src.m_size;
m_position = src.m_position;
- m_translation = src.m_translation;
m_anchorPoint = src.m_anchorPoint;
- m_scale = src.m_scale;
-
- m_fixedLeft = src.m_fixedLeft;
- m_fixedTop = src.m_fixedTop;
- m_fixedRight = src.m_fixedRight;
- m_fixedBottom = src.m_fixedBottom;
-
- m_backgroundColor = src.m_backgroundColor;
fMatrix = src.fMatrix;
fChildrenMatrix = src.fChildrenMatrix;
@@ -83,43 +59,54 @@ void SkLayer::setChildrenMatrix(const SkMatrix& matrix) {
///////////////////////////////////////////////////////////////////////////////
-void SkLayer::onSetupCanvas(SkCanvas* canvas, SkScalar, const SkRect*) {
- SkScalar tx = m_position.fX;
- SkScalar ty = m_position.fY;
- canvas->translate(tx, ty);
-
- // now apply our matrix about the anchorPoint
- tx = SkScalarMul(m_anchorPoint.fX, m_size.width());
- ty = SkScalarMul(m_anchorPoint.fY, m_size.height());
- canvas->translate(tx, ty);
- canvas->concat(this->getMatrix());
- canvas->translate(-tx, -ty);
+void SkLayer::onDraw(SkCanvas*, SkScalar opacity) {
+// SkDebugf("----- no onDraw for %p\n", this);
}
-void SkLayer::onDraw(SkCanvas*, SkScalar opacity, const SkRect* viewport) {}
+#include "SkString.h"
-void SkLayer::draw(SkCanvas* canvas, SkScalar opacity, const SkRect* viewport) {
+void SkLayer::draw(SkCanvas* canvas, SkScalar opacity) {
#if 0
- SkDebugf("--- drawlayer %p anchor [%g %g] scale [%g %g]\n", this, m_anchorPoint.fX, m_anchorPoint.fY,
- m_scale.fX, m_scale.fY);
+ SkString str1, str2;
+ // this->getMatrix().toDumpString(&str1);
+ // this->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(),
+ m_position.fX, m_position.fY, str1.c_str(), str2.c_str());
#endif
opacity = SkScalarMul(opacity, this->getOpacity());
if (opacity <= 0 || this->getSize().isEmpty()) {
+#if 0
+ SkDebugf("---- abort drawing %p opacity %g size [%g %g]\n",
+ this, opacity, m_size.width(), m_size.height());
+#endif
return;
}
- SkAutoCanvasRestore acr(canvas, false);
- canvas->save(SkCanvas::kMatrix_SaveFlag);
+ SkAutoCanvasRestore acr(canvas, true);
+
+ // update the matrix
+ {
+ SkScalar tx = m_position.fX;
+ SkScalar ty = m_position.fY;
+ canvas->translate(tx, ty);
+
+ // now apply our matrix about the anchorPoint
+ tx = SkScalarMul(m_anchorPoint.fX, m_size.width());
+ ty = SkScalarMul(m_anchorPoint.fY, m_size.height());
+ canvas->translate(tx, ty);
+ canvas->concat(this->getMatrix());
+ canvas->translate(-tx, -ty);
+ }
- this->onSetupCanvas(canvas, opacity, viewport);
- this->onDraw(canvas, opacity, viewport);
+ this->onDraw(canvas, opacity);
int count = this->countChildren();
if (count > 0) {
canvas->concat(this->getChildrenMatrix());
for (int i = 0; i < count; i++) {
- this->getChild(i)->draw(canvas, opacity, viewport);
+ this->getChild(i)->draw(canvas, opacity);
}
}
}