• 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 "SkSGRenderNode.h"
12 
13 namespace sksg {
14 
15 class GeometryNode;
16 class PaintNode;
17 
18 /**
19  * Concrete rendering node.
20  *
21  * Wraps and draws a [geometry, paint] tuple.
22  *
23  * Think Skia SkCanvas::drawFoo(foo, paint) calls.
24  */
25 class Draw : public RenderNode {
26 public:
Make(sk_sp<GeometryNode> geo,sk_sp<PaintNode> paint)27     static sk_sp<Draw> Make(sk_sp<GeometryNode> geo, sk_sp<PaintNode> paint) {
28         return (geo && paint) ? sk_sp<Draw>(new Draw(std::move(geo), std::move(paint))) : nullptr;
29     }
30 
31 protected:
32     Draw(sk_sp<GeometryNode>, sk_sp<PaintNode> paint);
33     ~Draw() override;
34 
35     void onRender(SkCanvas*, const RenderContext*) 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