Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2869)

Unified Diff: cc/surfaces/surface_reference.h

Issue 2541683004: Add/remove surface references via MojoCompositorFrameSink. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3a079b9de20b63b26b4aac951eb78e0adff6edf0
--- /dev/null
+++ b/cc/surfaces/surface_reference.h
@@ -0,0 +1,67 @@
+// 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" // nogncheck
+
+namespace cc {
+namespace mojom {
+class SurfaceReferenceDataView;
+}
+
+class SurfaceReference {
+ 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 base::HashInts(static_cast<uint64_t>(ref.parent_id().hash()),
+ static_cast<uint64_t>(ref.child_id().hash()));
+ }
+};
+
+} // namespace cc
+
+#endif // CC_SURFACES_SURFACE_REFERENCE_H_

Powered by Google App Engine
This is Rietveld 408576698