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

Side by Side Diff: cc/surfaces/surface_reference.h

Issue 2537343004: Add SurfaceReference class. (Closed)
Patch Set: Fix nit. 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 unified diff | Download patch
OLDNEW
(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 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.
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 { return ref.hash(); }
60 };
61
62 } // namespace cc
63
64 #endif // CC_SURFACES_SURFACE_REFERENCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698