Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: src/core/SkRemote_protocol.h

Issue 1391023005: SkRemote (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: hal Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkRemote.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « src/core/SkRemote.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698