c14f144484
Backpedal on node/reval-time-determined damage: nodes cannot control the invalidation order, and shared descendants may be revalidated before a particular ancestor gets to query their state - thus making any decisions based on that invalid. Instead, apply damage suppression at invalidation time, based on node type/traits. Node types which don't generate direct damage are marked as such, and the invalidation logic bubbles damage past them, until it finds a valid damage receiver. Nodes which currently suppress damage: - PaintNode (and subclasses) - GeometryNode (and subclasses) - Matrix TBR= Change-Id: I843e683e64cb6253d8c26d8397c44d02a7d6026f Reviewed-on: https://skia-review.googlesource.com/91421 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
71 lines
1.7 KiB
C++
71 lines
1.7 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 "SkSGTransform.h"
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
namespace sksg {
|
|
// Matrix nodes don't generate damage on their own, but via aggregation ancestor Transform nodes.
|
|
Matrix::Matrix(const SkMatrix& m, sk_sp<Matrix> parent)
|
|
: INHERITED(kBubbleDamage_Trait)
|
|
, fParent(std::move(parent))
|
|
, fLocalMatrix(m) {
|
|
if (fParent) {
|
|
fParent->addInvalReceiver(this);
|
|
}
|
|
}
|
|
|
|
Matrix::~Matrix() {
|
|
if (fParent) {
|
|
fParent->removeInvalReceiver(this);
|
|
}
|
|
}
|
|
|
|
SkRect Matrix::onRevalidate(InvalidationController* ic, const SkMatrix& ctm) {
|
|
fTotalMatrix = fLocalMatrix;
|
|
|
|
if (fParent) {
|
|
fParent->revalidate(ic, ctm);
|
|
fTotalMatrix.postConcat(fParent->getTotalMatrix());
|
|
}
|
|
|
|
return SkRect::MakeEmpty();
|
|
}
|
|
|
|
Transform::Transform(sk_sp<RenderNode> child, sk_sp<Matrix> matrix)
|
|
: INHERITED(std::move(child))
|
|
, fMatrix(std::move(matrix)) {
|
|
fMatrix->addInvalReceiver(this);
|
|
}
|
|
|
|
Transform::~Transform() {
|
|
fMatrix->removeInvalReceiver(this);
|
|
}
|
|
|
|
void Transform::onRender(SkCanvas* canvas) const {
|
|
const auto& m = fMatrix->getTotalMatrix();
|
|
SkAutoCanvasRestore acr(canvas, !m.isIdentity());
|
|
canvas->concat(m);
|
|
this->INHERITED::onRender(canvas);
|
|
}
|
|
|
|
SkRect Transform::onRevalidate(InvalidationController* ic, const SkMatrix& ctm) {
|
|
SkASSERT(this->hasInval());
|
|
|
|
// We don't care about matrix reval results.
|
|
fMatrix->revalidate(ic, ctm);
|
|
|
|
const auto& m = fMatrix->getTotalMatrix();
|
|
auto bounds = this->INHERITED::onRevalidate(ic, SkMatrix::Concat(ctm, m));
|
|
m.mapRect(&bounds);
|
|
|
|
return bounds;
|
|
}
|
|
|
|
} // namespace sksg
|