• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkSGDraw_DEFINED
9 #define SkSGDraw_DEFINED
10 
11 #include "SkSGGeometryNode.h"
12 #include "SkSGPaintNode.h"
13 #include "SkSGRenderNode.h"
14 
15 namespace sksg {
16 
17 /**
18  * Concrete rendering node.
19  *
20  * Wraps and draws a [geometry, paint] tuple.
21  *
22  * Think Skia SkCanvas::drawFoo(foo, paint) calls.
23  */
24 class Draw : public RenderNode {
25 public:
Make(sk_sp<GeometryNode> geo,sk_sp<PaintNode> paint)26     static sk_sp<Draw> Make(sk_sp<GeometryNode> geo, sk_sp<PaintNode> paint) {
27         return (geo && paint) ? sk_sp<Draw>(new Draw(std::move(geo), std::move(paint))) : nullptr;
28     }
29 
30 protected:
31     Draw(sk_sp<GeometryNode>, sk_sp<PaintNode> paint);
32     ~Draw() override;
33 
34     void onRender(SkCanvas*, const RenderContext*) const override;
35     const RenderNode* onNodeAt(const SkPoint&)     const override;
36 
37     SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
38 
39 private:
40     sk_sp<GeometryNode> fGeometry;
41     sk_sp<PaintNode>    fPaint;
42 
43     typedef RenderNode INHERITED;
44 };
45 
46 } // namespace sksg
47 
48 #endif // SkSGDraw_DEFINED
49