aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/sksg/SkSGGroup.h
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2017-12-19 12:21:02 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-21 20:56:32 +0000
commit4aa4441186b06565a597ec4a9baac5a972fddb51 (patch)
tree8ae7cb5e988f3b89dfea886e118931e78013ff63 /experimental/sksg/SkSGGroup.h
parentf059e7ca181ad20fa94edea65c8bfd839eceab46 (diff)
Initial scene graph (SkSG)
Sketching a thin (as in close-to-skia-semantics) scene graph API, focused on external animation, inval tracking and minimal repaint. Only a few concrete classes/features so far: * Rect/Color/Transform/Group * basic inval tracking * a trivial animated sample with inval visualization Pretty much everything (especially naming) is volatile, so treat accordingly. The interesting bits to review are likely in Node.{h,cpp} for inval and SampleSGInval.cpp for usage. Initial class hierarchy: * Node: invalidation/ancestors tracking | -- * RenderNode: onRender(SkCanvas) | | | -- * Draw (concrete): rendering a [geometry, paint] tuple | | | -- * Group (concrete): grouping multiple RenderNodes | | | -- * EffectNode: single-descendant effect wrapper | | | -- * Transform (concrete): transform effect | -- * PaintNode: onMakePaint() | | | -- * Color (concrete): SkColor paint wrapper | -- * GeometryNode: onComputeBounds(), onDraw(SkCanvas, SkPaint) | -- * Rect (concrete): SkRect wrapper TBR= Change-Id: Iacf9b773c181a7582ecd31ee968562f179d1aa1b Reviewed-on: https://skia-review.googlesource.com/85502 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental/sksg/SkSGGroup.h')
-rw-r--r--experimental/sksg/SkSGGroup.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/experimental/sksg/SkSGGroup.h b/experimental/sksg/SkSGGroup.h
new file mode 100644
index 0000000000..2ed9d0ecb5
--- /dev/null
+++ b/experimental/sksg/SkSGGroup.h
@@ -0,0 +1,44 @@
+/*
+ * 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 SkSGGroup_DEFINED
+#define SkSGGroup_DEFINED
+
+#include "SkSGRenderNode.h"
+
+#include "SkTArray.h"
+
+namespace sksg {
+
+/**
+ * Concrete node, grouping together multiple descendants.
+ */
+class Group : public RenderNode {
+public:
+ static sk_sp<Group> Make() {
+ return sk_sp<Group>(new Group());
+ }
+
+ void addChild(sk_sp<RenderNode>);
+ void removeChild(const sk_sp<RenderNode>&);
+
+protected:
+ Group();
+ ~Group() override;
+
+ void onRender(SkCanvas*) const override;
+ void onRevalidate(InvalidationController*, const SkMatrix&) override;
+
+private:
+ SkTArray<sk_sp<RenderNode>, true> fChildren;
+
+ typedef RenderNode INHERITED;
+};
+
+} // namespace sksg
+
+#endif // SkSGGroup_DEFINED