blob: d00e43474279f506cc96d2d6f2da7a6a7eeff5ed [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
reed@android.com8a1c16f2008-12-17 15:59:43 +00009
10#ifndef SkSVGElements_DEFINED
11#define SkSVGElements_DEFINED
12
13#include "SkSVGPaintState.h"
14#include "SkSVGTypes.h"
15#include "SkTDArray.h"
16
17class SkSVGParser;
18
19#define DECLARE_SVG_INFO(_type) \
20public: \
21 virtual ~SkSVG##_type(); \
22 static const SkSVGAttribute gAttributes[]; \
23 virtual int getAttributes(const SkSVGAttribute** attrPtr); \
24 virtual SkSVGTypes getType() const; \
25 virtual void translate(SkSVGParser& parser, bool defState); \
26 typedef SkSVG##_type BASE_CLASS
27
28#define DEFINE_SVG_INFO(_type) \
29 SkSVG##_type::~SkSVG##_type() {} \
30 int SkSVG##_type::getAttributes(const SkSVGAttribute** attrPtr) { \
31 *attrPtr = gAttributes; \
32 return SK_ARRAY_COUNT(gAttributes); \
33 } \
34 SkSVGTypes SkSVG##_type::getType() const { return SkSVGType_##_type; }
35
36#define DEFINE_SVG_NO_INFO(_type) \
37 SkSVG##_type::~SkSVG##_type() {} \
38 int SkSVG##_type::getAttributes(const SkSVGAttribute** ) { return 0; } \
39 SkSVGTypes SkSVG##_type::getType() const { return SkSVGType_##_type; }
40
41
42struct SkSVGTypeName {
43 const char* fName;
44 SkSVGTypes fType;
45};
46
47class SkSVGElement : public SkSVGBase {
48public:
49 SkSVGElement();
50 virtual ~SkSVGElement();
51 virtual SkSVGElement* getGradient();
52 virtual SkSVGTypes getType() const = 0;
53 virtual bool isDef();
54 virtual bool isFlushable();
55 virtual bool isGroup();
56 virtual bool isNotDef();
57 virtual bool onEndElement(SkSVGParser& parser);
58 virtual bool onStartElement(SkSVGElement* child);
59 void setIsDef();
60// void setIsNotDef();
61 virtual void translate(SkSVGParser& parser, bool defState);
62 virtual void write(SkSVGParser& , SkString& color);
63 SkString f_id;
64 SkSVGPaint fPaintState;
65 SkTDArray<SkSVGElement*> fChildren;
66 SkSVGElement* fParent;
67 bool fIsDef;
68 bool fIsNotDef;
69private:
70 bool isGroupParent();
71};
72
73#endif // SkSVGElements_DEFINED