| 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 | |
| 7 #include <limits> | 6 #include <limits> |
| 8 #include <ostream> | 7 #include <ostream> |
| 9 | |
| 10 #include "base/trace_event/trace_event_argument.h" | 8 #include "base/trace_event/trace_event_argument.h" |
| 11 #include "base/values.h" | 9 #include "base/values.h" |
| 12 | 10 |
| 13 namespace cc { | 11 namespace cc { |
| 14 | 12 |
| 15 bool ElementId::operator==(const ElementId& o) const { | 13 bool ElementId::operator==(const ElementId& o) const { |
| 16 return primaryId == o.primaryId && secondaryId == o.secondaryId; | 14 return id == o.id; |
| 17 } | 15 } |
| 18 | 16 |
| 19 bool ElementId::operator!=(const ElementId& o) const { | 17 bool ElementId::operator!=(const ElementId& o) const { |
| 20 return !(*this == o); | 18 return !(*this == o); |
| 21 } | 19 } |
| 22 | 20 |
| 23 bool ElementId::operator<(const ElementId& o) const { | 21 bool ElementId::operator<(const ElementId& o) const { |
| 24 return std::tie(primaryId, secondaryId) < | 22 return id < o.id; |
| 25 std::tie(o.primaryId, o.secondaryId); | |
| 26 } | 23 } |
| 27 | 24 |
| 28 ElementId::operator bool() const { | 25 ElementId::operator bool() const { |
| 29 return !!primaryId; | 26 return !!id; |
| 30 } | 27 } |
| 31 | 28 |
| 32 ElementId LayerIdToElementIdForTesting(int layer_id) { | 29 std::ostream& operator<<(std::ostream& out, const ElementId& element_id) { |
| 33 return ElementId(std::numeric_limits<int>::max() - layer_id, 0); | 30 return out << "(" << element_id.id << ")"; |
| 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 } | 31 } |
| 55 | 32 |
| 56 } // namespace cc | 33 } // namespace cc |
| OLD | NEW |