1 /* libs/graphics/svg/SkSVGElements.h 2 ** 3 ** Copyright 2006, The Android Open Source Project 4 ** 5 ** Licensed under the Apache License, Version 2.0 (the "License"); 6 ** you may not use this file except in compliance with the License. 7 ** You may obtain a copy of the License at 8 ** 9 ** http://www.apache.org/licenses/LICENSE-2.0 10 ** 11 ** Unless required by applicable law or agreed to in writing, software 12 ** distributed under the License is distributed on an "AS IS" BASIS, 13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 ** See the License for the specific language governing permissions and 15 ** limitations under the License. 16 */ 17 18 #ifndef SkSVGElements_DEFINED 19 #define SkSVGElements_DEFINED 20 21 #include "SkSVGPaintState.h" 22 #include "SkSVGTypes.h" 23 #include "SkTDArray.h" 24 25 class SkSVGParser; 26 27 #define DECLARE_SVG_INFO(_type) \ 28 public: \ 29 virtual ~SkSVG##_type(); \ 30 static const SkSVGAttribute gAttributes[]; \ 31 virtual int getAttributes(const SkSVGAttribute** attrPtr); \ 32 virtual SkSVGTypes getType() const; \ 33 virtual void translate(SkSVGParser& parser, bool defState); \ 34 typedef SkSVG##_type BASE_CLASS 35 36 #define DEFINE_SVG_INFO(_type) \ 37 SkSVG##_type::~SkSVG##_type() {} \ 38 int SkSVG##_type::getAttributes(const SkSVGAttribute** attrPtr) { \ 39 *attrPtr = gAttributes; \ 40 return SK_ARRAY_COUNT(gAttributes); \ 41 } \ 42 SkSVGTypes SkSVG##_type::getType() const { return SkSVGType_##_type; } 43 44 #define DEFINE_SVG_NO_INFO(_type) \ 45 SkSVG##_type::~SkSVG##_type() {} \ 46 int SkSVG##_type::getAttributes(const SkSVGAttribute** ) { return 0; } \ 47 SkSVGTypes SkSVG##_type::getType() const { return SkSVGType_##_type; } 48 49 50 struct SkSVGTypeName { 51 const char* fName; 52 SkSVGTypes fType; 53 }; 54 55 class SkSVGElement : public SkSVGBase { 56 public: 57 SkSVGElement(); 58 virtual ~SkSVGElement(); 59 virtual SkSVGElement* getGradient(); 60 virtual SkSVGTypes getType() const = 0; 61 virtual bool isDef(); 62 virtual bool isFlushable(); 63 virtual bool isGroup(); 64 virtual bool isNotDef(); 65 virtual bool onEndElement(SkSVGParser& parser); 66 virtual bool onStartElement(SkSVGElement* child); 67 void setIsDef(); 68 // void setIsNotDef(); 69 virtual void translate(SkSVGParser& parser, bool defState); 70 virtual void write(SkSVGParser& , SkString& color); 71 SkString f_id; 72 SkSVGPaint fPaintState; 73 SkTDArray<SkSVGElement*> fChildren; 74 SkSVGElement* fParent; 75 bool fIsDef; 76 bool fIsNotDef; 77 private: 78 bool isGroupParent(); 79 }; 80 81 #endif // SkSVGElements_DEFINED 82