public:
SkLayerView() {
- static const int W = 640;
- static const int H = 480;
+ static const int W = 600;
+ static const int H = 440;
static const struct {
int fWidth;
int fHeight;
{ 120, 80, SK_ColorMAGENTA, W - 120, H - 80 },
};
- fRootLayer = new SkLayer;
+ fRootLayer = new TestLayer(0xFFDDDDDD);
fRootLayer->setSize(W, H);
for (size_t i = 0; i < SK_ARRAY_COUNT(gData); i++) {
SkLayer* child = new TestLayer(gData[i].fColor);
child->setPosition(gData[i].fPosX, gData[i].fPosY);
fRootLayer->addChild(child)->unref();
}
+
+ SkLayer* child = new TestLayer(0xFFDD8844);
+ child->setSize(120, 80);
+ child->setPosition(fRootLayer->getWidth()/2 - child->getWidth()/2,
+ fRootLayer->getHeight()/2 - child->getHeight()/2);
+ child->setAnchorPoint(SK_ScalarHalf, SK_ScalarHalf);
+ {
+ SkMatrix m;
+ m.setRotate(SkIntToScalar(30));
+ child->setMatrix(m);
+ }
+ fRootLayer->addChild(child)->unref();
}
virtual ~SkLayerView() {
}
void drawBG(SkCanvas* canvas) {
- canvas->drawColor(0xFFDDDDDD);
+ canvas->drawColor(SK_ColorWHITE);
+ canvas->translate(20, 20);
fRootLayer->draw(canvas);
}
#include "SkLayer.h"
#include "SkCanvas.h"
+//#define DEBUG_LAYER_BOUNDS
+
SkLayer::SkLayer() {
- m_opacity = 1;
+ m_opacity = SK_Scalar1;
m_size.set(0, 0);
m_position.set(0, 0);
- m_anchorPoint.set(0.5, 0.5);
+ m_anchorPoint.set(SK_ScalarHalf, SK_ScalarHalf);
fMatrix.reset();
fChildrenMatrix.reset();
this->onDraw(canvas, opacity);
+#ifdef DEBUG_LAYER_BOUNDS
+ {
+ SkRect r = SkRect::MakeSize(this->getSize());
+ SkPaint p;
+ p.setAntiAlias(true);
+ p.setStyle(SkPaint::kStroke_Style);
+ p.setStrokeWidth(SkIntToScalar(2));
+ p.setColor(0xFFFF44DD);
+ canvas->drawRect(r, p);
+ canvas->drawLine(r.fLeft, r.fTop, r.fRight, r.fBottom, p);
+ canvas->drawLine(r.fLeft, r.fBottom, r.fRight, r.fTop, p);
+ }
+#endif
+
int count = this->countChildren();
if (count > 0) {
canvas->concat(this->getChildrenMatrix());