Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: experimental/svg/model/SkSVGValue.h

Issue 2202053002: [SVGDom/experimental] Initial SVGLength support (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « experimental/svg/model/SkSVGTypes.h ('k') | experimental/svg/model/SkSVGValue.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkTypes.h" 15 #include "SkTypes.h"
15 16
16 class SkSVGValue : public SkNoncopyable { 17 class SkSVGValue : public SkNoncopyable {
17 public: 18 public:
18 enum class Type { 19 enum class Type {
19 Color, 20 kColor,
20 Path, 21 kLength,
21 Transform, 22 kPath,
23 kTransform,
22 }; 24 };
23 25
24 Type type() const { return fType; } 26 Type type() const { return fType; }
25 27
26 template <typename T> 28 template <typename T>
27 const T* as() const { 29 const T* as() const {
28 return fType == T::TYPE ? static_cast<const T*>(this) : nullptr; 30 return fType == T::TYPE ? static_cast<const T*>(this) : nullptr;
29 } 31 }
30 32
31 protected: 33 protected:
32 SkSVGValue(Type t) : fType(t) { } 34 SkSVGValue(Type t) : fType(t) { }
33 35
34 private: 36 private:
35 Type fType; 37 Type fType;
38
39 typedef SkNoncopyable INHERITED;
36 }; 40 };
37 41
38 template <typename SkiaType, SkSVGValue::Type ValueType> 42 template <typename SkiaType, SkSVGValue::Type ValueType>
39 class SkSVGWrapperValue final : public SkSVGValue { 43 class SkSVGWrapperValue final : public SkSVGValue {
40 public: 44 public:
41 static constexpr Type TYPE = ValueType; 45 static constexpr Type TYPE = ValueType;
42 46
43 explicit SkSVGWrapperValue(const SkiaType& v) 47 explicit SkSVGWrapperValue(const SkiaType& v)
44 : INHERITED(ValueType) 48 : INHERITED(ValueType)
45 , fWrappedValue(v) { } 49 , fWrappedValue(v) { }
46 50
47 operator const SkiaType&() const { return fWrappedValue; } 51 operator const SkiaType&() const { return fWrappedValue; }
48 52
49 private: 53 private:
50 SkiaType fWrappedValue; 54 SkiaType fWrappedValue;
51 55
52 using INHERITED = SkSVGValue; 56 typedef SkSVGValue INHERITED;
53 }; 57 };
54 58
55 using SkSVGColorValue = SkSVGWrapperValue<SkColor , SkSVGValue::Type::Color >; 59 using SkSVGColorValue = SkSVGWrapperValue<SkSVGColor , SkSVGValue::Type::kCo lor >;
56 using SkSVGPathValue = SkSVGWrapperValue<SkPath , SkSVGValue::Type::Path >; 60 using SkSVGLengthValue = SkSVGWrapperValue<SkSVGLength, SkSVGValue::Type::kLe ngth >;
57 using SkSVGTransformValue = SkSVGWrapperValue<SkMatrix, SkSVGValue::Type::Transf orm>; 61 using SkSVGPathValue = SkSVGWrapperValue<SkPath , SkSVGValue::Type::kPa th >;
62 using SkSVGTransformValue = SkSVGWrapperValue<SkMatrix , SkSVGValue::Type::kTr ansform>;
58 63
59 #endif // SkSVGValue_DEFINED 64 #endif // SkSVGValue_DEFINED
OLDNEW
« no previous file with comments | « experimental/svg/model/SkSVGTypes.h ('k') | experimental/svg/model/SkSVGValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698