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

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

Issue 2382873002: Replace usage of SurfaceId's client_id with FrameSinkId (Closed)
Patch Set: Fixed windows + android + mac issues 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CC_SURFACES_FRAME_SINK_ID_H_
6 #define CC_SURFACES_FRAME_SINK_ID_H_
7
8 #include "base/format_macros.h"
9 #include "base/hash.h"
10 #include "base/strings/stringprintf.h"
11
12 namespace cc {
13
14 class FrameSinkId {
15 public:
16 constexpr FrameSinkId() : client_id_(0), sink_id_(0) {}
17
18 constexpr FrameSinkId(const FrameSinkId& other)
19 : client_id_(other.client_id_), sink_id_(other.sink_id_) {}
20
21 constexpr FrameSinkId(uint32_t client_id, uint32_t sink_id)
22 : client_id_(client_id), sink_id_(sink_id) {}
23
24 constexpr bool is_null() const { return client_id_ == 0 && sink_id_ == 0; }
25
26 constexpr uint32_t client_id() const { return client_id_; }
27
28 constexpr uint32_t sink_id() const { return sink_id_; }
29
30 bool operator==(const FrameSinkId& other) const {
31 return client_id_ == other.client_id_ && sink_id_ == other.sink_id_;
32 }
33
34 bool operator!=(const FrameSinkId& other) const { return !(*this == other); }
35
36 bool operator<(const FrameSinkId& other) const {
37 return std::tie(client_id_, sink_id_) <
38 std::tie(other.client_id_, other.sink_id_);
39 }
40
41 size_t hash() const { return base::HashInts(client_id_, sink_id_); }
42
43 std::string ToString() const {
44 return base::StringPrintf("FrameSinkId(%d, %d)", client_id_, sink_id_);
45 }
46
47 private:
48 uint32_t client_id_;
49 uint32_t sink_id_;
50 };
51
52 struct FrameSinkIdHash {
53 size_t operator()(const FrameSinkId& key) const { return key.hash(); }
54 };
55
56 } // namespace cc
57
58 #endif // CC_SURFACES_FRAME_SINK_ID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698