OLD | NEW |
| (Empty) |
1 | |
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 | |
9 | |
10 #ifndef SkSVGParser_DEFINED | |
11 #define SkSVGParser_DEFINED | |
12 | |
13 #include "SkMatrix.h" | |
14 #include "../private/SkTDict.h" | |
15 #include "SkSVGPaintState.h" | |
16 #include "SkSVGTypes.h" | |
17 #include "SkStream.h" | |
18 #include "SkString.h" | |
19 #include "SkXMLParser.h" | |
20 #include "SkXMLWriter.h" | |
21 | |
22 class SkSVGBase; | |
23 class SkSVGElement; | |
24 | |
25 class SkSVGParser : public SkXMLParser { | |
26 public: | |
27 SkSVGParser(SkXMLParserError* err = NULL); | |
28 virtual ~SkSVGParser(); | |
29 void _addAttribute(const char* attrName, const char* attrValue) { | |
30 fXMLWriter.addAttribute(attrName, attrValue); } | |
31 void _addAttribute(const char* attrName, SkString& attrValue) { | |
32 fXMLWriter.addAttribute(attrName, attrValue.c_str()); } | |
33 void _addAttributeLen(const char* attrName, const char* attrValue, size_t le
n) { | |
34 fXMLWriter.addAttributeLen(attrName, attrValue, len); } | |
35 void _endElement() { fXMLWriter.endElement(); } | |
36 int findAttribute(SkSVGBase* , const char* attrValue, size_t len, bool isPai
nt); | |
37 // const char* getFinal(); | |
38 SkTDict<SkSVGElement*>& getIDs() { return fIDs; } | |
39 SkString& getPaintLast(SkSVGPaint::Field field); | |
40 void _startElement(const char name[]) { fXMLWriter.startElement(name); } | |
41 void translate(SkSVGElement*, bool isDef); | |
42 void translateMatrix(SkString& , SkString* id); | |
43 static void ConvertToArray(SkString& vals); | |
44 protected: | |
45 virtual bool onAddAttribute(const char name[], const char value[]); | |
46 bool onAddAttributeLen(const char name[], const char value[], size_t len); | |
47 virtual bool onEndElement(const char elem[]); | |
48 virtual bool onStartElement(const char elem[]); | |
49 bool onStartElementLen(const char elem[], size_t len); | |
50 virtual bool onText(const char text[], int len); | |
51 private: | |
52 bool isStrokeAndFill(SkSVGPaint** stroke, SkSVGPaint** fill); | |
53 static SkSVGElement* CreateElement(SkSVGTypes type, SkSVGElement* parent); | |
54 static void Delete(SkTDArray<SkSVGElement*>& fChildren); | |
55 static SkSVGTypes GetType(const char name[], size_t len); | |
56 SkSVGPaint* fHead; | |
57 SkSVGPaint fEmptyPaint; | |
58 SkSVGPaint fLastFlush; | |
59 SkString fLastColor; | |
60 SkMatrix fLastTransform; | |
61 SkTDArray<SkSVGElement*> fChildren; | |
62 SkTDict<SkSVGElement*> fIDs; | |
63 SkTDArray<SkSVGElement*> fParents; | |
64 SkDynamicMemoryWStream fStream; | |
65 SkXMLStreamWriter fXMLWriter; | |
66 SkSVGElement* fCurrElement; | |
67 SkBool8 fInSVG; | |
68 SkBool8 fSuppressPaint; | |
69 friend class SkSVGPaint; | |
70 friend class SkSVGGradient; | |
71 }; | |
72 | |
73 #endif // SkSVGParser_DEFINED | |
OLD | NEW |