From 97b3d2bcdb862b13a6a3f7a0b263bd04e2b8f911 Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Tue, 20 Feb 2018 11:26:15 -0500 Subject: [sksg] Add 'plane' geometry node SG geometry corresponding to SkCanvas::drawPaint(). TBR= Change-Id: I3b368adda187fb92f524756496a3694c03a3113d Reviewed-on: https://skia-review.googlesource.com/108562 Reviewed-by: Florin Malita Commit-Queue: Florin Malita --- experimental/sksg/geometry/SkSGPlane.cpp | 36 ++++++++++++++++++++++++++++ experimental/sksg/geometry/SkSGPlane.h | 40 ++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 experimental/sksg/geometry/SkSGPlane.cpp create mode 100644 experimental/sksg/geometry/SkSGPlane.h (limited to 'experimental') diff --git a/experimental/sksg/geometry/SkSGPlane.cpp b/experimental/sksg/geometry/SkSGPlane.cpp new file mode 100644 index 0000000000..806fcc7d29 --- /dev/null +++ b/experimental/sksg/geometry/SkSGPlane.cpp @@ -0,0 +1,36 @@ +/* + * 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 "SkSGPlane.h" + +#include "SkCanvas.h" +#include "SkPath.h" + +namespace sksg { + +Plane::Plane() = default; + +void Plane::onClip(SkCanvas*, bool) const {} + +void Plane::onDraw(SkCanvas* canvas, const SkPaint& paint) const { + canvas->drawPaint(paint); +} + +SkRect Plane::onRevalidate(InvalidationController*, const SkMatrix&) { + SkASSERT(this->hasInval()); + + return SkRect::MakeLTRB(SK_ScalarMin, SK_ScalarMin, SK_ScalarMax, SK_ScalarMax); +} + +SkPath Plane::onAsPath() const { + SkPath path; + path.setFillType(SkPath::kInverseWinding_FillType); + + return path; +} + +} // namespace sksg diff --git a/experimental/sksg/geometry/SkSGPlane.h b/experimental/sksg/geometry/SkSGPlane.h new file mode 100644 index 0000000000..c0a26375b2 --- /dev/null +++ b/experimental/sksg/geometry/SkSGPlane.h @@ -0,0 +1,40 @@ +/* + * 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 SkSGPlane_DEFINED +#define SkSGPlane_DEFINED + +#include "SkSGGeometryNode.h" + +class SkCanvas; +class SkPaint; + +namespace sksg { + +/** + * Concrete Geometry node, representing the whole canvas. + */ +class Plane final : public GeometryNode { +public: + static sk_sp Make() { return sk_sp(new Plane()); } + +protected: + void onClip(SkCanvas*, bool antiAlias) const override; + void onDraw(SkCanvas*, const SkPaint&) const override; + + SkRect onRevalidate(InvalidationController*, const SkMatrix&) override; + SkPath onAsPath() const override; + +private: + Plane(); + + using INHERITED = GeometryNode; +}; + +} // namespace sksg + +#endif // SkSGPlane_DEFINED -- cgit v1.2.3