add DEBUG_LAYER_BOUNDS option to show layer bounds
git-svn-id: http://skia.googlecode.com/svn/trunk@509 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
233481ebd0
commit
2bd703b316
@ -32,8 +32,8 @@ private:
|
||||
|
||||
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;
|
||||
@ -47,7 +47,7 @@ public:
|
||||
{ 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);
|
||||
@ -55,6 +55,18 @@ public:
|
||||
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() {
|
||||
@ -72,8 +84,9 @@ protected:
|
||||
}
|
||||
|
||||
void drawBG(SkCanvas* canvas) {
|
||||
canvas->drawColor(0xFFDDDDDD);
|
||||
canvas->drawColor(SK_ColorWHITE);
|
||||
|
||||
canvas->translate(20, 20);
|
||||
fRootLayer->draw(canvas);
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
#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();
|
||||
@ -102,6 +104,20 @@ void SkLayer::draw(SkCanvas* canvas, SkScalar opacity) {
|
||||
|
||||
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());
|
||||
|
Loading…
Reference in New Issue
Block a user