OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_ANIMATION_ELEMENT_ID_H_ | |
6 #define CC_ANIMATION_ELEMENT_ID_H_ | |
7 | |
8 #include <cstdint> | |
9 #include <functional> | |
10 #include <iosfwd> | |
11 #include <memory> | |
12 #include <stddef.h> | |
13 | |
14 #include "cc/base/cc_export.h" | |
15 | |
16 namespace base { | |
17 class Value; | |
18 namespace trace_event { | |
19 class TracedValue; | |
20 } // namespace trace_event | |
21 } // namespace base | |
22 | |
23 namespace cc { | |
24 | |
25 namespace proto { | |
26 class ElementId; | |
27 } // namespace proto | |
28 | |
29 // ------------------------------*IMPORTANT*--------------------------------- | |
30 // ElementId has a corresponding proto defined in cc/proto/element_id.proto. | |
31 // When making any changes here, but sure to update the proto. | |
32 | |
33 struct CC_EXPORT ElementId { | |
jbroman
2016/06/02 20:20:21
would you mind a comment describing what sort of e
Ian Vollick
2016/06/03 19:31:21
Done.
| |
34 explicit ElementId(uint64_t value) : value(value) {} | |
35 ElementId() : value(0ul) {} | |
36 | |
37 inline bool operator==(const ElementId& o) const { return o.value == value; } | |
loyso (OOO)
2016/06/03 02:45:34
no need to write |inline| here.
Ian Vollick
2016/06/03 19:31:21
Done.
| |
38 inline bool operator!=(const ElementId& o) const { return o.value != value; } | |
39 inline bool operator<(const ElementId& o) const { return value < o.value; } | |
40 inline explicit operator bool() const { return !!value; } | |
41 | |
42 void AddToTracedValue(base::trace_event::TracedValue* res) const; | |
43 std::unique_ptr<base::Value> AsValue() const; | |
44 | |
45 void ToProtobuf(proto::ElementId* proto) const; | |
46 void FromProtobuf(const proto::ElementId& proto); | |
47 | |
48 uint64_t value; | |
49 }; | |
50 | |
51 ElementId CC_EXPORT LayerIdToElementIdForTesting(int layer_id); | |
jbroman
2016/06/02 20:20:21
style: please put CC_EXPORT before the return type
Ian Vollick
2016/06/03 19:31:21
Done.
| |
52 | |
53 struct ElementIdHash { | |
54 size_t operator()(ElementId key) const { | |
55 return std::hash<uint64_t>()(key.value); | |
56 } | |
57 }; | |
58 | |
59 // Stream operator so ElementId can be used in assertion statements. | |
60 CC_EXPORT std::ostream& operator<<(std::ostream& out, const ElementId& id); | |
61 | |
62 } // namespace cc | |
63 | |
64 #endif // CC_ANIMATION_ELEMENT_ID_H_ | |
OLD | NEW |