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

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

Issue 1973083002: Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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
« no previous file with comments | « cc/animation/element_id.h ('k') | cc/animation/scroll_offset_animations.h » ('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 #include "cc/animation/element_id.h"
6
7 #include <limits>
8 #include <ostream>
9
10 #include "base/trace_event/trace_event_argument.h"
11 #include "base/values.h"
12 #include "cc/proto/element_id.pb.h"
13
14 namespace cc {
15
16 bool ElementId::operator==(const ElementId& o) const {
17 return primaryId == o.primaryId && secondaryId == o.secondaryId;
18 }
19
20 bool ElementId::operator!=(const ElementId& o) const {
21 return !(*this == o);
22 }
23
24 bool ElementId::operator<(const ElementId& o) const {
25 return std::tie(primaryId, secondaryId) <
26 std::tie(o.primaryId, o.secondaryId);
27 }
28
29 ElementId::operator bool() const {
30 return !!primaryId;
31 }
32
33 ElementId LayerIdToElementIdForTesting(int layer_id) {
34 return ElementId(std::numeric_limits<int>::max() - layer_id, 0);
35 }
36
37 void ElementId::AddToTracedValue(base::trace_event::TracedValue* res) const {
38 res->SetInteger("primaryId", primaryId);
39 res->SetInteger("secondaryId", secondaryId);
40 }
41
42 std::unique_ptr<base::Value> ElementId::AsValue() const {
43 std::unique_ptr<base::DictionaryValue> res(new base::DictionaryValue());
44 res->SetInteger("primaryId", primaryId);
45 res->SetInteger("secondaryId", secondaryId);
46 return std::move(res);
47 }
48
49 void ElementId::ToProtobuf(proto::ElementId* proto) const {
50 proto->set_primary_id(primaryId);
51 proto->set_secondary_id(secondaryId);
52 }
53
54 void ElementId::FromProtobuf(const proto::ElementId& proto) {
55 primaryId = proto.primary_id();
56 secondaryId = proto.secondary_id();
57 }
58
59 size_t ElementIdHash::operator()(ElementId key) const {
60 return base::HashInts(key.primaryId, key.secondaryId);
61 }
62
63 std::ostream& operator<<(std::ostream& out, const ElementId& id) {
64 return out << "(" << id.primaryId << ", " << id.secondaryId << ")";
65 }
66
67 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/element_id.h ('k') | cc/animation/scroll_offset_animations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698