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