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

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

Issue 2661543002: Rename LocalFrameId to LocalSurfaceId (Closed)
Patch Set: c Created 3 years, 10 months 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
« no previous file with comments | « cc/surfaces/surface_hittest_unittest.cc ('k') | cc/surfaces/surface_id.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_SURFACES_SURFACE_ID_H_ 5 #ifndef CC_SURFACES_SURFACE_ID_H_
6 #define CC_SURFACES_SURFACE_ID_H_ 6 #define CC_SURFACES_SURFACE_ID_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <iosfwd> 10 #include <iosfwd>
11 #include <string> 11 #include <string>
12 12
13 #include "base/format_macros.h" 13 #include "base/format_macros.h"
14 #include "base/hash.h" 14 #include "base/hash.h"
15 #include "cc/surfaces/frame_sink_id.h" 15 #include "cc/surfaces/frame_sink_id.h"
16 #include "cc/surfaces/local_frame_id.h" 16 #include "cc/surfaces/local_surface_id.h"
17 #include "mojo/public/cpp/bindings/struct_traits.h" 17 #include "mojo/public/cpp/bindings/struct_traits.h"
18 18
19 namespace cc { 19 namespace cc {
20 namespace mojom { 20 namespace mojom {
21 class SurfaceIdDataView; 21 class SurfaceIdDataView;
22 } 22 }
23 23
24 class SurfaceId { 24 class SurfaceId {
25 public: 25 public:
26 constexpr SurfaceId() = default; 26 constexpr SurfaceId() = default;
27 27
28 constexpr SurfaceId(const SurfaceId& other) = default; 28 constexpr SurfaceId(const SurfaceId& other) = default;
29 29
30 // A SurfaceId consists of two components: FrameSinkId and LocalFrameId. 30 // A SurfaceId consists of two components: FrameSinkId and LocalSurfaceId.
31 // A |frame_sink_id| consists of two components; one is allocated by the 31 // A |frame_sink_id| consists of two components; one is allocated by the
32 // display compositor service and one is allocated by the client. The 32 // display compositor service and one is allocated by the client. The
33 // |frame_sink_id| uniquely identifies a FrameSink (and frame source). 33 // |frame_sink_id| uniquely identifies a FrameSink (and frame source).
34 // A |local_frame_id| is a sequentially allocated ID generated by the frame 34 // A |local_surface_id| is a sequentially allocated ID generated by the frame
35 // source that uniquely identifies a sequential set of frames of the same size 35 // source that uniquely identifies a sequential set of frames of the same size
36 // and device scale factor. 36 // and device scale factor.
37 constexpr SurfaceId(const FrameSinkId& frame_sink_id, 37 constexpr SurfaceId(const FrameSinkId& frame_sink_id,
38 const LocalFrameId& local_frame_id) 38 const LocalSurfaceId& local_surface_id)
39 : frame_sink_id_(frame_sink_id), local_frame_id_(local_frame_id) {} 39 : frame_sink_id_(frame_sink_id), local_surface_id_(local_surface_id) {}
40 40
41 bool is_valid() const { 41 bool is_valid() const {
42 return frame_sink_id_.is_valid() && local_frame_id_.is_valid(); 42 return frame_sink_id_.is_valid() && local_surface_id_.is_valid();
43 } 43 }
44 44
45 size_t hash() const { 45 size_t hash() const {
46 return base::HashInts(static_cast<uint64_t>(frame_sink_id_.hash()), 46 return base::HashInts(static_cast<uint64_t>(frame_sink_id_.hash()),
47 static_cast<uint64_t>(local_frame_id_.hash())); 47 static_cast<uint64_t>(local_surface_id_.hash()));
48 } 48 }
49 49
50 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } 50 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; }
51 51
52 const LocalFrameId& local_frame_id() const { return local_frame_id_; } 52 const LocalSurfaceId& local_surface_id() const { return local_surface_id_; }
53 53
54 std::string ToString() const; 54 std::string ToString() const;
55 55
56 bool operator==(const SurfaceId& other) const { 56 bool operator==(const SurfaceId& other) const {
57 return frame_sink_id_ == other.frame_sink_id_ && 57 return frame_sink_id_ == other.frame_sink_id_ &&
58 local_frame_id_ == other.local_frame_id_; 58 local_surface_id_ == other.local_surface_id_;
59 } 59 }
60 60
61 bool operator!=(const SurfaceId& other) const { return !(*this == other); } 61 bool operator!=(const SurfaceId& other) const { return !(*this == other); }
62 62
63 bool operator<(const SurfaceId& other) const { 63 bool operator<(const SurfaceId& other) const {
64 return std::tie(frame_sink_id_, local_frame_id_) < 64 return std::tie(frame_sink_id_, local_surface_id_) <
65 std::tie(other.frame_sink_id_, other.local_frame_id_); 65 std::tie(other.frame_sink_id_, other.local_surface_id_);
66 } 66 }
67 67
68 private: 68 private:
69 friend struct mojo::StructTraits<mojom::SurfaceIdDataView, SurfaceId>; 69 friend struct mojo::StructTraits<mojom::SurfaceIdDataView, SurfaceId>;
70 70
71 // See SurfaceIdAllocator::GenerateId. 71 // See SurfaceIdAllocator::GenerateId.
72 FrameSinkId frame_sink_id_; 72 FrameSinkId frame_sink_id_;
73 LocalFrameId local_frame_id_; 73 LocalSurfaceId local_surface_id_;
74 }; 74 };
75 75
76 std::ostream& operator<<(std::ostream& out, const SurfaceId& surface_id); 76 std::ostream& operator<<(std::ostream& out, const SurfaceId& surface_id);
77 77
78 struct SurfaceIdHash { 78 struct SurfaceIdHash {
79 size_t operator()(const SurfaceId& key) const { return key.hash(); } 79 size_t operator()(const SurfaceId& key) const { return key.hash(); }
80 }; 80 };
81 81
82 } // namespace cc 82 } // namespace cc
83 83
84 #endif // CC_SURFACES_SURFACE_ID_H_ 84 #endif // CC_SURFACES_SURFACE_ID_H_
OLDNEW
« no previous file with comments | « cc/surfaces/surface_hittest_unittest.cc ('k') | cc/surfaces/surface_id.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698