| 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 SkSVGValue_DEFINED | 8 #ifndef SkSVGValue_DEFINED |
| 9 #define SkSVGValue_DEFINED | 9 #define SkSVGValue_DEFINED |
| 10 | 10 |
| 11 #include "SkColor.h" | 11 #include "SkColor.h" |
| 12 #include "SkMatrix.h" | 12 #include "SkMatrix.h" |
| 13 #include "SkPath.h" | 13 #include "SkPath.h" |
| 14 #include "SkSVGTypes.h" | 14 #include "SkSVGTypes.h" |
| 15 #include "SkTypes.h" | 15 #include "SkTypes.h" |
| 16 | 16 |
| 17 class SkSVGValue : public SkNoncopyable { | 17 class SkSVGValue : public SkNoncopyable { |
| 18 public: | 18 public: |
| 19 enum class Type { | 19 enum class Type { |
| 20 kColor, | 20 kColor, |
| 21 kLength, | 21 kLength, |
| 22 kLineCap, | 22 kLineCap, |
| 23 kLineJoin, | 23 kLineJoin, |
| 24 kNumber, | 24 kNumber, |
| 25 kPaint, | 25 kPaint, |
| 26 kPath, | 26 kPath, |
| 27 kPoints, | 27 kPoints, |
| 28 kSpreadMethod, |
| 28 kString, | 29 kString, |
| 29 kTransform, | 30 kTransform, |
| 30 kViewBox, | 31 kViewBox, |
| 31 }; | 32 }; |
| 32 | 33 |
| 33 Type type() const { return fType; } | 34 Type type() const { return fType; } |
| 34 | 35 |
| 35 template <typename T> | 36 template <typename T> |
| 36 const T* as() const { | 37 const T* as() const { |
| 37 return fType == T::TYPE ? static_cast<const T*>(this) : nullptr; | 38 return fType == T::TYPE ? static_cast<const T*>(this) : nullptr; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 61 private: | 62 private: |
| 62 // Stack-only | 63 // Stack-only |
| 63 void* operator new(size_t) = delete; | 64 void* operator new(size_t) = delete; |
| 64 void* operator new(size_t, void*) = delete; | 65 void* operator new(size_t, void*) = delete; |
| 65 | 66 |
| 66 const T& fWrappedValue; | 67 const T& fWrappedValue; |
| 67 | 68 |
| 68 typedef SkSVGValue INHERITED; | 69 typedef SkSVGValue INHERITED; |
| 69 }; | 70 }; |
| 70 | 71 |
| 71 using SkSVGColorValue = SkSVGWrapperValue<SkSVGColorType , SkSVGValue::Ty
pe::kColor >; | 72 using SkSVGColorValue = SkSVGWrapperValue<SkSVGColorType , SkSVGValue:
:Type::kColor >; |
| 72 using SkSVGLengthValue = SkSVGWrapperValue<SkSVGLength , SkSVGValue::Ty
pe::kLength >; | 73 using SkSVGLengthValue = SkSVGWrapperValue<SkSVGLength , SkSVGValue:
:Type::kLength >; |
| 73 using SkSVGPathValue = SkSVGWrapperValue<SkPath , SkSVGValue::Ty
pe::kPath >; | 74 using SkSVGPathValue = SkSVGWrapperValue<SkPath , SkSVGValue:
:Type::kPath >; |
| 74 using SkSVGTransformValue = SkSVGWrapperValue<SkSVGTransformType, SkSVGValue::Ty
pe::kTransform>; | 75 using SkSVGTransformValue = SkSVGWrapperValue<SkSVGTransformType, SkSVGValue:
:Type::kTransform>; |
| 75 using SkSVGViewBoxValue = SkSVGWrapperValue<SkSVGViewBoxType , SkSVGValue::Ty
pe::kViewBox >; | 76 using SkSVGViewBoxValue = SkSVGWrapperValue<SkSVGViewBoxType , SkSVGValue:
:Type::kViewBox >; |
| 76 using SkSVGPaintValue = SkSVGWrapperValue<SkSVGPaint , SkSVGValue::Ty
pe::kPaint >; | 77 using SkSVGPaintValue = SkSVGWrapperValue<SkSVGPaint , SkSVGValue:
:Type::kPaint >; |
| 77 using SkSVGLineCapValue = SkSVGWrapperValue<SkSVGLineCap , SkSVGValue::Ty
pe::kLineCap >; | 78 using SkSVGLineCapValue = SkSVGWrapperValue<SkSVGLineCap , SkSVGValue:
:Type::kLineCap >; |
| 78 using SkSVGLineJoinValue = SkSVGWrapperValue<SkSVGLineJoin , SkSVGValue::Ty
pe::kLineJoin >; | 79 using SkSVGLineJoinValue = SkSVGWrapperValue<SkSVGLineJoin , SkSVGValue:
:Type::kLineJoin >; |
| 79 using SkSVGNumberValue = SkSVGWrapperValue<SkSVGNumberType , SkSVGValue::Ty
pe::kNumber >; | 80 using SkSVGNumberValue = SkSVGWrapperValue<SkSVGNumberType , SkSVGValue:
:Type::kNumber >; |
| 80 using SkSVGPointsValue = SkSVGWrapperValue<SkSVGPointsType , SkSVGValue::Ty
pe::kPoints >; | 81 using SkSVGPointsValue = SkSVGWrapperValue<SkSVGPointsType , SkSVGValue:
:Type::kPoints >; |
| 81 using SkSVGStringValue = SkSVGWrapperValue<SkSVGStringType , SkSVGValue::Ty
pe::kString >; | 82 using SkSVGStringValue = SkSVGWrapperValue<SkSVGStringType , SkSVGValue:
:Type::kString >; |
| 83 using SkSVGSpreadMethodValue = SkSVGWrapperValue<SkSVGSpreadMethod , |
| 84 SkSVGValue::Type::kSpreadMethod
>; |
| 82 | 85 |
| 83 #endif // SkSVGValue_DEFINED | 86 #endif // SkSVGValue_DEFINED |
| OLD | NEW |