| 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 <tuple> | 8 #include <tuple> |
| 9 | 9 |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| 11 #include "base/hash.h" | 11 #include "base/hash.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 class FrameSinkId { | 16 class FrameSinkId { |
| 17 public: | 17 public: |
| 18 constexpr FrameSinkId() : client_id_(0), sink_id_(0) {} | 18 constexpr FrameSinkId() : client_id_(0), sink_id_(0) {} |
| 19 | 19 |
| 20 constexpr FrameSinkId(const FrameSinkId& other) | 20 constexpr FrameSinkId(const FrameSinkId& other) |
| 21 : client_id_(other.client_id_), sink_id_(other.sink_id_) {} | 21 : client_id_(other.client_id_), sink_id_(other.sink_id_) {} |
| 22 | 22 |
| 23 constexpr FrameSinkId(uint32_t client_id, uint32_t sink_id) | 23 constexpr FrameSinkId(uint32_t client_id, uint32_t sink_id) |
| 24 : client_id_(client_id), sink_id_(sink_id) {} | 24 : client_id_(client_id), sink_id_(sink_id) {} |
| 25 | 25 |
| 26 constexpr bool is_null() const { return client_id_ == 0 && sink_id_ == 0; } | 26 constexpr bool is_valid() const { return client_id_ != 0 || sink_id_ != 0; } |
| 27 | 27 |
| 28 constexpr uint32_t client_id() const { return client_id_; } | 28 constexpr uint32_t client_id() const { return client_id_; } |
| 29 | 29 |
| 30 constexpr uint32_t sink_id() const { return sink_id_; } | 30 constexpr uint32_t sink_id() const { return sink_id_; } |
| 31 | 31 |
| 32 bool operator==(const FrameSinkId& other) const { | 32 bool operator==(const FrameSinkId& other) const { |
| 33 return client_id_ == other.client_id_ && sink_id_ == other.sink_id_; | 33 return client_id_ == other.client_id_ && sink_id_ == other.sink_id_; |
| 34 } | 34 } |
| 35 | 35 |
| 36 bool operator!=(const FrameSinkId& other) const { return !(*this == other); } | 36 bool operator!=(const FrameSinkId& other) const { return !(*this == other); } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 51 uint32_t sink_id_; | 51 uint32_t sink_id_; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 struct FrameSinkIdHash { | 54 struct FrameSinkIdHash { |
| 55 size_t operator()(const FrameSinkId& key) const { return key.hash(); } | 55 size_t operator()(const FrameSinkId& key) const { return key.hash(); } |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 } // namespace cc | 58 } // namespace cc |
| 59 | 59 |
| 60 #endif // CC_SURFACES_FRAME_SINK_ID_H_ | 60 #endif // CC_SURFACES_FRAME_SINK_ID_H_ |
| OLD | NEW |