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

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: . 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 #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 CC_EXPORT operator==(uint64_t o, const ElementId& e) {
jbroman 2016/06/02 20:20:21 What's going on here? CC_EXPORT is only meaningful
Ian Vollick 2016/06/03 19:31:21 This copy and paste error was supposed to have bee
17 return o == e.value;
18 }
19
20 bool CC_EXPORT operator!=(uint64_t o, const ElementId& e) {
21 return o != e.value;
22 }
23
24 ElementId CC_EXPORT LayerIdToElementIdForTesting(int layer_id) {
25 return ElementId(std::numeric_limits<uint64_t>::max() - layer_id);
26 }
27
28 void ElementId::AddToTracedValue(base::trace_event::TracedValue* res) const {
29 res->SetInteger("element_id", base::saturated_cast<int>(value));
jbroman 2016/06/02 20:20:21 saturated_cast is wrong here: anything with a non-
Ian Vollick 2016/06/03 19:31:21 Thank you for catching this. Since this approach i
30 res->SetInteger("sub_element_id", base::saturated_cast<int>(value >> 32));
31 }
32
33 std::unique_ptr<base::Value> ElementId::AsValue() const {
34 std::unique_ptr<base::DictionaryValue> res(new base::DictionaryValue());
35 res->SetInteger("element_id", base::saturated_cast<int>(value));
36 res->SetInteger("sub_element_id", base::saturated_cast<int>(value >> 32));
37 return std::move(res);
38 }
39
40 void ElementId::ToProtobuf(proto::ElementId* proto) const {
41 proto->set_id(value);
42 }
43
44 void ElementId::FromProtobuf(const proto::ElementId& proto) {
45 value = proto.id();
46 }
47
48 std::ostream& operator<<(std::ostream& out, const ElementId& id) {
49 return out << id.value;
50 }
51
52 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698