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

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

Issue 2234153002: [SVGDom] Add more presentation attributes. (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') | no next file » | 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 "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,
23 kLineJoin,
24 kNumber,
25 kPaint,
22 kPath, 26 kPath,
23 kTransform, 27 kTransform,
24 kViewBox, 28 kViewBox,
25 }; 29 };
26 30
27 Type type() const { return fType; } 31 Type type() const { return fType; }
28 32
29 template <typename T> 33 template <typename T>
30 const T* as() const { 34 const T* as() const {
31 return fType == T::TYPE ? static_cast<const T*>(this) : nullptr; 35 return fType == T::TYPE ? static_cast<const T*>(this) : nullptr;
(...skipping 11 matching lines...) Expand all
43 template <typename T, SkSVGValue::Type ValueType> 47 template <typename T, SkSVGValue::Type ValueType>
44 class SkSVGWrapperValue final : public SkSVGValue { 48 class SkSVGWrapperValue final : public SkSVGValue {
45 public: 49 public:
46 static constexpr Type TYPE = ValueType; 50 static constexpr Type TYPE = ValueType;
47 51
48 explicit SkSVGWrapperValue(const T& v) 52 explicit SkSVGWrapperValue(const T& v)
49 : INHERITED(ValueType) 53 : INHERITED(ValueType)
50 , fWrappedValue(v) { } 54 , fWrappedValue(v) { }
51 55
52 operator const T&() const { return fWrappedValue; } 56 operator const T&() const { return fWrappedValue; }
57 const T* operator->() const { return &fWrappedValue; }
53 58
54 private: 59 private:
55 // Stack-only 60 // Stack-only
56 void* operator new(size_t) = delete; 61 void* operator new(size_t) = delete;
57 void* operator new(size_t, void*) = delete; 62 void* operator new(size_t, void*) = delete;
58 63
59 const T& fWrappedValue; 64 const T& fWrappedValue;
60 65
61 typedef SkSVGValue INHERITED; 66 typedef SkSVGValue INHERITED;
62 }; 67 };
63 68
64 using SkSVGColorValue = SkSVGWrapperValue<SkSVGColorType , SkSVGValue::Ty pe::kColor >; 69 using SkSVGColorValue = SkSVGWrapperValue<SkSVGColorType , SkSVGValue::Ty pe::kColor >;
65 using SkSVGLengthValue = SkSVGWrapperValue<SkSVGLength , SkSVGValue::Ty pe::kLength >; 70 using SkSVGLengthValue = SkSVGWrapperValue<SkSVGLength , SkSVGValue::Ty pe::kLength >;
66 using SkSVGPathValue = SkSVGWrapperValue<SkPath , SkSVGValue::Ty pe::kPath >; 71 using SkSVGPathValue = SkSVGWrapperValue<SkPath , SkSVGValue::Ty pe::kPath >;
67 using SkSVGTransformValue = SkSVGWrapperValue<SkSVGTransformType, SkSVGValue::Ty pe::kTransform>; 72 using SkSVGTransformValue = SkSVGWrapperValue<SkSVGTransformType, SkSVGValue::Ty pe::kTransform>;
68 using SkSVGViewBoxValue = SkSVGWrapperValue<SkSVGViewBoxType , SkSVGValue::Ty pe::kViewBox >; 73 using SkSVGViewBoxValue = SkSVGWrapperValue<SkSVGViewBoxType , SkSVGValue::Ty pe::kViewBox >;
74 using SkSVGPaintValue = SkSVGWrapperValue<SkSVGPaint , SkSVGValue::Ty pe::kPaint >;
75 using SkSVGLineCapValue = SkSVGWrapperValue<SkSVGLineCap , SkSVGValue::Ty pe::kLineCap >;
76 using SkSVGLineJoinValue = SkSVGWrapperValue<SkSVGLineJoin , SkSVGValue::Ty pe::kLineJoin >;
77 using SkSVGNumberValue = SkSVGWrapperValue<SkSVGNumberType , SkSVGValue::Ty pe::kNumber >;
69 78
70 #endif // SkSVGValue_DEFINED 79 #endif // SkSVGValue_DEFINED
OLDNEW
« no previous file with comments | « experimental/svg/model/SkSVGTypes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698