OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/element_id.h" | 5 #include "cc/trees/element_id.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <ostream> | 8 #include <ostream> |
9 | 9 |
10 #include "base/trace_event/trace_event_argument.h" | 10 #include "base/trace_event/trace_event_argument.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 | 14 |
15 bool ElementId::operator==(const ElementId& o) const { | 15 bool ElementId::operator==(const ElementId& o) const { |
16 return primaryId == o.primaryId && secondaryId == o.secondaryId; | 16 return id_ == o.id_; |
17 } | 17 } |
18 | 18 |
19 bool ElementId::operator!=(const ElementId& o) const { | 19 bool ElementId::operator!=(const ElementId& o) const { |
20 return !(*this == o); | 20 return !(*this == o); |
21 } | 21 } |
22 | 22 |
23 bool ElementId::operator<(const ElementId& o) const { | 23 bool ElementId::operator<(const ElementId& o) const { |
24 return std::tie(primaryId, secondaryId) < | 24 return id_ < o.id_; |
25 std::tie(o.primaryId, o.secondaryId); | |
26 } | 25 } |
27 | 26 |
28 ElementId::operator bool() const { | 27 ElementId::operator bool() const { |
29 return !!primaryId; | 28 return !!id_; |
30 } | 29 } |
31 | 30 |
32 ElementId LayerIdToElementIdForTesting(int layer_id) { | 31 ElementId LayerIdToElementIdForTesting(int layer_id) { |
33 return ElementId(std::numeric_limits<int>::max() - layer_id, 0); | 32 return ElementId(std::numeric_limits<int>::max() - layer_id); |
34 } | 33 } |
35 | 34 |
36 void ElementId::AddToTracedValue(base::trace_event::TracedValue* res) const { | 35 void ElementId::AddToTracedValue(base::trace_event::TracedValue* res) const { |
37 res->SetInteger("primaryId", primaryId); | 36 res->SetInteger("id_", id_); |
38 res->SetInteger("secondaryId", secondaryId); | |
39 } | 37 } |
40 | 38 |
41 std::unique_ptr<base::Value> ElementId::AsValue() const { | 39 std::unique_ptr<base::Value> ElementId::AsValue() const { |
42 std::unique_ptr<base::DictionaryValue> res(new base::DictionaryValue()); | 40 std::unique_ptr<base::DictionaryValue> res(new base::DictionaryValue()); |
43 res->SetInteger("primaryId", primaryId); | 41 res->SetInteger("id_", id_); |
44 res->SetInteger("secondaryId", secondaryId); | |
45 return std::move(res); | 42 return std::move(res); |
46 } | 43 } |
47 | 44 |
48 size_t ElementIdHash::operator()(ElementId key) const { | 45 size_t ElementIdHash::operator()(ElementId key) const { |
49 return base::HashInts(key.primaryId, key.secondaryId); | 46 return std::hash<int>()(key.id_); |
50 } | 47 } |
51 | 48 |
52 std::ostream& operator<<(std::ostream& out, const ElementId& id) { | 49 std::ostream& operator<<(std::ostream& out, const ElementId& id) { |
53 return out << "(" << id.primaryId << ", " << id.secondaryId << ")"; | 50 return out << "(" << id.id_ << ")"; |
54 } | 51 } |
55 | 52 |
56 } // namespace cc | 53 } // namespace cc |
OLD | NEW |