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

Side by Side Diff: cc/surfaces/surface_id.h

Issue 2369793002: WIP: Propagate SurfaceID up window tree hierarchy
Patch Set: Fix input events: EventDispatcher ignores container windows Created 4 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 | « cc/surfaces/surface_factory.cc ('k') | cc/surfaces/surface_id_allocator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_SURFACES_SURFACE_ID_H_ 5 #ifndef CC_SURFACES_SURFACE_ID_H_
6 #define CC_SURFACES_SURFACE_ID_H_ 6 #define CC_SURFACES_SURFACE_ID_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <functional> 11 #include <functional>
12 12
13 #include "base/format_macros.h" 13 #include "base/format_macros.h"
14 #include "base/hash.h" 14 #include "base/hash.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "cc/surfaces/frame_sink_id.h"
16 17
17 namespace cc { 18 namespace cc {
18 19
19 class SurfaceId { 20 class SurfaceId {
20 public: 21 public:
21 SurfaceId() : client_id_(0), local_id_(0), nonce_(0) {} 22 SurfaceId() : local_id_(0), nonce_(0) {}
22 23
23 SurfaceId(const SurfaceId& other) 24 SurfaceId(const SurfaceId& other)
24 : client_id_(other.client_id_), 25 : frame_sink_id_(other.frame_sink_id_),
25 local_id_(other.local_id_), 26 local_id_(other.local_id_),
26 nonce_(other.nonce_) {} 27 nonce_(other.nonce_) {}
27 28
28 // A SurfaceId consists of three components: client Id, local Id, and nonce. 29 // A SurfaceId consists of three components: client Id, local Id, and nonce.
29 // A |client_id| is a display compositor service allocated ID that 30 // A |client_id| is a display compositor service allocated ID that
30 // uniquely identifies a client. 31 // uniquely identifies a client.
31 // A |local_id| is a sequentially allocated ID generated by the display 32 // A |local_id| is a sequentially allocated ID generated by the display
32 // compositor client that uniquely identifies a surface. 33 // compositor client that uniquely identifies a surface.
33 // A |nonce| is a cryptographically secure random int that makes a SurfaceId 34 // A |nonce| is a cryptographically secure random int that makes a SurfaceId
34 // unguessable by other clients. 35 // unguessable by other clients.
35 SurfaceId(uint32_t client_id, uint32_t local_id, uint64_t nonce) 36 SurfaceId(const FrameSinkId& frame_sink_id, uint32_t local_id, uint64_t nonce)
36 : client_id_(client_id), local_id_(local_id), nonce_(nonce) {} 37 : frame_sink_id_(frame_sink_id), local_id_(local_id), nonce_(nonce) {}
37 38
38 bool is_null() const { 39 bool is_null() const {
39 return client_id_ == 0 && nonce_ == 0 && local_id_ == 0; 40 return frame_sink_id_.is_null() && nonce_ == 0 && local_id_ == 0;
40 } 41 }
41 42
42 size_t hash() const { 43 size_t hash() const {
43 size_t interim = base::HashInts(client_id_, local_id_); 44 size_t interim = base::HashInts(local_id_, nonce_);
44 return base::HashInts(static_cast<uint64_t>(interim), nonce_); 45 return base::HashInts(frame_sink_id_.hash(), interim);
45 } 46 }
46 47
47 uint32_t client_id() const { return client_id_; } 48 uint32_t client_id() const { return frame_sink_id_.client_id(); }
49
50 uint32_t sink_id() const { return frame_sink_id_.sink_id(); }
51
52 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; }
48 53
49 uint32_t local_id() const { return local_id_; } 54 uint32_t local_id() const { return local_id_; }
50 55
51 uint64_t nonce() const { return nonce_; } 56 uint64_t nonce() const { return nonce_; }
52 57
53 std::string ToString() const { 58 std::string ToString() const {
54 return base::StringPrintf("%d:%d:%" PRIu64, client_id_, local_id_, nonce_); 59 return base::StringPrintf("%s:LocalId(%d, %lu)" PRIu64,
60 frame_sink_id_.ToString().c_str(), local_id_,
61 nonce_);
55 } 62 }
56 63
57 bool operator==(const SurfaceId& other) const { 64 bool operator==(const SurfaceId& other) const {
58 return client_id_ == other.client_id_ && local_id_ == other.local_id_ && 65 return frame_sink_id_ == other.frame_sink_id_ &&
59 nonce_ == other.nonce_; 66 local_id_ == other.local_id_ && nonce_ == other.nonce_;
60 } 67 }
61 68
62 bool operator!=(const SurfaceId& other) const { return !(*this == other); } 69 bool operator!=(const SurfaceId& other) const { return !(*this == other); }
63 70
64 bool operator<(const SurfaceId& other) const { 71 bool operator<(const SurfaceId& other) const {
65 return std::tie(client_id_, local_id_, nonce_) < 72 return std::tie(frame_sink_id_, local_id_, nonce_) <
66 std::tie(other.client_id_, other.local_id_, other.nonce_); 73 std::tie(frame_sink_id_, other.local_id_, other.nonce_);
67 } 74 }
68 75
69 private: 76 private:
70 // See SurfaceIdAllocator::GenerateId. 77 // See SurfaceIdAllocator::GenerateId.
71 uint32_t client_id_; 78 FrameSinkId frame_sink_id_;
72 uint32_t local_id_; 79 uint32_t local_id_;
73 uint64_t nonce_; 80 uint64_t nonce_;
74 }; 81 };
75 82
76 struct SurfaceIdHash { 83 struct SurfaceIdHash {
77 size_t operator()(const SurfaceId& key) const { return key.hash(); } 84 size_t operator()(const SurfaceId& key) const { return key.hash(); }
78 }; 85 };
79 86
80 } // namespace cc 87 } // namespace cc
81 88
82 #endif // CC_SURFACES_SURFACE_ID_H_ 89 #endif // CC_SURFACES_SURFACE_ID_H_
OLDNEW
« no previous file with comments | « cc/surfaces/surface_factory.cc ('k') | cc/surfaces/surface_id_allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698