aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/sksg/effects
diff options
context:
space:
mode:
Diffstat (limited to 'experimental/sksg/effects')
-rw-r--r--experimental/sksg/effects/SkSGClipEffect.cpp50
-rw-r--r--experimental/sksg/effects/SkSGClipEffect.h50
-rw-r--r--experimental/sksg/effects/SkSGMaskEffect.cpp54
-rw-r--r--experimental/sksg/effects/SkSGMaskEffect.h51
-rw-r--r--experimental/sksg/effects/SkSGOpacityEffect.cpp42
-rw-r--r--experimental/sksg/effects/SkSGOpacityEffect.h42
-rw-r--r--experimental/sksg/effects/SkSGTransform.cpp70
-rw-r--r--experimental/sksg/effects/SkSGTransform.h81
8 files changed, 0 insertions, 440 deletions
diff --git a/experimental/sksg/effects/SkSGClipEffect.cpp b/experimental/sksg/effects/SkSGClipEffect.cpp
deleted file mode 100644
index b2d68fc8cf..0000000000
--- a/experimental/sksg/effects/SkSGClipEffect.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2018 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkSGClipEffect.h"
-
-#include "SkCanvas.h"
-#include "SkPath.h"
-#include "SkSGGeometryNode.h"
-
-namespace sksg {
-
-ClipEffect::ClipEffect(sk_sp<RenderNode> child, sk_sp<GeometryNode> clip, bool aa)
- : INHERITED(std::move(child))
- , fClipNode(std::move(clip))
- , fAntiAlias(aa) {
- this->observeInval(fClipNode);
-}
-
-ClipEffect::~ClipEffect() {
- this->unobserveInval(fClipNode);
-}
-
-void ClipEffect::onRender(SkCanvas* canvas) const {
- if (this->bounds().isEmpty())
- return;
-
- SkAutoCanvasRestore acr(canvas, !fNoop);
- if (!fNoop) {
- fClipNode->clip(canvas, fAntiAlias);
- }
-
- this->INHERITED::onRender(canvas);
-}
-
-SkRect ClipEffect::onRevalidate(InvalidationController* ic, const SkMatrix& ctm) {
- SkASSERT(this->hasInval());
-
- const auto clipBounds = fClipNode->revalidate(ic, ctm);
- auto childBounds = this->INHERITED::onRevalidate(ic, ctm);
-
- fNoop = fClipNode->asPath().conservativelyContainsRect(childBounds);
-
- return childBounds.intersect(clipBounds) ? childBounds : SkRect::MakeEmpty();
-}
-
-} // namespace sksg
diff --git a/experimental/sksg/effects/SkSGClipEffect.h b/experimental/sksg/effects/SkSGClipEffect.h
deleted file mode 100644
index 674edb2b5c..0000000000
--- a/experimental/sksg/effects/SkSGClipEffect.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2018 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkSGClipEffect_DEFINED
-#define SkSGClipEffect_DEFINED
-
-#include "SkSGEffectNode.h"
-
-namespace sksg {
-
-class GeometryNode;
-
-/**
- * Concrete Effect node, applying a clip to its descendants.
- *
- */
-class ClipEffect final : public EffectNode {
-public:
- static sk_sp<ClipEffect> Make(sk_sp<RenderNode> child, sk_sp<GeometryNode> clip,
- bool aa = false) {
- return (child && clip)
- ? sk_sp<ClipEffect>(new ClipEffect(std::move(child), std::move(clip), aa))
- : nullptr;
- }
-
- ~ClipEffect() override;
-
-protected:
- ClipEffect(sk_sp<RenderNode>, sk_sp<GeometryNode>, bool aa);
-
- void onRender(SkCanvas*) const override;
-
- SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
-
-private:
- const sk_sp<GeometryNode> fClipNode;
- const bool fAntiAlias;
-
- bool fNoop = false;
-
- typedef EffectNode INHERITED;
-};
-
-} // namespace sksg
-
-#endif // SkSGClipEffect_DEFINED
diff --git a/experimental/sksg/effects/SkSGMaskEffect.cpp b/experimental/sksg/effects/SkSGMaskEffect.cpp
deleted file mode 100644
index 16e4c0dd8d..0000000000
--- a/experimental/sksg/effects/SkSGMaskEffect.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2018 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkSGMaskEffect.h"
-
-#include "SkCanvas.h"
-
-namespace sksg {
-
-MaskEffect::MaskEffect(sk_sp<RenderNode> child, sk_sp<RenderNode> mask, Mode mode)
- : INHERITED(std::move(child))
- , fMaskNode(std::move(mask))
- , fMaskMode(mode) {
- this->observeInval(fMaskNode);
-}
-
-MaskEffect::~MaskEffect() {
- this->unobserveInval(fMaskNode);
-}
-
-void MaskEffect::onRender(SkCanvas* canvas) const {
- if (this->bounds().isEmpty())
- return;
-
- SkAutoCanvasRestore acr(canvas, false);
-
- canvas->saveLayer(this->bounds(), nullptr);
- fMaskNode->render(canvas);
-
-
- SkPaint p;
- p.setBlendMode(fMaskMode == Mode::kNormal ? SkBlendMode::kSrcIn : SkBlendMode::kSrcOut);
- canvas->saveLayer(this->bounds(), &p);
-
- this->INHERITED::onRender(canvas);
-}
-
-
-SkRect MaskEffect::onRevalidate(InvalidationController* ic, const SkMatrix& ctm) {
- SkASSERT(this->hasInval());
-
- const auto maskBounds = fMaskNode->revalidate(ic, ctm);
- auto childBounds = this->INHERITED::onRevalidate(ic, ctm);
-
- return (fMaskMode == Mode::kInvert || childBounds.intersect(maskBounds))
- ? childBounds
- : SkRect::MakeEmpty();
-}
-
-} // namespace sksg
diff --git a/experimental/sksg/effects/SkSGMaskEffect.h b/experimental/sksg/effects/SkSGMaskEffect.h
deleted file mode 100644
index c4fd0120e5..0000000000
--- a/experimental/sksg/effects/SkSGMaskEffect.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2018 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkSGMaskEffect_DEFINED
-#define SkSGMaskEffect_DEFINED
-
-#include "SkSGEffectNode.h"
-
-namespace sksg {
-
-/**
- * Concrete Effect node, applying a mask to its descendants.
- *
- */
-class MaskEffect final : public EffectNode {
-public:
- enum class Mode {
- kNormal,
- kInvert
- };
-
- static sk_sp<MaskEffect> Make(sk_sp<RenderNode> child, sk_sp<RenderNode> mask,
- Mode mode = Mode::kNormal) {
- return (child && mask)
- ? sk_sp<MaskEffect>(new MaskEffect(std::move(child), std::move(mask), mode))
- : nullptr;
- }
-
- ~MaskEffect() override;
-
-protected:
- MaskEffect(sk_sp<RenderNode>, sk_sp<RenderNode> mask, Mode);
-
- void onRender(SkCanvas*) const override;
-
- SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
-
-private:
- const sk_sp<RenderNode> fMaskNode;
- const Mode fMaskMode;
-
- typedef EffectNode INHERITED;
-};
-
-} // namespace sksg
-
-#endif // SkSGMaskEffect_DEFINED
diff --git a/experimental/sksg/effects/SkSGOpacityEffect.cpp b/experimental/sksg/effects/SkSGOpacityEffect.cpp
deleted file mode 100644
index b1ff10d217..0000000000
--- a/experimental/sksg/effects/SkSGOpacityEffect.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2018 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkSGOpacityEffect.h"
-
-#include "SkCanvas.h"
-
-#include <math.h>
-
-namespace sksg {
-
-OpacityEffect::OpacityEffect(sk_sp<RenderNode> child, float opacity)
- : INHERITED(std::move(child))
- , fOpacity(opacity) {}
-
-void OpacityEffect::onRender(SkCanvas* canvas) const {
- // opacity <= 0 disables rendering
- if (fOpacity <= 0)
- return;
-
- // TODO: we could avoid savelayer if there is no more than one drawing primitive
- // in the sub-DAG.
- SkAutoCanvasRestore acr(canvas, false);
- if (fOpacity < 1) {
- canvas->saveLayerAlpha(&this->bounds(), roundf(fOpacity * 255));
- }
-
- this->INHERITED::onRender(canvas);
-}
-
-SkRect OpacityEffect::onRevalidate(InvalidationController* ic, const SkMatrix& ctm) {
- SkASSERT(this->hasInval());
-
- // opacity <= 0 disables rendering AND revalidation for the sub-DAG
- return fOpacity > 0 ? this->INHERITED::onRevalidate(ic, ctm) : SkRect::MakeEmpty();
-}
-
-} // namespace sksg
diff --git a/experimental/sksg/effects/SkSGOpacityEffect.h b/experimental/sksg/effects/SkSGOpacityEffect.h
deleted file mode 100644
index d906775b44..0000000000
--- a/experimental/sksg/effects/SkSGOpacityEffect.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2018 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkSGOpacityEffect_DEFINED
-#define SkSGOpacityEffect_DEFINED
-
-#include "SkSGEffectNode.h"
-
-namespace sksg {
-
-/**
- * Concrete Effect node, applying opacity to its descendants.
- *
- */
-class OpacityEffect final : public EffectNode {
-public:
- static sk_sp<OpacityEffect> Make(sk_sp<RenderNode> child, float opacity = 1) {
- return child ? sk_sp<OpacityEffect>(new OpacityEffect(std::move(child), opacity)) : nullptr;
- }
-
- SG_ATTRIBUTE(Opacity, float, fOpacity)
-
-protected:
- OpacityEffect(sk_sp<RenderNode>, float);
-
- void onRender(SkCanvas*) const override;
-
- SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
-
-private:
- float fOpacity;
-
- typedef EffectNode INHERITED;
-};
-
-} // namespace sksg
-
-#endif // SkSGOpacityEffect_DEFINED
diff --git a/experimental/sksg/effects/SkSGTransform.cpp b/experimental/sksg/effects/SkSGTransform.cpp
deleted file mode 100644
index 6a985a971e..0000000000
--- a/experimental/sksg/effects/SkSGTransform.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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) {
- this->observeInval(fParent);
- }
-}
-
-Matrix::~Matrix() {
- if (fParent) {
- this->unobserveInval(fParent);
- }
-}
-
-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)) {
- this->observeInval(fMatrix);
-}
-
-Transform::~Transform() {
- this->unobserveInval(fMatrix);
-}
-
-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
diff --git a/experimental/sksg/effects/SkSGTransform.h b/experimental/sksg/effects/SkSGTransform.h
deleted file mode 100644
index 6b7fbc010b..0000000000
--- a/experimental/sksg/effects/SkSGTransform.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2017 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkSGTransform_DEFINED
-#define SkSGTransform_DEFINED
-
-#include "SkSGEffectNode.h"
-
-#include "SkMatrix.h"
-
-namespace sksg {
-
-/**
- * Concrete node, wrapping an SkMatrix, with an optional parent Matrix (to allow chaining):
- *
- * M' = parent x M
- */
-class Matrix : public Node {
-public:
- static sk_sp<Matrix> Make(const SkMatrix& m, sk_sp<Matrix> parent = nullptr) {
- return sk_sp<Matrix>(new Matrix(m, std::move(parent)));
- }
-
- ~Matrix() override;
-
- SG_ATTRIBUTE(Matrix, SkMatrix, fLocalMatrix)
-
- const SkMatrix& getTotalMatrix() const { return fTotalMatrix; }
-
-protected:
- Matrix(const SkMatrix&, sk_sp<Matrix>);
-
- SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
-
-private:
- sk_sp<Matrix> fParent;
- SkMatrix fLocalMatrix,
- fTotalMatrix; // cached during revalidation
-
- typedef Node INHERITED;
-};
-
-/**
- * Concrete Effect node, binding a Matrix to a RenderNode.
- */
-class Transform final : public EffectNode {
-public:
- static sk_sp<Transform> Make(sk_sp<RenderNode> child, sk_sp<Matrix> matrix) {
- return child && matrix
- ? sk_sp<Transform>(new Transform(std::move(child), std::move(matrix)))
- : nullptr;
- }
-
- static sk_sp<Transform> Make(sk_sp<RenderNode> child, const SkMatrix& m) {
- return Make(std::move(child), Matrix::Make(m));
- }
-
- ~Transform() override;
-
- const sk_sp<Matrix>& getMatrix() const { return fMatrix; }
-
-protected:
- void onRender(SkCanvas*) const override;
-
- SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
-
-private:
- Transform(sk_sp<RenderNode>, sk_sp<Matrix>);
-
- const sk_sp<Matrix> fMatrix;
-
- typedef EffectNode INHERITED;
-};
-
-} // namespace sksg
-
-#endif // SkSGTransform_DEFINED