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

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

Issue 2455663003: Add cc::Surface ref counting. (Closed)
Patch Set: Address comments. Created 4 years, 1 month 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/BUILD.gn ('k') | cc/surfaces/surface_manager.h » ('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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <functional> 11 #include <functional>
12 #include <string>
12 13
13 #include "base/format_macros.h" 14 #include "base/format_macros.h"
14 #include "base/hash.h" 15 #include "base/hash.h"
15 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
16 #include "cc/surfaces/frame_sink_id.h" 17 #include "cc/surfaces/frame_sink_id.h"
17 #include "cc/surfaces/local_frame_id.h" 18 #include "cc/surfaces/local_frame_id.h"
18 19
19 namespace cc { 20 namespace cc {
20 21
21 class SurfaceId { 22 class SurfaceId {
22 public: 23 public:
23 SurfaceId() = default; 24 constexpr SurfaceId() = default;
24 25
25 SurfaceId(const SurfaceId& other) 26 constexpr SurfaceId(const SurfaceId& other) = default;
26 : frame_sink_id_(other.frame_sink_id_),
27 local_frame_id_(other.local_frame_id_) {}
28 27
29 // A SurfaceId consists of three components: FrameSinkId, local Id, and nonce. 28 // A SurfaceId consists of three components: FrameSinkId, local Id, and nonce.
30 // A |frame_sink_id| consists of two components; one is allocated by the 29 // A |frame_sink_id| consists of two components; one is allocated by the
31 // display compositor service and one is allocated by the client. The 30 // display compositor service and one is allocated by the client. The
32 // |frame_sink_id| uniquely identifies a FrameSink (and frame source). 31 // |frame_sink_id| uniquely identifies a FrameSink (and frame source).
33 // A |local_id| is a sequentially allocated ID generated by the frame source 32 // A |local_id| is a sequentially allocated ID generated by the frame source
34 // that uniquely identifies a sequential set of frames of the same size and 33 // that uniquely identifies a sequential set of frames of the same size and
35 // device scale factor. 34 // device scale factor.
36 // A |nonce| is a cryptographically secure unguessable token that makes it 35 // A |nonce| is a cryptographically secure unguessable token that makes it
37 // impossible for an unprivileged frame source to embed another frame source 36 // impossible for an unprivileged frame source to embed another frame source
38 // without being explicitly given the surface ID of that frame source from a 37 // without being explicitly given the surface ID of that frame source from a
39 // privileged process. 38 // privileged process.
40 SurfaceId(const FrameSinkId& frame_sink_id, 39 constexpr SurfaceId(const FrameSinkId& frame_sink_id,
41 const LocalFrameId& local_frame_id) 40 const LocalFrameId& local_frame_id)
42 : frame_sink_id_(frame_sink_id), local_frame_id_(local_frame_id) {} 41 : frame_sink_id_(frame_sink_id), local_frame_id_(local_frame_id) {}
43 42
44 bool is_null() const { 43 bool is_null() const {
45 return frame_sink_id_.is_null() && local_frame_id_.is_null(); 44 return frame_sink_id_.is_null() && local_frame_id_.is_null();
46 } 45 }
47 46
48 size_t hash() const { 47 size_t hash() const {
49 return base::HashInts(static_cast<uint64_t>(frame_sink_id_.hash()), 48 return base::HashInts(static_cast<uint64_t>(frame_sink_id_.hash()),
50 static_cast<uint64_t>(local_frame_id_.hash())); 49 static_cast<uint64_t>(local_frame_id_.hash()));
51 } 50 }
(...skipping 26 matching lines...) Expand all
78 LocalFrameId local_frame_id_; 77 LocalFrameId local_frame_id_;
79 }; 78 };
80 79
81 struct SurfaceIdHash { 80 struct SurfaceIdHash {
82 size_t operator()(const SurfaceId& key) const { return key.hash(); } 81 size_t operator()(const SurfaceId& key) const { return key.hash(); }
83 }; 82 };
84 83
85 } // namespace cc 84 } // namespace cc
86 85
87 #endif // CC_SURFACES_SURFACE_ID_H_ 86 #endif // CC_SURFACES_SURFACE_ID_H_
OLDNEW
« no previous file with comments | « cc/BUILD.gn ('k') | cc/surfaces/surface_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698