Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSVGValue.h
Go to the documentation of this file.
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
13#include "include/core/SkPath.h"
17
19public:
20 enum class Type {
21 kColor,
22 kFilter,
23 kLength,
24 kNumber,
25 kObjectBoundingBoxUnits,
27 kStopColor,
28 kString,
31 };
32
33 Type type() const { return fType; }
34
35 template <typename T>
36 const T* as() const {
37 return fType == T::TYPE ? static_cast<const T*>(this) : nullptr;
38 }
39
40protected:
41 SkSVGValue(Type t) : fType(t) { }
42
43private:
44 Type fType;
45
47};
48
49template <typename T, SkSVGValue::Type ValueType>
50class SK_API SkSVGWrapperValue final : public SkSVGValue {
51public:
52 static constexpr Type TYPE = ValueType;
53
54 explicit SkSVGWrapperValue(const T& v)
55 : INHERITED(ValueType)
56 , fWrappedValue(v) { }
57
58 operator const T&() const { return fWrappedValue; }
59 const T* operator->() const { return &fWrappedValue; }
60
61private:
62 // Stack-only
63 void* operator new(size_t) = delete;
64 void* operator new(size_t, void*) = delete;
65
66 const T& fWrappedValue;
67
68 using INHERITED = SkSVGValue;
69};
70
78
81
84
85#endif // SkSVGValue_DEFINED
static constexpr SkColor kColor
#define SK_API
Definition SkAPI.h:35
#define INHERITED(method,...)
#define TYPE(t)
SkNoncopyable()=default
Type type() const
Definition SkSVGValue.h:33
SkSVGValue(Type t)
Definition SkSVGValue.h:41
const T * as() const
Definition SkSVGValue.h:36
const T * operator->() const
Definition SkSVGValue.h:59
SkSVGWrapperValue(const T &v)
Definition SkSVGValue.h:54
static constexpr char kTransform[]
#define T