| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_FRAME_SINK_ID_H_ | 5 #ifndef CC_SURFACES_FRAME_SINK_ID_H_ |
| 6 #define CC_SURFACES_FRAME_SINK_ID_H_ | 6 #define CC_SURFACES_FRAME_SINK_ID_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include <iosfwd> |
| 11 #include <string> |
| 8 #include <tuple> | 12 #include <tuple> |
| 9 | 13 |
| 10 #include "base/format_macros.h" | |
| 11 #include "base/hash.h" | 14 #include "base/hash.h" |
| 12 #include "base/strings/stringprintf.h" | |
| 13 | 15 |
| 14 namespace cc { | 16 namespace cc { |
| 15 | 17 |
| 16 class FrameSinkId { | 18 class FrameSinkId { |
| 17 public: | 19 public: |
| 18 constexpr FrameSinkId() : client_id_(0), sink_id_(0) {} | 20 constexpr FrameSinkId() : client_id_(0), sink_id_(0) {} |
| 19 | 21 |
| 20 constexpr FrameSinkId(const FrameSinkId& other) | 22 constexpr FrameSinkId(const FrameSinkId& other) |
| 21 : client_id_(other.client_id_), sink_id_(other.sink_id_) {} | 23 : client_id_(other.client_id_), sink_id_(other.sink_id_) {} |
| 22 | 24 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 35 | 37 |
| 36 bool operator!=(const FrameSinkId& other) const { return !(*this == other); } | 38 bool operator!=(const FrameSinkId& other) const { return !(*this == other); } |
| 37 | 39 |
| 38 bool operator<(const FrameSinkId& other) const { | 40 bool operator<(const FrameSinkId& other) const { |
| 39 return std::tie(client_id_, sink_id_) < | 41 return std::tie(client_id_, sink_id_) < |
| 40 std::tie(other.client_id_, other.sink_id_); | 42 std::tie(other.client_id_, other.sink_id_); |
| 41 } | 43 } |
| 42 | 44 |
| 43 size_t hash() const { return base::HashInts(client_id_, sink_id_); } | 45 size_t hash() const { return base::HashInts(client_id_, sink_id_); } |
| 44 | 46 |
| 45 std::string ToString() const { | 47 std::string ToString() const; |
| 46 return base::StringPrintf("FrameSinkId(%d, %d)", client_id_, sink_id_); | |
| 47 } | |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 uint32_t client_id_; | 50 uint32_t client_id_; |
| 51 uint32_t sink_id_; | 51 uint32_t sink_id_; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 std::ostream& operator<<(std::ostream& out, const FrameSinkId& frame_sink_id); |
| 55 |
| 54 struct FrameSinkIdHash { | 56 struct FrameSinkIdHash { |
| 55 size_t operator()(const FrameSinkId& key) const { return key.hash(); } | 57 size_t operator()(const FrameSinkId& key) const { return key.hash(); } |
| 56 }; | 58 }; |
| 57 | 59 |
| 58 } // namespace cc | 60 } // namespace cc |
| 59 | 61 |
| 60 #endif // CC_SURFACES_FRAME_SINK_ID_H_ | 62 #endif // CC_SURFACES_FRAME_SINK_ID_H_ |
| OLD | NEW |