Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkValue_DEFINED | 8 #ifndef SkValue_DEFINED |
| 9 #define SkValue_DEFINED | 9 #define SkValue_DEFINED |
| 10 | 10 |
| 11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
| 12 #include <functional> | 12 #include <functional> |
| 13 | 13 |
| 14 class SkValue { | 14 class SkValue { |
| 15 public: | 15 public: |
| 16 enum Type : uint32_t { | 16 enum Type : uint32_t { |
| 17 // 0-255 are reserved for built-in SkValue types. | 17 // 0-255 are reserved for built-in SkValue types. |
| 18 Null, | 18 Null, |
| 19 Byte , S16 , U16 , S32 , U32 , S64 , U64 , F32 , F64 , | 19 Byte , S16 , U16 , S32 , U32 , S64 , U64 , F32 , F64 , |
| 20 Bytes, S16s, U16s, S32s, U32s, S64s, U64s, F32s, F64s, | 20 Bytes, S16s, U16s, S32s, U32s, S64s, U64s, F32s, F64s, |
| 21 Array, | 21 Array, |
| 22 | 22 |
| 23 // 256-2147483647 may be used by Skia for public Object types. | 23 // 256-2147483647 may be used by Skia for public Object types. |
| 24 | 24 |
| 25 ArithmeticXfermode = 0x100, | |
| 26 LerpXfermode, | |
| 27 OverdrawXfermode, | |
| 28 PixelXorXfermode, | |
| 29 ProcCoeffXfermode, | |
| 25 | 30 |
| 26 // 2147483648+ won't be used by Skia. They're open for client-specific use, testing, etc. | 31 // 2147483648+ won't be used by Skia. They're open for client-specific use, testing, etc. |
| 27 }; | 32 }; |
| 28 | 33 |
| 29 enum Key : uint32_t { | 34 // Each Object type may define its own namespace of Key values, |
| 30 // Each Object type may define its own namespace of Key values, | 35 // so there are no pre-defined Keys here. |
| 31 // so there are no pre-defined Keys here. | 36 // |
| 32 // | 37 // This is just a reminder that they must fit in a uint32_t, |
| 33 // This is just a reminder that they must fit in a uint32_t, | 38 // and that their namespace is distinct from other uint32_ts (e.g. Type). |
| 34 // and that their namespace is distinct from other uint32_ts (e.g. Type) . | 39 typedef uint32_t Key; |
| 35 }; | |
| 36 | 40 |
| 37 SkValue(); | 41 SkValue(); |
| 38 SkValue(const SkValue&); | 42 SkValue(const SkValue&); |
| 39 SkValue(SkValue&&); | 43 SkValue(SkValue&&); |
| 40 | 44 |
| 41 SkValue& operator=(const SkValue&); | 45 SkValue& operator=(const SkValue&); |
| 42 SkValue& operator=(SkValue&&); | 46 SkValue& operator=(SkValue&&); |
| 43 | 47 |
| 44 ~SkValue(); | 48 ~SkValue(); |
| 45 | 49 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 59 | 63 |
| 60 const void* bytes() const; | 64 const void* bytes() const; |
| 61 size_t count() const; | 65 size_t count() const; |
| 62 | 66 |
| 63 void set(Key, SkValue); | 67 void set(Key, SkValue); |
| 64 const SkValue* get(Key) const; | 68 const SkValue* get(Key) const; |
| 65 void foreach(std::function<void(Key, const SkValue&)>) const; | 69 void foreach(std::function<void(Key, const SkValue&)>) const; |
| 66 | 70 |
| 67 private: | 71 private: |
| 68 class Bytes; | 72 class Bytes; |
| 69 class Object; | 73 class Obj; |
|
mtklein
2016/01/15 00:25:22
?
hal.canary
2016/01/15 13:38:56
SkValue::Object was an enum value, too. The compi
| |
| 70 | 74 |
| 71 Type fType; | 75 Type fType; |
| 72 union { | 76 union { |
| 73 int32_t fS32; | 77 int32_t fS32; |
| 74 uint32_t fU32; | 78 uint32_t fU32; |
| 75 float fF32; | 79 float fF32; |
| 76 class Bytes* fBytes; | 80 class Bytes* fBytes; |
| 77 class Object* fObject; | 81 class Obj* fObject; |
| 78 }; | 82 }; |
| 79 }; | 83 }; |
| 80 | 84 |
| 81 #endif//SkValue_DEFINED | 85 #endif//SkValue_DEFINED |
| OLD | NEW |