Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(656)

Side by Side Diff: cc/animation/element_id.h

Issue 1973083002: Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address reviewer feedback Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "base/hash.h"
15 #include "cc/base/cc_export.h"
16
17 namespace base {
18 class Value;
19 namespace trace_event {
20 class TracedValue;
21 } // namespace trace_event
22 } // namespace base
23
24 namespace cc {
25
26 namespace proto {
27 class ElementId;
28 } // namespace proto
29
30 // ------------------------------*IMPORTANT*---------------------------------
31 // ElementId has a corresponding proto defined in cc/proto/element_id.proto.
32 // When making any changes here, but sure to update the proto.
33
34 // An "element" is really an animation target. It retains the name element to be
35 // symmetric with ElementAnimations and blink::ElementAnimations, but is not
36 // in fact tied to the notion of a blink element. It is also not associated with
37 // the notion of a Layer. Ultimately, these ids will be used to look up the
38 // property tree node associated with the given animation.
39 //
40 // These ids are chosen by cc's clients to permit the destruction and
41 // restoration of cc entities (when visuals are hidden and shown) but maintain
42 // stable identifiers. There will be a single layer for an ElementId, but
43 // not every layer will have an id.
44 struct CC_EXPORT ElementId {
45 ElementId(int primaryId, int secondaryId)
46 : primaryId(primaryId), secondaryId(secondaryId) {}
47 ElementId() : ElementId(0, 0) {}
48
49 bool operator==(const ElementId& o) const;
50 bool operator!=(const ElementId& o) const;
51 bool operator<(const ElementId& o) const;
52 explicit operator bool() const;
53
54 void AddToTracedValue(base::trace_event::TracedValue* res) const;
55 std::unique_ptr<base::Value> AsValue() const;
56
57 void ToProtobuf(proto::ElementId* proto) const;
58 void FromProtobuf(const proto::ElementId& proto);
59
60 // The compositor treats this as an opaque handle and should not know how to
61 // interpret these bits. Non-blink cc clients typically operate in terms of
62 // layers and may set this value to match the client's layer id.
63 int primaryId;
64 int secondaryId;
65 };
66
67 CC_EXPORT ElementId LayerIdToElementIdForTesting(int layer_id);
68
69 struct CC_EXPORT ElementIdHash {
70 size_t operator()(ElementId key) const;
71 };
72
73 // Stream operator so ElementId can be used in assertion statements.
74 CC_EXPORT std::ostream& operator<<(std::ostream& out, const ElementId& id);
75
76 } // namespace cc
77
78 #endif // CC_ANIMATION_ELEMENT_ID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698