Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1358)

Unified Diff: cc/animation/element_id.cc

Issue 1973083002: Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/animation/element_id.h ('k') | cc/animation/scroll_offset_animations.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/element_id.cc
diff --git a/cc/animation/element_id.cc b/cc/animation/element_id.cc
new file mode 100644
index 0000000000000000000000000000000000000000..242cd32e621e37a9fb844d567dbc0f0a1c026410
--- /dev/null
+++ b/cc/animation/element_id.cc
@@ -0,0 +1,67 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/animation/element_id.h"
+
+#include <limits>
+#include <ostream>
+
+#include "base/trace_event/trace_event_argument.h"
+#include "base/values.h"
+#include "cc/proto/element_id.pb.h"
+
+namespace cc {
+
+bool ElementId::operator==(const ElementId& o) const {
+ return primaryId == o.primaryId && secondaryId == o.secondaryId;
+}
+
+bool ElementId::operator!=(const ElementId& o) const {
+ return !(*this == o);
+}
+
+bool ElementId::operator<(const ElementId& o) const {
+ return std::tie(primaryId, secondaryId) <
+ std::tie(o.primaryId, o.secondaryId);
+}
+
+ElementId::operator bool() const {
+ return !!primaryId;
+}
+
+ElementId LayerIdToElementIdForTesting(int layer_id) {
+ return ElementId(std::numeric_limits<int>::max() - layer_id, 0);
+}
+
+void ElementId::AddToTracedValue(base::trace_event::TracedValue* res) const {
+ res->SetInteger("primaryId", primaryId);
+ res->SetInteger("secondaryId", secondaryId);
+}
+
+std::unique_ptr<base::Value> ElementId::AsValue() const {
+ std::unique_ptr<base::DictionaryValue> res(new base::DictionaryValue());
+ res->SetInteger("primaryId", primaryId);
+ res->SetInteger("secondaryId", secondaryId);
+ return std::move(res);
+}
+
+void ElementId::ToProtobuf(proto::ElementId* proto) const {
+ proto->set_primary_id(primaryId);
+ proto->set_secondary_id(secondaryId);
+}
+
+void ElementId::FromProtobuf(const proto::ElementId& proto) {
+ primaryId = proto.primary_id();
+ secondaryId = proto.secondary_id();
+}
+
+size_t ElementIdHash::operator()(ElementId key) const {
+ return base::HashInts(key.primaryId, key.secondaryId);
+}
+
+std::ostream& operator<<(std::ostream& out, const ElementId& id) {
+ return out << "(" << id.primaryId << ", " << id.secondaryId << ")";
+}
+
+} // namespace cc
« no previous file with comments | « cc/animation/element_id.h ('k') | cc/animation/scroll_offset_animations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698