OLD | NEW |
---|---|
(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 SkValue { | |
15 public: | |
16 enum Type : uint32_t { | |
17 // 0-255 are reserved for built-in SkValue types. | |
18 Null, | |
19 Byte , S16 , U16 , S32 , U32 , S64 , U64 , F32 , F64 , | |
hal.canary
2016/01/14 16:11:45
I thought you preferred U8 to byte.
mtklein
2016/01/14 16:45:15
I thought so too. But then I realized I don't thi
mtklein
2016/01/14 16:45:15
I was thinking of adding Bit too, as a signal to O
| |
20 Bytes, S16s, U16s, S32s, U32s, S64s, U64s, F32s, F64s, Values, | |
21 | |
22 // 256-2147483647 may be used by Skia for public Object types. | |
23 | |
24 | |
25 // 2147483648+ won't be used by Skia. They're open for client-specific use, testing, etc. | |
26 }; | |
27 | |
28 enum Key : uint32_t { | |
29 // Each Object type may define its own namespace of Key values, | |
30 // so there are no pre-defined Keys here. | |
31 // | |
32 // This is just a reminder that they must fit in a uint32_t, | |
33 // and that their namespace is distinct from other uint32_ts (e.g. Type) . | |
34 }; | |
35 | |
36 SkValue(); | |
37 SkValue(const SkValue&); | |
hal.canary
2016/01/14 16:11:45
what does it mean to copy a SkValue that has compl
mtklein
2016/01/14 16:45:15
From an API perspective, it doesn't matter how we
| |
38 SkValue(SkValue&&); | |
39 | |
40 SkValue& operator=(const SkValue&); | |
41 SkValue& operator=(SkValue&&); | |
42 | |
43 ~SkValue(); | |
44 | |
45 static SkValue FromS32(int32_t); | |
46 static SkValue FromU32(uint32_t); | |
47 static SkValue FromF32(float); | |
48 static SkValue FromBytes(const void*, size_t); | |
hal.canary
2016/01/14 19:16:37
does this copy?
| |
49 static SkValue Object(Type); | |
hal.canary
2016/01/14 19:16:37
static SkValue List(int reserve = 0);
| |
50 | |
51 Type type() const; | |
52 | |
53 // These remaining methods may assert they're called on a value of the appro priate type. | |
54 | |
55 int32_t s32() const; | |
56 uint32_t u32() const; | |
57 float f32() const; | |
58 | |
59 const void* bytes() const; | |
60 size_t count() const; | |
61 | |
62 void set(Key, SkValue); | |
hal.canary
2016/01/14 19:16:37
set(Key, SkValue&&);
set(Key, const SkValue&);
| |
63 const SkValue* get(Key) const; | |
64 void foreach(std::function<void(Key, const SkValue&)>) const; | |
65 | |
hal.canary
2016/01/14 19:16:38
void append(const Value&);
void append(Value&&);
hal.canary
2016/01/14 19:26:21
const SkValue* getFromList(int);
| |
66 private: | |
67 class Bytes; | |
68 class Object; | |
69 | |
70 Type fType; | |
71 union { | |
72 int32_t fS32; | |
73 uint32_t fU32; | |
74 float fF32; | |
75 class Bytes* fBytes; | |
76 class Object* fObject; | |
77 }; | |
78 }; | |
79 | |
80 #endif//SkValue_DEFINED | |
OLD | NEW |