| 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/animation/element_id.h" | 5 #include "cc/animation/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 #include "cc/proto/element_id.pb.h" | |
| 13 | 12 |
| 14 namespace cc { | 13 namespace cc { |
| 15 | 14 |
| 16 bool ElementId::operator==(const ElementId& o) const { | 15 bool ElementId::operator==(const ElementId& o) const { |
| 17 return primaryId == o.primaryId && secondaryId == o.secondaryId; | 16 return primaryId == o.primaryId && secondaryId == o.secondaryId; |
| 18 } | 17 } |
| 19 | 18 |
| 20 bool ElementId::operator!=(const ElementId& o) const { | 19 bool ElementId::operator!=(const ElementId& o) const { |
| 21 return !(*this == o); | 20 return !(*this == o); |
| 22 } | 21 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 39 res->SetInteger("secondaryId", secondaryId); | 38 res->SetInteger("secondaryId", secondaryId); |
| 40 } | 39 } |
| 41 | 40 |
| 42 std::unique_ptr<base::Value> ElementId::AsValue() const { | 41 std::unique_ptr<base::Value> ElementId::AsValue() const { |
| 43 std::unique_ptr<base::DictionaryValue> res(new base::DictionaryValue()); | 42 std::unique_ptr<base::DictionaryValue> res(new base::DictionaryValue()); |
| 44 res->SetInteger("primaryId", primaryId); | 43 res->SetInteger("primaryId", primaryId); |
| 45 res->SetInteger("secondaryId", secondaryId); | 44 res->SetInteger("secondaryId", secondaryId); |
| 46 return std::move(res); | 45 return std::move(res); |
| 47 } | 46 } |
| 48 | 47 |
| 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 { | 48 size_t ElementIdHash::operator()(ElementId key) const { |
| 60 return base::HashInts(key.primaryId, key.secondaryId); | 49 return base::HashInts(key.primaryId, key.secondaryId); |
| 61 } | 50 } |
| 62 | 51 |
| 63 std::ostream& operator<<(std::ostream& out, const ElementId& id) { | 52 std::ostream& operator<<(std::ostream& out, const ElementId& id) { |
| 64 return out << "(" << id.primaryId << ", " << id.secondaryId << ")"; | 53 return out << "(" << id.primaryId << ", " << id.secondaryId << ")"; |
| 65 } | 54 } |
| 66 | 55 |
| 67 } // namespace cc | 56 } // namespace cc |
| OLD | NEW |