blob: de180146b783b0b49e4e56d18bb7e889997eeacd [file] [log] [blame]
fmalita6ceef3d2016-07-26 18:46:34 -07001/*
2 * Copyright 2016 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 SkSVGNode_DEFINED
9#define SkSVGNode_DEFINED
10
11#include "SkRefCnt.h"
12#include "SkSVGAttribute.h"
13
14class SkCanvas;
15class SkMatrix;
16class SkSVGRenderContext;
17class SkSVGValue;
18
19enum class SkSVGTag {
20 g,
21 path,
22 svg
23};
24
25class SkSVGNode : public SkRefCnt {
26public:
27 virtual ~SkSVGNode();
28
29 SkSVGTag tag() const { return fTag; }
30
31 virtual void appendChild(sk_sp<SkSVGNode>) = 0;
32
33 void render(SkCanvas*) const;
34 void render(SkCanvas*, const SkSVGRenderContext&) const;
35
36 void setAttribute(SkSVGAttribute, const SkSVGValue&);
37
38protected:
39 SkSVGNode(SkSVGTag);
40
41 virtual void onRender(SkCanvas*, const SkSVGRenderContext&) const = 0;
42
43 virtual void onSetAttribute(SkSVGAttribute, const SkSVGValue&);
44
45 virtual const SkMatrix& onLocalMatrix() const;
46
47private:
48 SkSVGTag fTag;
49
50 // FIXME: this should be sparse
51 SkSVGPresentationAttributes fPresentationAttributes;
52
53 typedef SkRefCnt INHERITED;
54};
55
56#endif // SkSVGNode_DEFINED