2017-12-19 17:21:02 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SkSGDraw.h"
|
|
|
|
|
|
|
|
#include "SkSGGeometryNode.h"
|
2017-12-29 00:24:07 +00:00
|
|
|
#include "SkSGInvalidationController.h"
|
2017-12-19 17:21:02 +00:00
|
|
|
#include "SkSGPaintNode.h"
|
|
|
|
|
|
|
|
namespace sksg {
|
|
|
|
|
|
|
|
Draw::Draw(sk_sp<GeometryNode> geometry, sk_sp<PaintNode> paint)
|
|
|
|
: fGeometry(std::move(geometry))
|
|
|
|
, fPaint(std::move(paint)) {
|
|
|
|
fGeometry->addInvalReceiver(this);
|
|
|
|
fPaint->addInvalReceiver(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Draw::~Draw() {
|
|
|
|
fGeometry->removeInvalReceiver(this);
|
|
|
|
fPaint->removeInvalReceiver(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Draw::onRender(SkCanvas* canvas) const {
|
|
|
|
fGeometry->draw(canvas, fPaint->makePaint());
|
|
|
|
}
|
|
|
|
|
2018-01-03 21:17:29 +00:00
|
|
|
SkRect Draw::onRevalidate(InvalidationController* ic, const SkMatrix& ctm) {
|
|
|
|
SkASSERT(this->hasInval());
|
2017-12-19 17:21:02 +00:00
|
|
|
|
2017-12-29 00:24:07 +00:00
|
|
|
// TODO: paint bounds extents
|
2018-01-03 21:17:29 +00:00
|
|
|
const auto bounds = fGeometry->revalidate(ic, ctm);
|
2017-12-19 17:21:02 +00:00
|
|
|
fPaint->revalidate(ic, ctm);
|
2017-12-29 00:24:07 +00:00
|
|
|
|
2018-01-03 21:17:29 +00:00
|
|
|
return bounds;
|
2017-12-19 17:21:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace sksg
|