| 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_SURFACE_REFERENCE_H_ |
| 6 #define CC_SURFACES_SURFACE_REFERENCE_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/hash.h" |
| 11 #include "cc/surfaces/surface_id.h" |
| 12 #include "mojo/public/cpp/bindings/struct_traits.h" // nogncheck |
| 13 |
| 14 namespace cc { |
| 15 namespace mojom { |
| 16 class SurfaceReferenceDataView; |
| 17 } |
| 18 |
| 19 class SurfaceReference { |
| 20 public: |
| 21 SurfaceReference(); |
| 22 SurfaceReference(const SurfaceId& parent_id, const SurfaceId& child_id); |
| 23 SurfaceReference(const SurfaceReference& other); |
| 24 |
| 25 ~SurfaceReference(); |
| 26 |
| 27 const SurfaceId& parent_id() const { return parent_id_; } |
| 28 const SurfaceId& child_id() const { return child_id_; } |
| 29 |
| 30 size_t hash() const { |
| 31 return base::HashInts(static_cast<uint64_t>(parent_id_.hash()), |
| 32 static_cast<uint64_t>(child_id_.hash())); |
| 33 } |
| 34 |
| 35 bool operator==(const SurfaceReference& other) const { |
| 36 return parent_id_ == other.parent_id_ && child_id_ == other.child_id_; |
| 37 } |
| 38 |
| 39 bool operator!=(const SurfaceReference& other) const { |
| 40 return !(*this == other); |
| 41 } |
| 42 |
| 43 bool operator<(const SurfaceReference& other) const { |
| 44 return std::tie(parent_id_, child_id_) < |
| 45 std::tie(other.parent_id_, other.child_id_); |
| 46 } |
| 47 |
| 48 std::string ToString() const; |
| 49 |
| 50 private: |
| 51 friend struct mojo::StructTraits<mojom::SurfaceReferenceDataView, |
| 52 SurfaceReference>; |
| 53 |
| 54 SurfaceId parent_id_; |
| 55 SurfaceId child_id_; |
| 56 }; |
| 57 |
| 58 struct SurfaceReferenceHash { |
| 59 size_t operator()(const SurfaceReference& ref) const { |
| 60 return base::HashInts(static_cast<uint64_t>(ref.parent_id().hash()), |
| 61 static_cast<uint64_t>(ref.child_id().hash())); |
| 62 } |
| 63 }; |
| 64 |
| 65 } // namespace cc |
| 66 |
| 67 #endif // CC_SURFACES_SURFACE_REFERENCE_H_ |
| OLD | NEW |