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

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

Issue 2164193002: Initial SVG model (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: warning fix 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
OLDNEW
(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 SkSVGValue_DEFINED
9 #define SkSVGValue_DEFINED
10
11 #include "SkColor.h"
12 #include "SkMatrix.h"
13 #include "SkPath.h"
14 #include "SkTypes.h"
15
16 class SkSVGValue : public SkNoncopyable {
17 public:
18 enum class Type {
19 Color,
20 Path,
21 Transform,
22 };
23
24 Type type() const { return fType; }
25
26 template <typename T>
27 const T* as() const {
28 return fType == T::TYPE ? static_cast<const T*>(this) : nullptr;
29 }
30
31 protected:
32 SkSVGValue(Type t) : fType(t) { }
33
34 private:
35 Type fType;
36 };
37
38 template <typename SkiaType, SkSVGValue::Type ValueType>
39 class SkSVGWrapperValue final : public SkSVGValue {
40 public:
41 static constexpr Type TYPE = ValueType;
42
43 explicit SkSVGWrapperValue(const SkiaType& v)
44 : INHERITED(ValueType)
45 , fWrappedValue(v) { }
46
47 operator const SkiaType&() const { return fWrappedValue; }
48
49 private:
50 SkiaType fWrappedValue;
51
52 using INHERITED = SkSVGValue;
53 };
54
55 using SkSVGColorValue = SkSVGWrapperValue<SkColor , SkSVGValue::Type::Color >;
56 using SkSVGPathValue = SkSVGWrapperValue<SkPath , SkSVGValue::Type::Path >;
57 using SkSVGTransformValue = SkSVGWrapperValue<SkMatrix, SkSVGValue::Type::Transf orm>;
58
59 #endif // SkSVGValue_DEFINED
OLDNEW
« no previous file with comments | « experimental/svg/model/SkSVGTransformableNode.cpp ('k') | experimental/svg/model/SkSVGValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698