blob: 20ead3d5f6a91f6d1f2e57700b37439cd7f55091 [file] [log] [blame]
Florin Malita4aa44412017-12-19 12:21:02 -05001/*
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
13namespace sksg {
14
15class GeometryNode;
16class 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 */
25class Draw : public RenderNode {
26public:
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
31protected:
32 Draw(sk_sp<GeometryNode>, sk_sp<PaintNode> paint);
33 ~Draw() override;
34
35 void onRender(SkCanvas*) const override;
36
Florin Malitac75e2402018-01-03 16:17:29 -050037 SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
Florin Malita4aa44412017-12-19 12:21:02 -050038
39private:
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