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

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: . 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 "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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698