| 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 SkSVGTypes_DEFINED | 8 #ifndef SkSVGTypes_DEFINED | 
| 9 #define SkSVGTypes_DEFINED | 9 #define SkSVGTypes_DEFINED | 
| 10 | 10 | 
| 11 #include "SkColor.h" | 11 #include "SkColor.h" | 
|  | 12 #include "SkRect.h" | 
| 12 #include "SkScalar.h" | 13 #include "SkScalar.h" | 
| 13 #include "SkTypes.h" | 14 #include "SkTypes.h" | 
| 14 | 15 | 
| 15 class SkSVGNumber { | 16 template <typename T> | 
|  | 17 class SkSVGPrimitiveTypeWrapper { | 
| 16 public: | 18 public: | 
| 17     constexpr SkSVGNumber()                    : fValue(0) {} | 19     SkSVGPrimitiveTypeWrapper() = default; | 
| 18     explicit constexpr SkSVGNumber(SkScalar v) : fValue(v) {} | 20     explicit constexpr SkSVGPrimitiveTypeWrapper(T v) : fValue(v) {} | 
| 19     SkSVGNumber(const SkSVGNumber&)            = default; |  | 
| 20     SkSVGNumber& operator=(const SkSVGNumber&) = default; |  | 
| 21 | 21 | 
|  | 22     SkSVGPrimitiveTypeWrapper(const SkSVGPrimitiveTypeWrapper&)            = def
    ault; | 
|  | 23     SkSVGPrimitiveTypeWrapper& operator=(const SkSVGPrimitiveTypeWrapper&) = def
    ault; | 
| 22 | 24 | 
| 23     const SkScalar& value() const { return fValue; } | 25     const T& value() const { return fValue; } | 
| 24 | 26     operator const T&() const { return fValue; } | 
| 25     operator const SkScalar&() const { return fValue; } |  | 
| 26 | 27 | 
| 27 private: | 28 private: | 
| 28     SkScalar fValue; | 29     T fValue; | 
| 29 }; | 30 }; | 
| 30 | 31 | 
|  | 32 using SkSVGColorType   = SkSVGPrimitiveTypeWrapper<SkColor >; | 
|  | 33 using SkSVGNumberType  = SkSVGPrimitiveTypeWrapper<SkScalar>; | 
|  | 34 using SkSVGViewBoxType = SkSVGPrimitiveTypeWrapper<SkRect  >; | 
|  | 35 | 
| 31 class SkSVGLength { | 36 class SkSVGLength { | 
| 32 public: | 37 public: | 
| 33     enum class Unit { | 38     enum class Unit { | 
| 34         kUnknown, | 39         kUnknown, | 
| 35         kNumber, | 40         kNumber, | 
| 36         kPercentage, | 41         kPercentage, | 
| 37         kEMS, | 42         kEMS, | 
| 38         kEXS, | 43         kEXS, | 
| 39         kPX, | 44         kPX, | 
| 40         kCM, | 45         kCM, | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 51     SkSVGLength& operator=(const SkSVGLength&) = default; | 56     SkSVGLength& operator=(const SkSVGLength&) = default; | 
| 52 | 57 | 
| 53     const SkScalar& value() const { return fValue; } | 58     const SkScalar& value() const { return fValue; } | 
| 54     const Unit&     unit()  const { return fUnit;  } | 59     const Unit&     unit()  const { return fUnit;  } | 
| 55 | 60 | 
| 56 private: | 61 private: | 
| 57     SkScalar fValue; | 62     SkScalar fValue; | 
| 58     Unit     fUnit; | 63     Unit     fUnit; | 
| 59 }; | 64 }; | 
| 60 | 65 | 
| 61 class SkSVGColor { |  | 
| 62 public: |  | 
| 63     constexpr SkSVGColor()                   : fValue(SK_ColorBLACK) {} |  | 
| 64     explicit constexpr SkSVGColor(SkColor c) : fValue(c) {} |  | 
| 65 |  | 
| 66     operator const SkColor&() const { return fValue; } |  | 
| 67 |  | 
| 68 private: |  | 
| 69     SkColor fValue; |  | 
| 70 }; |  | 
| 71 |  | 
| 72 #endif // SkSVGTypes_DEFINED | 66 #endif // SkSVGTypes_DEFINED | 
| OLD | NEW | 
|---|