aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkRemote_protocol.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-10-16 10:29:41 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-10-16 10:29:41 -0700
commit2e2ea38bb77d42bab292919de5d80286cc354782 (patch)
tree59edecbf152d2e1d6eef652b473cbbd5ed552358 /src/core/SkRemote_protocol.h
parenta106c627532ad669cf7d879955ae8ea6a53233c1 (diff)
SkRemote
Diffstat (limited to 'src/core/SkRemote_protocol.h')
-rw-r--r--src/core/SkRemote_protocol.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/core/SkRemote_protocol.h b/src/core/SkRemote_protocol.h
new file mode 100644
index 0000000000..997521356e
--- /dev/null
+++ b/src/core/SkRemote_protocol.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkRemote_protocol_DEFINED
+#define SkRemote_protocol_DEFINED
+
+// ATTENTION! Changes to this file can break protocol compatibility. Tread carefully.
+
+namespace SkRemote {
+
+ // It is safe to append to this enum without breaking protocol compatibility.
+ // Resorting, deleting, or inserting anywhere but the end will break compatibility.
+ enum class Type : uint8_t {
+ kNone,
+
+ kMatrix,
+ kMisc,
+ kPath,
+ kStroke,
+ };
+
+ class ID {
+ public:
+ explicit ID(Type type = Type::kNone) : fVal((uint64_t)type << 56) {}
+ ID(Type type, uint64_t val) {
+ fVal = (uint64_t)type << 56 | val;
+ SkASSERT(this->type() == type && this->val() == val);
+ }
+
+ Type type() const { return (Type)(fVal >> 56); }
+ uint64_t val() const { return fVal & ~((uint64_t)0xFF << 56); }
+
+ bool operator==(ID o) const { return fVal == o.fVal; }
+ ID operator++(int) {
+ ID prev = *this;
+ fVal++;
+ SkASSERT(this->val() != 0); // Overflow is particularly bad as it'd change our Type.
+ return prev;
+ }
+
+ private:
+ // High 8 bits hold a Type. Low 56 bits are unique within that Type.
+ // Any change to this format will break protocol compatibility.
+ uint64_t fVal;
+ };
+
+} // namespace SkRemote
+
+#endif//SkRemote_protocol_DEFINED