OLD | NEW |
(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 <tuple> |
| 9 |
| 10 #include "base/format_macros.h" |
| 11 #include "base/hash.h" |
| 12 #include "base/strings/stringprintf.h" |
| 13 |
| 14 namespace cc { |
| 15 |
| 16 class FrameSinkId { |
| 17 public: |
| 18 constexpr FrameSinkId() : client_id_(0), sink_id_(0) {} |
| 19 |
| 20 constexpr FrameSinkId(const FrameSinkId& other) |
| 21 : client_id_(other.client_id_), sink_id_(other.sink_id_) {} |
| 22 |
| 23 constexpr FrameSinkId(uint32_t client_id, uint32_t sink_id) |
| 24 : client_id_(client_id), sink_id_(sink_id) {} |
| 25 |
| 26 constexpr bool is_null() const { return client_id_ == 0 && sink_id_ == 0; } |
| 27 |
| 28 constexpr uint32_t client_id() const { return client_id_; } |
| 29 |
| 30 constexpr uint32_t sink_id() const { return sink_id_; } |
| 31 |
| 32 bool operator==(const FrameSinkId& other) const { |
| 33 return client_id_ == other.client_id_ && sink_id_ == other.sink_id_; |
| 34 } |
| 35 |
| 36 bool operator!=(const FrameSinkId& other) const { return !(*this == other); } |
| 37 |
| 38 bool operator<(const FrameSinkId& other) const { |
| 39 return std::tie(client_id_, sink_id_) < |
| 40 std::tie(other.client_id_, other.sink_id_); |
| 41 } |
| 42 |
| 43 size_t hash() const { return base::HashInts(client_id_, sink_id_); } |
| 44 |
| 45 std::string ToString() const { |
| 46 return base::StringPrintf("FrameSinkId(%d, %d)", client_id_, sink_id_); |
| 47 } |
| 48 |
| 49 private: |
| 50 uint32_t client_id_; |
| 51 uint32_t sink_id_; |
| 52 }; |
| 53 |
| 54 struct FrameSinkIdHash { |
| 55 size_t operator()(const FrameSinkId& key) const { return key.hash(); } |
| 56 }; |
| 57 |
| 58 } // namespace cc |
| 59 |
| 60 #endif // CC_SURFACES_FRAME_SINK_ID_H_ |
OLD | NEW |