michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #ifndef SkSVGElements_DEFINED michael@0: #define SkSVGElements_DEFINED michael@0: michael@0: #include "SkSVGPaintState.h" michael@0: #include "SkSVGTypes.h" michael@0: #include "SkTDArray.h" michael@0: michael@0: class SkSVGParser; michael@0: michael@0: #define DECLARE_SVG_INFO(_type) \ michael@0: public: \ michael@0: virtual ~SkSVG##_type(); \ michael@0: static const SkSVGAttribute gAttributes[]; \ michael@0: virtual int getAttributes(const SkSVGAttribute** attrPtr); \ michael@0: virtual SkSVGTypes getType() const; \ michael@0: virtual void translate(SkSVGParser& parser, bool defState); \ michael@0: typedef SkSVG##_type BASE_CLASS michael@0: michael@0: #define DEFINE_SVG_INFO(_type) \ michael@0: SkSVG##_type::~SkSVG##_type() {} \ michael@0: int SkSVG##_type::getAttributes(const SkSVGAttribute** attrPtr) { \ michael@0: *attrPtr = gAttributes; \ michael@0: return SK_ARRAY_COUNT(gAttributes); \ michael@0: } \ michael@0: SkSVGTypes SkSVG##_type::getType() const { return SkSVGType_##_type; } michael@0: michael@0: #define DEFINE_SVG_NO_INFO(_type) \ michael@0: SkSVG##_type::~SkSVG##_type() {} \ michael@0: int SkSVG##_type::getAttributes(const SkSVGAttribute** ) { return 0; } \ michael@0: SkSVGTypes SkSVG##_type::getType() const { return SkSVGType_##_type; } michael@0: michael@0: michael@0: struct SkSVGTypeName { michael@0: const char* fName; michael@0: SkSVGTypes fType; michael@0: }; michael@0: michael@0: class SkSVGElement : public SkSVGBase { michael@0: public: michael@0: SkSVGElement(); michael@0: virtual ~SkSVGElement(); michael@0: virtual SkSVGElement* getGradient(); michael@0: virtual SkSVGTypes getType() const = 0; michael@0: virtual bool isDef(); michael@0: virtual bool isFlushable(); michael@0: virtual bool isGroup(); michael@0: virtual bool isNotDef(); michael@0: virtual bool onEndElement(SkSVGParser& parser); michael@0: virtual bool onStartElement(SkSVGElement* child); michael@0: void setIsDef(); michael@0: // void setIsNotDef(); michael@0: virtual void translate(SkSVGParser& parser, bool defState); michael@0: virtual void write(SkSVGParser& , SkString& color); michael@0: SkString f_id; michael@0: SkSVGPaint fPaintState; michael@0: SkTDArray fChildren; michael@0: SkSVGElement* fParent; michael@0: bool fIsDef; michael@0: bool fIsNotDef; michael@0: private: michael@0: bool isGroupParent(); michael@0: }; michael@0: michael@0: #endif // SkSVGElements_DEFINED