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