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

Side by Side Diff: src/core/SkValue.h

Issue 1643753002: kill SkValue (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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 | « include/effects/SkPixelXorXfermode.h ('k') | src/core/SkValue.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 SkValue_DEFINED
9 #define SkValue_DEFINED
10
11 #include "SkTypes.h"
12 #include <functional>
13
14 class SkData;
15
16 class SkValue {
17 public:
18 enum Type : uint32_t {
19 // 0-255 are reserved for built-in SkValue types.
20 Null,
21 Byte , S16 , U16 , S32 , U32 , S64 , U64 , F32 , F64 ,
22 Bytes, S16s, U16s, S32s, U32s, S64s, U64s, F32s, F64s,
23 Array,
24
25 kMaxBuiltin = 0xFF,
26 // 256-2147483647 may be used by Skia for public Object types.
27
28 Matrix,
29
30 ArithmeticXfermode,
31 DefaultXfermode,
32 PixelXorXfermode,
33 ProcCoeffXfermode,
34
35 kMaxPublicObject = 0x7FFFFFFF,
36 // 2147483648+ won't be used by Skia. They're open for
37 // client-specific use, testing, etc.
38 };
39
40 // Each Object type may define its own namespace of Key values,
41 // so there are no pre-defined Keys here.
42 //
43 // This is just a reminder that they must fit in a uint32_t,
44 // and that their namespace is distinct from other uint32_ts (e.g. Type).
45 typedef uint32_t Key;
46
47 SkValue();
48 SkValue(const SkValue&);
49 SkValue(SkValue&&);
50
51 SkValue& operator=(const SkValue&);
52 SkValue& operator=(SkValue&&);
53
54 ~SkValue();
55
56 static SkValue FromS32(int32_t);
57 static SkValue FromU32(uint32_t);
58 static SkValue FromF32(float);
59 static SkValue FromBytes(SkData*);
60 static SkValue FromU16s(SkData*);
61 static SkValue FromU32s(SkData*);
62 static SkValue FromF32s(SkData*);
63 static SkValue ValueArray();
64 static SkValue Object(Type);
65
66 Type type() const { return fType; }
67
68 // These remaining methods may assert they're called on a value of the appro priate type.
69
70 int32_t s32() const;
71 uint32_t u32() const;
72 float f32() const;
73 SkData* bytes() const;
74
75 const uint16_t* u16s(int* count) const;
76 const uint32_t* u32s(int* count) const;
77 const float* f32s(int* count) const;
78
79 // Object
80 void set(Key, SkValue);
81 const SkValue* get(Key) const;
82 void foreach(std::function<void(Key, const SkValue&)>) const;
83
84 // Array
85 size_t length() const;
86 const SkValue& at(size_t) const;
87 void append(SkValue);
88
89 private:
90 class Obj;
91 class Arr;
92
93 Type fType;
94 union {
95 int32_t fS32;
96 uint32_t fU32;
97 float fF32;
98 SkData* fBytes;
99 Obj* fObject;
100 Arr* fArray;
101 };
102
103 SkValue(Type);
104 bool isObject() const { return fType > kMaxBuiltin; }
105 bool isData() const {
106 return Bytes == fType
107 || U16s == fType
108 || U32s == fType
109 || F32s == fType;
110 }
111 template <typename T> static SkValue FromT(SkValue::Type, T SkValue::*, T);
112 template <typename T> static SkValue FromTs(SkValue::Type, SkData*);
113 template <typename T> const T* asTs(SkValue::Type, int*) const;
114 };
115
116 #endif // SkValue_DEFINED
OLDNEW
« no previous file with comments | « include/effects/SkPixelXorXfermode.h ('k') | src/core/SkValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698