Chromium Code Reviews| Index: src/core/SkValue.h |
| diff --git a/src/core/SkValue.h b/src/core/SkValue.h |
| index dd42b3a889042f5843d847225de4c66939975951..dc595f1d98d9ba6cfb06fd0adb25b32eb9eec7e0 100644 |
| --- a/src/core/SkValue.h |
| +++ b/src/core/SkValue.h |
| @@ -11,6 +11,15 @@ |
| #include "SkTypes.h" |
| #include <functional> |
| +class SkData; |
| + |
| +#define SK_VALUE_OBJECT_TYPES(M) \ |
| + M(ArithmeticXfermode) \ |
| + M(LerpXfermode) \ |
| + M(OverdrawXfermode) \ |
| + M(PixelXorXfermode) \ |
| + M(ProcCoeffXfermode) |
| + |
| class SkValue { |
| public: |
| enum Type : uint32_t { |
| @@ -20,19 +29,22 @@ public: |
| Bytes, S16s, U16s, S32s, U32s, S64s, U64s, F32s, F64s, |
| Array, |
| - // 256-2147483647 may be used by Skia for public Object types. |
| + kMaxBuiltin = 0xFF, |
| + // 256-2147483647 may be used by Skia for public Object types. |
| + #define FN(TYPE) TYPE, |
| + SK_VALUE_OBJECT_TYPES(FN) |
| + #undef FN |
| // 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). |
| - }; |
| + // 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). |
| + typedef uint32_t Key; |
| SkValue(); |
| SkValue(const SkValue&); |
| @@ -60,22 +72,23 @@ public: |
| const void* bytes() const; |
| size_t count() const; |
| - void set(Key, SkValue); |
| + bool set(Key, SkValue); // returns true on success. |
| const SkValue* get(Key) const; |
| void foreach(std::function<void(Key, const SkValue&)>) const; |
| private: |
| - class Bytes; |
| - class Object; |
| + class Obj; |
| Type fType; |
| union { |
| - int32_t fS32; |
| - uint32_t fU32; |
| - float fF32; |
| - class Bytes* fBytes; |
| - class Object* fObject; |
| + int32_t fS32; |
| + uint32_t fU32; |
| + float fF32; |
| + SkData* fBytes; |
| + Obj* fObject; |
| }; |
| + |
| + bool isObject() const { return fType > 0xFF; } |
|
mtklein
2016/01/15 17:26:20
kMaxBuiltin?
hal.canary
2016/01/15 19:44:31
done
|
| }; |
| #endif//SkValue_DEFINED |