diff options
author | fmalita <fmalita@chromium.org> | 2016-08-11 09:16:29 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-11 09:16:29 -0700 |
commit | 2d961e086bb40b371b1a667536fa089794847368 (patch) | |
tree | 89c6986af025e9d5c87791e4977838331bbd575b /experimental/svg/model/SkSVGTypes.h | |
parent | 90b5cc31f373e831c942bfd3113b44486546846b (diff) |
[SVGDom] Add more presentation attributes.
Implement proper presentation attribute inheritance, and add
support for
* fill-opacity
* stroke-linecap
* stroke-linejoin
* stroke-opacity
* stroke-width
R=robertphillips@google.com,stephana@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2234153002
Review-Url: https://codereview.chromium.org/2234153002
Diffstat (limited to 'experimental/svg/model/SkSVGTypes.h')
-rw-r--r-- | experimental/svg/model/SkSVGTypes.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/experimental/svg/model/SkSVGTypes.h b/experimental/svg/model/SkSVGTypes.h index b2e2db1076..c8330e1088 100644 --- a/experimental/svg/model/SkSVGTypes.h +++ b/experimental/svg/model/SkSVGTypes.h @@ -23,6 +23,13 @@ public: SkSVGPrimitiveTypeWrapper(const SkSVGPrimitiveTypeWrapper&) = default; SkSVGPrimitiveTypeWrapper& operator=(const SkSVGPrimitiveTypeWrapper&) = default; + bool operator==(const SkSVGPrimitiveTypeWrapper<T>& other) const { + return fValue == other.fValue; + } + bool operator!=(const SkSVGPrimitiveTypeWrapper<T>& other) const { + return !(*this == other); + } + const T& value() const { return fValue; } operator const T&() const { return fValue; } @@ -57,6 +64,11 @@ public: SkSVGLength(const SkSVGLength&) = default; SkSVGLength& operator=(const SkSVGLength&) = default; + bool operator==(const SkSVGLength& other) const { + return fUnit == other.fUnit && fValue == other.fValue; + } + bool operator!=(const SkSVGLength& other) const { return !(*this == other); } + const SkScalar& value() const { return fValue; } const Unit& unit() const { return fUnit; } @@ -65,4 +77,82 @@ private: Unit fUnit; }; +class SkSVGPaint { +public: + enum class Type { + kNone, + kCurrentColor, + kColor, + kInherit, + }; + + constexpr SkSVGPaint() : fType(Type::kInherit), fColor(SK_ColorBLACK) {} + explicit constexpr SkSVGPaint(Type t) : fType(t), fColor(SK_ColorBLACK) {} + explicit constexpr SkSVGPaint(const SkSVGColorType& c) : fType(Type::kColor), fColor(c) {} + + SkSVGPaint(const SkSVGPaint&) = default; + SkSVGPaint& operator=(const SkSVGPaint&) = default; + + bool operator==(const SkSVGPaint& other) const { + return fType == other.fType && fColor == other.fColor; + } + bool operator!=(const SkSVGPaint& other) const { return !(*this == other); } + + Type type() const { return fType; } + const SkSVGColorType& color() const { SkASSERT(fType == Type::kColor); return fColor; } + +private: + Type fType; + + SkSVGColorType fColor; +}; + +class SkSVGLineCap { +public: + enum class Type { + kButt, + kRound, + kSquare, + kInherit, + }; + + constexpr SkSVGLineCap() : fType(Type::kInherit) {} + constexpr explicit SkSVGLineCap(Type t) : fType(t) {} + + SkSVGLineCap(const SkSVGLineCap&) = default; + SkSVGLineCap& operator=(const SkSVGLineCap&) = default; + + bool operator==(const SkSVGLineCap& other) const { return fType == other.fType; } + bool operator!=(const SkSVGLineCap& other) const { return !(*this == other); } + + Type type() const { return fType; } + +private: + Type fType; +}; + +class SkSVGLineJoin { +public: + enum class Type { + kMiter, + kRound, + kBevel, + kInherit, + }; + + constexpr SkSVGLineJoin() : fType(Type::kInherit) {} + constexpr explicit SkSVGLineJoin(Type t) : fType(t) {} + + SkSVGLineJoin(const SkSVGLineJoin&) = default; + SkSVGLineJoin& operator=(const SkSVGLineJoin&) = default; + + bool operator==(const SkSVGLineJoin& other) const { return fType == other.fType; } + bool operator!=(const SkSVGLineJoin& other) const { return !(*this == other); } + + Type type() const { return fType; } + +private: + Type fType; +}; + #endif // SkSVGTypes_DEFINED |