示例#1
0
文件: SkView.cpp 项目: tiftof/skia
void SkView::draw(SkCanvas* canvas)
{
    if (fWidth && fHeight && this->isVisible())
    {
        SkRect    r;
        r.set(fLoc.fX, fLoc.fY, fLoc.fX + fWidth, fLoc.fY + fHeight);
        if (this->isClipToBounds() &&
            canvas->quickReject(r)) {
                return;
        }

        SkAutoCanvasRestore    as(canvas, true);

        if (this->isClipToBounds()) {
            canvas->clipRect(r);
        }

        canvas->translate(fLoc.fX, fLoc.fY);
        canvas->concat(fMatrix);

        if (fParent) {
            fParent->beforeChild(this, canvas);
        }

        int sc = canvas->save();
        this->onDraw(canvas);
        canvas->restoreToCount(sc);

        if (fParent) {
            fParent->afterChild(this, canvas);
        }

        B2FIter    iter(this);
        SkView*    child;

        SkCanvas* childCanvas = this->beforeChildren(canvas);

        while ((child = iter.next()) != nullptr)
            child->draw(childCanvas);

        this->afterChildren(canvas);
    }
}
void SkView::draw(SkCanvas* canvas)
{
	if (fWidth && fHeight && this->isVisible())
	{
		SkRect	r;
		r.set(fLoc.fX, fLoc.fY, fLoc.fX + fWidth, fLoc.fY + fHeight);
		if (canvas->quickReject(r, SkCanvas::kBW_EdgeType))
			return;

		SkAutoCanvasRestore	as(canvas, true);

		canvas->clipRect(r);
		canvas->translate(fLoc.fX, fLoc.fY);

        if (fParent) {
            fParent->beforeChild(this, canvas);
        }

        int sc = canvas->save();
		this->onDraw(canvas);
        canvas->restoreToCount(sc);

        if (fParent) {
            fParent->afterChild(this, canvas);
        }
        
		B2FIter	iter(this);
		SkView*	child;

        SkCanvas* childCanvas = this->beforeChildren(canvas);

		while ((child = iter.next()) != NULL)
			child->draw(childCanvas);
        
        this->afterChildren(canvas);
	}
}
示例#3
0
static void drawIntoCanvas(State* state, SkCanvas* canvas) {
    gAnimTime = SkTime::GetMSecs();
    SkView* view = state->getView();
    view->draw(canvas);
}