Chromium Code Reviews| Index: cc/surfaces/surface_reference.h |
| diff --git a/cc/surfaces/surface_reference.h b/cc/surfaces/surface_reference.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..06aaa8b86ff86e88725ad513cecafa7485b6554c |
| --- /dev/null |
| +++ b/cc/surfaces/surface_reference.h |
| @@ -0,0 +1,64 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CC_SURFACES_SURFACE_REFERENCE_H_ |
| +#define CC_SURFACES_SURFACE_REFERENCE_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/hash.h" |
| +#include "cc/surfaces/surface_id.h" |
| +#include "mojo/public/cpp/bindings/struct_traits.h" |
| + |
| +namespace cc { |
| +namespace mojom { |
| +class SurfaceReferenceDataView; |
| +} |
| + |
| +class SurfaceReference { |
|
vmpstr
2016/12/02 19:33:35
Can you add a small class comment briefly describi
kylechar
2016/12/02 20:16:23
Done.
|
| + public: |
| + SurfaceReference(); |
| + SurfaceReference(const SurfaceId& parent_id, const SurfaceId& child_id); |
| + SurfaceReference(const SurfaceReference& other); |
| + |
| + ~SurfaceReference(); |
| + |
| + const SurfaceId& parent_id() const { return parent_id_; } |
| + const SurfaceId& child_id() const { return child_id_; } |
| + |
| + size_t hash() const { |
| + return base::HashInts(static_cast<uint64_t>(parent_id_.hash()), |
| + static_cast<uint64_t>(child_id_.hash())); |
| + } |
| + |
| + bool operator==(const SurfaceReference& other) const { |
| + return parent_id_ == other.parent_id_ && child_id_ == other.child_id_; |
| + } |
| + |
| + bool operator!=(const SurfaceReference& other) const { |
| + return !(*this == other); |
| + } |
| + |
| + bool operator<(const SurfaceReference& other) const { |
| + return std::tie(parent_id_, child_id_) < |
| + std::tie(other.parent_id_, other.child_id_); |
| + } |
| + |
| + std::string ToString() const; |
| + |
| + private: |
| + friend struct mojo::StructTraits<mojom::SurfaceReferenceDataView, |
| + SurfaceReference>; |
| + |
| + SurfaceId parent_id_; |
| + SurfaceId child_id_; |
| +}; |
| + |
| +struct SurfaceReferenceHash { |
| + size_t operator()(const SurfaceReference& ref) const { return ref.hash(); } |
| +}; |
| + |
| +} // namespace cc |
| + |
| +#endif // CC_SURFACES_SURFACE_REFERENCE_H_ |