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 <stddef.h> | |
9 | |
10 #include <cstdint> | |
11 #include <functional> | |
12 #include <iosfwd> | |
13 #include <memory> | |
14 | |
15 #include "base/hash.h" | |
16 #include "cc/base/cc_export.h" | |
17 | |
18 namespace base { | |
19 class Value; | |
20 namespace trace_event { | |
21 class TracedValue; | |
22 } // namespace trace_event | |
23 } // namespace base | |
24 | |
25 namespace cc { | |
26 | |
27 namespace proto { | |
28 class ElementId; | |
29 } // namespace proto | |
30 | |
31 // ------------------------------*IMPORTANT*--------------------------------- | |
32 // ElementId has a corresponding proto defined in cc/proto/element_id.proto. | |
33 // When making any changes here, but sure to update the proto. | |
34 | |
35 // An "element" is really an animation target. It retains the name element to be | |
36 // symmetric with ElementAnimations and blink::ElementAnimations, but is not | |
37 // in fact tied to the notion of a blink element. It is also not associated with | |
38 // the notion of a Layer. Ultimately, these ids will be used to look up the | |
39 // property tree node associated with the given animation. | |
40 // | |
41 // These ids are chosen by cc's clients to permit the destruction and | |
42 // restoration of cc entities (when visuals are hidden and shown) but maintain | |
43 // stable identifiers. There will be a single layer for an ElementId, but | |
44 // not every layer will have an id. | |
45 struct CC_EXPORT ElementId { | |
46 ElementId(int primaryId, int secondaryId) | |
47 : primaryId(primaryId), secondaryId(secondaryId) {} | |
48 ElementId() : ElementId(0, 0) {} | |
49 | |
50 bool operator==(const ElementId& o) const; | |
51 bool operator!=(const ElementId& o) const; | |
52 bool operator<(const ElementId& o) const; | |
53 | |
54 // An ElementId's conversion to a boolean value depends only on its primaryId. | |
55 explicit operator bool() const; | |
56 | |
57 void AddToTracedValue(base::trace_event::TracedValue* res) const; | |
58 std::unique_ptr<base::Value> AsValue() const; | |
59 | |
60 void ToProtobuf(proto::ElementId* proto) const; | |
61 void FromProtobuf(const proto::ElementId& proto); | |
62 | |
63 // The compositor treats this as an opaque handle and should not know how to | |
64 // interpret these bits. Non-blink cc clients typically operate in terms of | |
65 // layers and may set this value to match the client's layer id. | |
66 int primaryId; | |
67 int secondaryId; | |
68 }; | |
69 | |
70 CC_EXPORT ElementId LayerIdToElementIdForTesting(int layer_id); | |
71 | |
72 struct CC_EXPORT ElementIdHash { | |
73 size_t operator()(ElementId key) const; | |
74 }; | |
75 | |
76 // Stream operator so ElementId can be used in assertion statements. | |
77 CC_EXPORT std::ostream& operator<<(std::ostream& out, const ElementId& id); | |
78 | |
79 } // namespace cc | |
80 | |
81 #endif // CC_ANIMATION_ELEMENT_ID_H_ | |
OLD | NEW |