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/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) { |
| 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)); |
| 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 |
OLD | NEW |