Chromium Code Reviews| Index: src/core/SkValue.h |
| diff --git a/src/core/SkValue.h b/src/core/SkValue.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1a6e626c9ed0d23392e2d7b0c25b6b375cdcd403 |
| --- /dev/null |
| +++ b/src/core/SkValue.h |
| @@ -0,0 +1,80 @@ |
| +/* |
| + * 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 SkValue_DEFINED |
| +#define SkValue_DEFINED |
| + |
| +#include "SkTypes.h" |
| +#include <functional> |
| + |
| +class SkValue { |
| +public: |
| + enum Type : uint32_t { |
| + // 0-255 are reserved for built-in SkValue types. |
| + Null, |
| + 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
|
| + Bytes, S16s, U16s, S32s, U32s, S64s, U64s, F32s, F64s, Values, |
| + |
| + // 256-2147483647 may be used by Skia for public Object types. |
| + |
| + |
| + // 2147483648+ won't be used by Skia. They're open for client-specific use, testing, etc. |
| + }; |
| + |
| + enum Key : uint32_t { |
| + // Each Object type may define its own namespace of Key values, |
| + // so there are no pre-defined Keys here. |
| + // |
| + // This is just a reminder that they must fit in a uint32_t, |
| + // and that their namespace is distinct from other uint32_ts (e.g. Type). |
| + }; |
| + |
| + SkValue(); |
| + 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
|
| + SkValue(SkValue&&); |
| + |
| + SkValue& operator=(const SkValue&); |
| + SkValue& operator=(SkValue&&); |
| + |
| + ~SkValue(); |
| + |
| + static SkValue FromS32(int32_t); |
| + static SkValue FromU32(uint32_t); |
| + static SkValue FromF32(float); |
| + static SkValue FromBytes(const void*, size_t); |
|
hal.canary
2016/01/14 19:16:37
does this copy?
|
| + static SkValue Object(Type); |
|
hal.canary
2016/01/14 19:16:37
static SkValue List(int reserve = 0);
|
| + |
| + Type type() const; |
| + |
| + // These remaining methods may assert they're called on a value of the appropriate type. |
| + |
| + int32_t s32() const; |
| + uint32_t u32() const; |
| + float f32() const; |
| + |
| + const void* bytes() const; |
| + size_t count() const; |
| + |
| + void set(Key, SkValue); |
|
hal.canary
2016/01/14 19:16:37
set(Key, SkValue&&);
set(Key, const SkValue&);
|
| + const SkValue* get(Key) const; |
| + void foreach(std::function<void(Key, const SkValue&)>) const; |
| + |
|
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);
|
| +private: |
| + class Bytes; |
| + class Object; |
| + |
| + Type fType; |
| + union { |
| + int32_t fS32; |
| + uint32_t fU32; |
| + float fF32; |
| + class Bytes* fBytes; |
| + class Object* fObject; |
| + }; |
| +}; |
| + |
| +#endif//SkValue_DEFINED |