OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2016 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef SkSVGTypes_DEFINED |
| 9 #define SkSVGTypes_DEFINED |
| 10 |
| 11 #include "SkColor.h" |
| 12 #include "SkScalar.h" |
| 13 #include "SkTypes.h" |
| 14 |
| 15 class SkSVGNumber { |
| 16 public: |
| 17 constexpr SkSVGNumber() : fValue(0) {} |
| 18 explicit constexpr SkSVGNumber(SkScalar v) : fValue(v) {} |
| 19 SkSVGNumber(const SkSVGNumber&) = default; |
| 20 SkSVGNumber& operator=(const SkSVGNumber&) = default; |
| 21 |
| 22 |
| 23 const SkScalar& value() const { return fValue; } |
| 24 |
| 25 operator const SkScalar&() const { return fValue; } |
| 26 |
| 27 private: |
| 28 SkScalar fValue; |
| 29 }; |
| 30 |
| 31 class SkSVGLength { |
| 32 public: |
| 33 enum class Unit { |
| 34 kUnknown, |
| 35 kNumber, |
| 36 kPercentage, |
| 37 kEMS, |
| 38 kEXS, |
| 39 kPX, |
| 40 kCM, |
| 41 kMM, |
| 42 kIN, |
| 43 kPT, |
| 44 kPC, |
| 45 }; |
| 46 |
| 47 constexpr SkSVGLength() : fValue(0), fUnit(Unit::kUnknown
) {} |
| 48 explicit constexpr SkSVGLength(SkScalar v, Unit u = Unit::kNumber) |
| 49 : fValue(v), fUnit(u) {} |
| 50 SkSVGLength(const SkSVGLength&) = default; |
| 51 SkSVGLength& operator=(const SkSVGLength&) = default; |
| 52 |
| 53 const SkScalar& value() const { return fValue; } |
| 54 const Unit& unit() const { return fUnit; } |
| 55 |
| 56 private: |
| 57 SkScalar fValue; |
| 58 Unit fUnit; |
| 59 }; |
| 60 |
| 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 |
OLD | NEW |