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

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

Issue 2492133002: CC Animation: Move ElementId from animation to trees. (Closed)
Patch Set: Rebase. Created 4 years, 1 month 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
« no previous file with comments | « cc/animation/element_animations.h ('k') | cc/animation/element_id.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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 // An "element" is really an animation target. It retains the name element to be
28 // symmetric with ElementAnimations and blink::ElementAnimations, but is not
29 // in fact tied to the notion of a blink element. It is also not associated with
30 // the notion of a Layer. Ultimately, these ids will be used to look up the
31 // property tree node associated with the given animation.
32 //
33 // These ids are chosen by cc's clients to permit the destruction and
34 // restoration of cc entities (when visuals are hidden and shown) but maintain
35 // stable identifiers. There will be a single layer for an ElementId, but
36 // not every layer will have an id.
37 struct CC_EXPORT ElementId {
38 ElementId(int primaryId, int secondaryId)
39 : primaryId(primaryId), secondaryId(secondaryId) {}
40 ElementId() : ElementId(0, 0) {}
41
42 bool operator==(const ElementId& o) const;
43 bool operator!=(const ElementId& o) const;
44 bool operator<(const ElementId& o) const;
45
46 // An ElementId's conversion to a boolean value depends only on its primaryId.
47 explicit operator bool() const;
48
49 void AddToTracedValue(base::trace_event::TracedValue* res) const;
50 std::unique_ptr<base::Value> AsValue() const;
51
52 // The compositor treats this as an opaque handle and should not know how to
53 // interpret these bits. Non-blink cc clients typically operate in terms of
54 // layers and may set this value to match the client's layer id.
55 int primaryId;
56 int secondaryId;
57 };
58
59 CC_EXPORT ElementId LayerIdToElementIdForTesting(int layer_id);
60
61 struct CC_EXPORT ElementIdHash {
62 size_t operator()(ElementId key) const;
63 };
64
65 // Stream operator so ElementId can be used in assertion statements.
66 CC_EXPORT std::ostream& operator<<(std::ostream& out, const ElementId& id);
67
68 } // namespace cc
69
70 #endif // CC_ANIMATION_ELEMENT_ID_H_
OLDNEW
« no previous file with comments | « cc/animation/element_animations.h ('k') | cc/animation/element_id.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698