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

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

Issue 2455663003: Add cc::Surface ref counting. (Closed)
Patch Set: Fixes for fsamuel 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
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)
vmpstr 2016/11/02 20:28:12 Can this also be = default?
kylechar 2016/11/02 21:21:20 Done.
26 : frame_sink_id_(other.frame_sink_id_), 27 : frame_sink_id_(other.frame_sink_id_),
27 local_frame_id_(other.local_frame_id_) {} 28 local_frame_id_(other.local_frame_id_) {}
28 29
29 // A SurfaceId consists of three components: FrameSinkId, local Id, and nonce. 30 // 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 31 // 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 32 // display compositor service and one is allocated by the client. The
32 // |frame_sink_id| uniquely identifies a FrameSink (and frame source). 33 // |frame_sink_id| uniquely identifies a FrameSink (and frame source).
33 // A |local_id| is a sequentially allocated ID generated by the frame source 34 // 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 35 // that uniquely identifies a sequential set of frames of the same size and
35 // device scale factor. 36 // device scale factor.
36 // A |nonce| is a cryptographically secure unguessable token that makes it 37 // A |nonce| is a cryptographically secure unguessable token that makes it
37 // impossible for an unprivileged frame source to embed another frame source 38 // 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 39 // without being explicitly given the surface ID of that frame source from a
39 // privileged process. 40 // privileged process.
40 SurfaceId(const FrameSinkId& frame_sink_id, 41 constexpr SurfaceId(const FrameSinkId& frame_sink_id,
41 const LocalFrameId& local_frame_id) 42 const LocalFrameId& local_frame_id)
42 : frame_sink_id_(frame_sink_id), local_frame_id_(local_frame_id) {} 43 : frame_sink_id_(frame_sink_id), local_frame_id_(local_frame_id) {}
43 44
44 bool is_null() const { 45 bool is_null() const {
45 return frame_sink_id_.is_null() && local_frame_id_.is_null(); 46 return frame_sink_id_.is_null() && local_frame_id_.is_null();
46 } 47 }
47 48
48 size_t hash() const { 49 size_t hash() const {
49 return base::HashInts(static_cast<uint64_t>(frame_sink_id_.hash()), 50 return base::HashInts(static_cast<uint64_t>(frame_sink_id_.hash()),
50 static_cast<uint64_t>(local_frame_id_.hash())); 51 static_cast<uint64_t>(local_frame_id_.hash()));
51 } 52 }
(...skipping 26 matching lines...) Expand all
78 LocalFrameId local_frame_id_; 79 LocalFrameId local_frame_id_;
79 }; 80 };
80 81
81 struct SurfaceIdHash { 82 struct SurfaceIdHash {
82 size_t operator()(const SurfaceId& key) const { return key.hash(); } 83 size_t operator()(const SurfaceId& key) const { return key.hash(); }
83 }; 84 };
84 85
85 } // namespace cc 86 } // namespace cc
86 87
87 #endif // CC_SURFACES_SURFACE_ID_H_ 88 #endif // CC_SURFACES_SURFACE_ID_H_
OLDNEW
« no previous file with comments | « cc/BUILD.gn ('k') | cc/surfaces/surface_manager.h » ('j') | cc/surfaces/surface_manager.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698