OLD | NEW |
| (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/trees/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 | |
13 namespace cc { | |
14 | |
15 bool ElementId::operator==(const ElementId& o) const { | |
16 return primaryId == o.primaryId && secondaryId == o.secondaryId; | |
17 } | |
18 | |
19 bool ElementId::operator!=(const ElementId& o) const { | |
20 return !(*this == o); | |
21 } | |
22 | |
23 bool ElementId::operator<(const ElementId& o) const { | |
24 return std::tie(primaryId, secondaryId) < | |
25 std::tie(o.primaryId, o.secondaryId); | |
26 } | |
27 | |
28 ElementId::operator bool() const { | |
29 return !!primaryId; | |
30 } | |
31 | |
32 ElementId LayerIdToElementIdForTesting(int layer_id) { | |
33 return ElementId(std::numeric_limits<int>::max() - layer_id, 0); | |
34 } | |
35 | |
36 void ElementId::AddToTracedValue(base::trace_event::TracedValue* res) const { | |
37 res->SetInteger("primaryId", primaryId); | |
38 res->SetInteger("secondaryId", secondaryId); | |
39 } | |
40 | |
41 std::unique_ptr<base::Value> ElementId::AsValue() const { | |
42 std::unique_ptr<base::DictionaryValue> res(new base::DictionaryValue()); | |
43 res->SetInteger("primaryId", primaryId); | |
44 res->SetInteger("secondaryId", secondaryId); | |
45 return std::move(res); | |
46 } | |
47 | |
48 size_t ElementIdHash::operator()(ElementId key) const { | |
49 return base::HashInts(key.primaryId, key.secondaryId); | |
50 } | |
51 | |
52 std::ostream& operator<<(std::ostream& out, const ElementId& id) { | |
53 return out << "(" << id.primaryId << ", " << id.secondaryId << ")"; | |
54 } | |
55 | |
56 } // namespace cc | |
OLD | NEW |