OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 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 SkRemote_protocol_DEFINED |
| 9 #define SkRemote_protocol_DEFINED |
| 10 |
| 11 // ATTENTION! Changes to this file can break protocol compatibility. Tread car
efully. |
| 12 |
| 13 namespace SkRemote { |
| 14 |
| 15 // It is safe to append to this enum without breaking protocol compatibility
. |
| 16 // Resorting, deleting, or inserting anywhere but the end will break compati
bility. |
| 17 enum class Type : uint8_t { |
| 18 kNone, |
| 19 |
| 20 kMatrix, |
| 21 kMisc, |
| 22 kPath, |
| 23 kStroke, |
| 24 }; |
| 25 |
| 26 class ID { |
| 27 public: |
| 28 explicit ID(Type type = Type::kNone) : fVal((uint64_t)type << 56) {} |
| 29 ID(Type type, uint64_t val) { |
| 30 fVal = (uint64_t)type << 56 | val; |
| 31 SkASSERT(this->type() == type && this->val() == val); |
| 32 } |
| 33 |
| 34 Type type() const { return (Type)(fVal >> 56); } |
| 35 uint64_t val() const { return fVal & ~((uint64_t)0xFF << 56); } |
| 36 |
| 37 bool operator==(ID o) const { return fVal == o.fVal; } |
| 38 ID operator++(int) { |
| 39 ID prev = *this; |
| 40 fVal++; |
| 41 SkASSERT(this->val() != 0); // Overflow is particularly bad as it'd
change our Type. |
| 42 return prev; |
| 43 } |
| 44 |
| 45 private: |
| 46 // High 8 bits hold a Type. Low 56 bits are unique within that Type. |
| 47 // Any change to this format will break protocol compatibility. |
| 48 uint64_t fVal; |
| 49 }; |
| 50 |
| 51 } // namespace SkRemote |
| 52 |
| 53 #endif//SkRemote_protocol_DEFINED |
OLD | NEW |