0ebf4192f1
Node subclasses can now control whether their bounds (changes) contribute to damage. Tristate: * Default: The node bounds contribute to damage if the node itself was invalidated, observing hasSelfInval(). This is the default behavior. * ForceSelf: The node bounds contribute to damage, regardless of hasSelfInval(). Used for domain-boundary nodes (e.g. Draw), which gate blocked fragments (e.g. geometry, paint nodes). * BlockSelf: The node bounds do not contribute to damage, regardless of hasSelfInval(). Used for nodes which do not contribute damage directly (e.g. paints, geometry). TBR= Change-Id: I7c941c7ea12e14b008d846ec13108e66e34dbc73 Reviewed-on: https://skia-review.googlesource.com/91104 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
45 lines
1.1 KiB
C++
45 lines
1.1 KiB
C++
/*
|
|
* 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"
|
|
#include "SkSGInvalidationController.h"
|
|
#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());
|
|
}
|
|
|
|
Node::RevalidationResult Draw::onRevalidate(InvalidationController* ic, const SkMatrix& ctm) {
|
|
SkASSERT(this->hasInval());
|
|
|
|
// TODO: adjust bounds for paint
|
|
const auto bounds = fGeometry->revalidate(ic, ctm);
|
|
fPaint->revalidate(ic, ctm);
|
|
|
|
// Neither paint nor geometry contribute to damage directly; instead we generate
|
|
// damage here, at the binding point.
|
|
return { bounds, Damage::kForceSelf };
|
|
}
|
|
|
|
} // namespace sksg
|