Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | 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 "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "cc/surfaces/frame_sink_id.h" | 16 #include "cc/surfaces/frame_sink_id.h" |
| 17 #include "cc/surfaces/local_frame_id.h" | 17 #include "cc/surfaces/local_frame_id.h" |
| 18 | 18 |
| 19 namespace cc { | 19 namespace cc { |
| 20 | 20 |
| 21 class SurfaceId { | 21 class SurfaceId { |
| 22 public: | 22 public: |
| 23 SurfaceId() = default; | 23 SurfaceId() = default; |
| 24 | 24 |
| 25 SurfaceId(const SurfaceId& other) | 25 SurfaceId(const SurfaceId& other) |
| 26 : frame_sink_id_(other.frame_sink_id_), | 26 : frame_sink_id_(other.frame_sink_id_), |
| 27 local_frame_id_(other.local_frame_id_) {} | 27 local_frame_id_(other.local_frame_id_) {} |
| 28 | 28 |
| 29 // A SurfaceId consists of three components: FrameSinkId, local Id, and nonce. | 29 // A SurfaceId consists of two components: FrameSinkId and local_frame_id. |
|
Fady Samuel
2016/11/09 21:41:57
nit: FrameSinkId and LocalFrameId.
Alex Z.
2016/11/09 22:05:21
Done.
| |
| 30 // A |frame_sink_id| consists of two components; one is allocated by the | 30 // 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 | 31 // display compositor service and one is allocated by the client. The |
| 32 // |frame_sink_id| uniquely identifies a FrameSink (and frame source). | 32 // |frame_sink_id| uniquely identifies a FrameSink (and frame source). |
| 33 // A |local_id| is a sequentially allocated ID generated by the frame source | 33 // A |local_frame_id| is a sequentially allocated ID generated by the frame |
| 34 // that uniquely identifies a sequential set of frames of the same size and | 34 // source that uniquely identifies a sequential set of frames of the same size |
| 35 // device scale factor. | 35 // and device scale factor. |
| 36 // A |nonce| is a cryptographically secure unguessable token that makes it | |
| 37 // 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 // privileged process. | |
| 40 SurfaceId(const FrameSinkId& frame_sink_id, | 36 SurfaceId(const FrameSinkId& frame_sink_id, |
| 41 const LocalFrameId& local_frame_id) | 37 const LocalFrameId& local_frame_id) |
| 42 : frame_sink_id_(frame_sink_id), local_frame_id_(local_frame_id) {} | 38 : frame_sink_id_(frame_sink_id), local_frame_id_(local_frame_id) {} |
| 43 | 39 |
| 44 bool is_null() const { | 40 bool is_null() const { |
| 45 return frame_sink_id_.is_null() && local_frame_id_.is_null(); | 41 return frame_sink_id_.is_null() && local_frame_id_.is_null(); |
| 46 } | 42 } |
| 47 | 43 |
| 48 size_t hash() const { | 44 size_t hash() const { |
| 49 return base::HashInts(static_cast<uint64_t>(frame_sink_id_.hash()), | 45 return base::HashInts(static_cast<uint64_t>(frame_sink_id_.hash()), |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 78 LocalFrameId local_frame_id_; | 74 LocalFrameId local_frame_id_; |
| 79 }; | 75 }; |
| 80 | 76 |
| 81 struct SurfaceIdHash { | 77 struct SurfaceIdHash { |
| 82 size_t operator()(const SurfaceId& key) const { return key.hash(); } | 78 size_t operator()(const SurfaceId& key) const { return key.hash(); } |
| 83 }; | 79 }; |
| 84 | 80 |
| 85 } // namespace cc | 81 } // namespace cc |
| 86 | 82 |
| 87 #endif // CC_SURFACES_SURFACE_ID_H_ | 83 #endif // CC_SURFACES_SURFACE_ID_H_ |
| OLD | NEW |