aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2017-12-27 11:13:13 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-27 16:32:15 +0000
commit047ae274319c7f4055b6c7a5c1ca53147fe4712a (patch)
tree87168d897fad5954e2f5d2e7ae996f073121ea49 /experimental
parent68c8156cdfd115beec575bcd14365a330da28859 (diff)
[sksg] Initial Path support
TBR= Change-Id: I594634d339b5e1ad9181dc5303af1a1c754d0fe3 Reviewed-on: https://skia-review.googlesource.com/89540 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental')
-rw-r--r--experimental/sksg/geometry/SkSGPath.cpp25
-rw-r--r--experimental/sksg/geometry/SkSGPath.h43
2 files changed, 68 insertions, 0 deletions
diff --git a/experimental/sksg/geometry/SkSGPath.cpp b/experimental/sksg/geometry/SkSGPath.cpp
new file mode 100644
index 0000000000..8a1550a8f7
--- /dev/null
+++ b/experimental/sksg/geometry/SkSGPath.cpp
@@ -0,0 +1,25 @@
+/*
+ * 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 "SkSGPath.h"
+
+#include "SkCanvas.h"
+#include "SkPaint.h"
+
+namespace sksg {
+
+Path::Path(const SkPath& path) : fPath(path) {}
+
+void Path::onDraw(SkCanvas* canvas, const SkPaint& paint) const {
+ canvas->drawPath(fPath, paint);
+}
+
+SkRect Path::onComputeBounds() const {
+ return fPath.computeTightBounds();
+}
+
+} // namespace sksg
diff --git a/experimental/sksg/geometry/SkSGPath.h b/experimental/sksg/geometry/SkSGPath.h
new file mode 100644
index 0000000000..42c56188a2
--- /dev/null
+++ b/experimental/sksg/geometry/SkSGPath.h
@@ -0,0 +1,43 @@
+/*
+ * 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 SkSGPath_DEFINED
+#define SkSGPath_DEFINED
+
+#include "SkSGGeometryNode.h"
+
+#include "SkPath.h"
+
+class SkCanvas;
+class SkPaint;
+
+namespace sksg {
+
+/**
+ * Concrete Geometry node, wrapping an SkPath.
+ */
+class Path : public GeometryNode {
+public:
+ static sk_sp<Path> Make() { return sk_sp<Path>(new Path(SkPath())); }
+ static sk_sp<Path> Make(const SkPath& r) { return sk_sp<Path>(new Path(r)); }
+
+ SG_ATTRIBUTE(Path, SkPath, fPath)
+
+protected:
+ void onDraw(SkCanvas*, const SkPaint&) const override;
+
+ SkRect onComputeBounds() const override;
+
+private:
+ explicit Path(const SkPath&);
+
+ SkPath fPath;
+};
+
+} // namespace sksg
+
+#endif // SkSGPath_DEFINED