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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/svg/model/SkSVGTransformableNode.cpp ('k') | experimental/svg/model/SkSVGValue.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/svg/model/SkSVGValue.h
diff --git a/experimental/svg/model/SkSVGValue.h b/experimental/svg/model/SkSVGValue.h
new file mode 100644
index 0000000000000000000000000000000000000000..3d3cd6efc1d723a5273ab031fe140cb83b965508
--- /dev/null
+++ b/experimental/svg/model/SkSVGValue.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkSVGValue_DEFINED
+#define SkSVGValue_DEFINED
+
+#include "SkColor.h"
+#include "SkMatrix.h"
+#include "SkPath.h"
+#include "SkTypes.h"
+
+class SkSVGValue : public SkNoncopyable {
+public:
+ enum class Type {
+ Color,
+ Path,
+ Transform,
+ };
+
+ Type type() const { return fType; }
+
+ template <typename T>
+ const T* as() const {
+ return fType == T::TYPE ? static_cast<const T*>(this) : nullptr;
+ }
+
+protected:
+ SkSVGValue(Type t) : fType(t) { }
+
+private:
+ Type fType;
+};
+
+template <typename SkiaType, SkSVGValue::Type ValueType>
+class SkSVGWrapperValue final : public SkSVGValue {
+public:
+ static constexpr Type TYPE = ValueType;
+
+ explicit SkSVGWrapperValue(const SkiaType& v)
+ : INHERITED(ValueType)
+ , fWrappedValue(v) { }
+
+ operator const SkiaType&() const { return fWrappedValue; }
+
+private:
+ SkiaType fWrappedValue;
+
+ using INHERITED = SkSVGValue;
+};
+
+using SkSVGColorValue = SkSVGWrapperValue<SkColor , SkSVGValue::Type::Color >;
+using SkSVGPathValue = SkSVGWrapperValue<SkPath , SkSVGValue::Type::Path >;
+using SkSVGTransformValue = SkSVGWrapperValue<SkMatrix, SkSVGValue::Type::Transform>;
+
+#endif // SkSVGValue_DEFINED
« 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