OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkSVGAttributeParser_DEFINED | 8 #ifndef SkSVGAttributeParser_DEFINED |
9 #define SkSVGAttributeParser_DEFINED | 9 #define SkSVGAttributeParser_DEFINED |
10 | 10 |
11 #include "SkSVGTypes.h" | 11 #include "SkSVGTypes.h" |
12 | 12 |
13 class SkSVGAttributeParser : public SkNoncopyable { | 13 class SkSVGAttributeParser : public SkNoncopyable { |
14 public: | 14 public: |
15 SkSVGAttributeParser(const char[]); | 15 SkSVGAttributeParser(const char[]); |
16 | 16 |
17 bool parseColor(SkSVGColorType*); | 17 bool parseColor(SkSVGColorType*); |
18 bool parseNumber(SkSVGNumberType*); | 18 bool parseNumber(SkSVGNumberType*); |
19 bool parseLength(SkSVGLength*); | 19 bool parseLength(SkSVGLength*); |
20 bool parseViewBox(SkSVGViewBoxType*); | 20 bool parseViewBox(SkSVGViewBoxType*); |
| 21 bool parseTransform(SkSVGTransformType*); |
21 | 22 |
22 private: | 23 private: |
23 // Stack-only | 24 // Stack-only |
24 void* operator new(size_t) = delete; | 25 void* operator new(size_t) = delete; |
25 void* operator new(size_t, void*) = delete; | 26 void* operator new(size_t, void*) = delete; |
26 | 27 |
27 template <typename F> | 28 template <typename F> |
28 bool advanceWhile(F func); | 29 bool advanceWhile(F func); |
29 | 30 |
30 bool parseWSToken(); | 31 bool parseWSToken(); |
31 bool parseEOSToken(); | 32 bool parseEOSToken(); |
32 bool parseSepToken(); | 33 bool parseSepToken(); |
33 bool parseExpectedStringToken(const char*); | 34 bool parseExpectedStringToken(const char*); |
34 bool parseScalarToken(SkScalar*); | 35 bool parseScalarToken(SkScalar*); |
35 bool parseHexToken(uint32_t*); | 36 bool parseHexToken(uint32_t*); |
36 bool parseLengthUnitToken(SkSVGLength::Unit*); | 37 bool parseLengthUnitToken(SkSVGLength::Unit*); |
37 bool parseNamedColorToken(SkColor*); | 38 bool parseNamedColorToken(SkColor*); |
38 bool parseHexColorToken(SkColor*); | 39 bool parseHexColorToken(SkColor*); |
39 | 40 |
| 41 // Transform helpers |
| 42 bool parseMatrixToken(SkMatrix*); |
| 43 bool parseTranslateToken(SkMatrix*); |
| 44 bool parseScaleToken(SkMatrix*); |
| 45 bool parseRotateToken(SkMatrix*); |
| 46 bool parseSkewXToken(SkMatrix*); |
| 47 bool parseSkewYToken(SkMatrix*); |
| 48 |
| 49 // Parses a sequence of 'WS* <prefix> WS* (<nested>)', where the nested sequ
ence |
| 50 // is handled by the passed functor. |
| 51 template <typename Func, typename T> |
| 52 bool parseParenthesized(const char* prefix, Func, T* result); |
| 53 |
40 // The current position in the input string. | 54 // The current position in the input string. |
41 const char* fCurPos; | 55 const char* fCurPos; |
42 | 56 |
43 typedef SkNoncopyable INHERITED; | 57 typedef SkNoncopyable INHERITED; |
44 }; | 58 }; |
45 | 59 |
46 #endif // SkSVGAttributeParser_DEFINED | 60 #endif // SkSVGAttributeParser_DEFINED |
OLD | NEW |