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 "base/containers/hash_tables.h" |
| 9 |
8 namespace cc { | 10 namespace cc { |
9 | 11 |
10 // A per-surface-namespace sequence number that's used to coordinate | 12 // A per-surface-namespace sequence number that's used to coordinate |
11 // dependencies between frames. A sequence number may be satisfied once, and | 13 // dependencies between frames. A sequence number may be satisfied once, and |
12 // may be depended on once. | 14 // may be depended on once. |
13 struct SurfaceSequence { | 15 struct SurfaceSequence { |
14 SurfaceSequence() : id_namespace(0u), sequence(0u) {} | 16 SurfaceSequence() : id_namespace(0u), sequence(0u) {} |
15 SurfaceSequence(uint32_t id_namespace, uint32_t sequence) | 17 SurfaceSequence(uint32_t id_namespace, uint32_t sequence) |
16 : id_namespace(id_namespace), sequence(sequence) {} | 18 : id_namespace(id_namespace), sequence(sequence) {} |
| 19 bool is_null() const { return id_namespace == 0u && sequence == 0u; } |
17 | 20 |
18 uint32_t id_namespace; | 21 uint32_t id_namespace; |
19 uint32_t sequence; | 22 uint32_t sequence; |
20 }; | 23 }; |
21 | 24 |
22 inline bool operator==(const SurfaceSequence& a, const SurfaceSequence& b) { | 25 inline bool operator==(const SurfaceSequence& a, const SurfaceSequence& b) { |
23 return a.id_namespace == b.id_namespace && a.sequence == b.sequence; | 26 return a.id_namespace == b.id_namespace && a.sequence == b.sequence; |
24 } | 27 } |
25 | 28 |
26 inline bool operator!=(const SurfaceSequence& a, const SurfaceSequence& b) { | 29 inline bool operator!=(const SurfaceSequence& a, const SurfaceSequence& b) { |
27 return !(a == b); | 30 return !(a == b); |
28 } | 31 } |
29 | 32 |
30 inline bool operator<(const SurfaceSequence& a, const SurfaceSequence& b) { | 33 inline bool operator<(const SurfaceSequence& a, const SurfaceSequence& b) { |
31 if (a.id_namespace != b.id_namespace) | 34 if (a.id_namespace != b.id_namespace) |
32 return a.id_namespace < b.id_namespace; | 35 return a.id_namespace < b.id_namespace; |
33 return a.sequence < b.sequence; | 36 return a.sequence < b.sequence; |
34 } | 37 } |
35 | 38 |
36 } // namespace cc | 39 } // namespace cc |
37 | 40 |
| 41 namespace BASE_HASH_NAMESPACE { |
| 42 template <> |
| 43 struct hash<cc::SurfaceSequence> { |
| 44 size_t operator()(cc::SurfaceSequence key) const { |
| 45 return base::HashPair(key.id_namespace, key.sequence); |
| 46 } |
| 47 }; |
| 48 } // namespace BASE_HASH_NAMESPACE |
| 49 |
38 #endif // CC_SURFACES_SURFACE_SEQUENCE_H_ | 50 #endif // CC_SURFACES_SURFACE_SEQUENCE_H_ |
OLD | NEW |