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_SEQUENCE_H_ | 5 #ifndef CC_SURFACES_SURFACE_SEQUENCE_H_ |
| 6 #define CC_SURFACES_SURFACE_SEQUENCE_H_ | 6 #define CC_SURFACES_SURFACE_SEQUENCE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <tuple> | 11 #include <tuple> |
| 12 | 12 |
| 13 #include "base/hash.h" | 13 #include "base/hash.h" |
| 14 #include "cc/surfaces/frame_sink_id.h" | 14 #include "cc/surfaces/frame_sink_id.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 // A per-surface-namespace sequence number that's used to coordinate | 18 // A per-surface-namespace sequence number that's used to coordinate |
| 19 // dependencies between frames. A sequence number may be satisfied once, and | 19 // dependencies between frames. A sequence number may be satisfied once, and |
| 20 // may be depended on once. | 20 // may be depended on once. |
| 21 struct SurfaceSequence { | 21 struct SurfaceSequence { |
| 22 SurfaceSequence() : sequence(0u) {} | 22 SurfaceSequence() : sequence(0u) {} |
| 23 SurfaceSequence(const FrameSinkId& frame_sink_id, uint32_t sequence) | 23 SurfaceSequence(const FrameSinkId& frame_sink_id, uint32_t sequence) |
| 24 : frame_sink_id(frame_sink_id), sequence(sequence) {} | 24 : frame_sink_id(frame_sink_id), sequence(sequence) {} |
| 25 bool is_null() const { return frame_sink_id.is_null() && sequence == 0u; } | 25 bool is_valid() const { return frame_sink_id.is_valid() && sequence > 0u; } |
|
piman
2016/11/08 23:16:34
Ditto, this changes the logic. Is that intended?
Alex Z.
2016/11/09 15:29:15
Yes. I will update the description to reflex the c
| |
| 26 | 26 |
| 27 FrameSinkId frame_sink_id; | 27 FrameSinkId frame_sink_id; |
| 28 uint32_t sequence; | 28 uint32_t sequence; |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 inline bool operator==(const SurfaceSequence& a, const SurfaceSequence& b) { | 31 inline bool operator==(const SurfaceSequence& a, const SurfaceSequence& b) { |
| 32 return a.frame_sink_id == b.frame_sink_id && a.sequence == b.sequence; | 32 return a.frame_sink_id == b.frame_sink_id && a.sequence == b.sequence; |
| 33 } | 33 } |
| 34 | 34 |
| 35 inline bool operator!=(const SurfaceSequence& a, const SurfaceSequence& b) { | 35 inline bool operator!=(const SurfaceSequence& a, const SurfaceSequence& b) { |
| 36 return !(a == b); | 36 return !(a == b); |
| 37 } | 37 } |
| 38 | 38 |
| 39 inline bool operator<(const SurfaceSequence& a, const SurfaceSequence& b) { | 39 inline bool operator<(const SurfaceSequence& a, const SurfaceSequence& b) { |
| 40 return std::tie(a.frame_sink_id, a.sequence) < | 40 return std::tie(a.frame_sink_id, a.sequence) < |
| 41 std::tie(b.frame_sink_id, b.sequence); | 41 std::tie(b.frame_sink_id, b.sequence); |
| 42 } | 42 } |
| 43 | 43 |
| 44 struct SurfaceSequenceHash { | 44 struct SurfaceSequenceHash { |
| 45 size_t operator()(SurfaceSequence key) const { | 45 size_t operator()(SurfaceSequence key) const { |
| 46 return base::HashInts(static_cast<uint64_t>(key.frame_sink_id.hash()), | 46 return base::HashInts(static_cast<uint64_t>(key.frame_sink_id.hash()), |
| 47 key.sequence); | 47 key.sequence); |
| 48 } | 48 } |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 } // namespace cc | 51 } // namespace cc |
| 52 | 52 |
| 53 #endif // CC_SURFACES_SURFACE_SEQUENCE_H_ | 53 #endif // CC_SURFACES_SURFACE_SEQUENCE_H_ |
| OLD | NEW |