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 "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 FrameSinkId() : client_id_(0), sink_id_(0) {} |
| 17 |
| 18 FrameSinkId(const FrameSinkId& other) |
| 19 : client_id_(other.client_id_), sink_id_(other.sink_id_) {} |
| 20 |
| 21 FrameSinkId(uint32_t client_id, uint32_t sink_id) |
| 22 : client_id_(client_id), sink_id_(sink_id) {} |
| 23 |
| 24 bool is_null() const { return client_id_ == 0 && sink_id_ == 0; } |
| 25 |
| 26 size_t hash() const { return base::HashInts(client_id_, sink_id_); } |
| 27 |
| 28 uint32_t client_id() const { return client_id_; } |
| 29 |
| 30 uint32_t sink_id() const { return sink_id_; } |
| 31 |
| 32 std::string ToString() const { |
| 33 return base::StringPrintf("FrameSinkId(%d, %d)", client_id_, sink_id_); |
| 34 } |
| 35 |
| 36 bool operator==(const FrameSinkId& other) const { |
| 37 return client_id_ == other.client_id_ && sink_id_ == other.sink_id_; |
| 38 } |
| 39 |
| 40 bool operator!=(const FrameSinkId& other) const { return !(*this == other); } |
| 41 |
| 42 bool operator<(const FrameSinkId& other) const { |
| 43 return std::tie(client_id_, sink_id_) < |
| 44 std::tie(other.client_id_, other.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_ |
OLD | NEW |