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

Unified Diff: cc/animation/element_id.h

Issue 1973083002: Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get element id's from scroll node data directly. Created 4 years, 7 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
Index: cc/animation/element_id.h
diff --git a/cc/animation/element_id.h b/cc/animation/element_id.h
new file mode 100644
index 0000000000000000000000000000000000000000..069e3bc1fe396aaaf8fe12f5e3e58656a9482dcf
--- /dev/null
+++ b/cc/animation/element_id.h
@@ -0,0 +1,64 @@
+// 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.
+
+#ifndef CC_ANIMATION_ELEMENT_ID_H_
+#define CC_ANIMATION_ELEMENT_ID_H_
+
+#include <cstdint>
+#include <functional>
+#include <iosfwd>
+#include <memory>
+#include <stddef.h>
+
+#include "cc/base/cc_export.h"
+
+namespace base {
+class Value;
+namespace trace_event {
+class TracedValue;
+} // namespace trace_event
+} // namespace base
+
+namespace cc {
+
+namespace proto {
+class ElementId;
+} // namespace proto
+
+// ------------------------------*IMPORTANT*---------------------------------
+// ElementId has a corresponding proto defined in cc/proto/element_id.proto.
+// When making any changes here, but sure to update the proto.
+
+struct CC_EXPORT ElementId {
Ian Vollick 2016/06/01 18:08:26 Why a struct? 1. Catch bugs. I started with a typ
+ explicit ElementId(uint64_t value) : value(value) {}
+ ElementId() : value(0ul) {}
+
+ inline bool operator==(const ElementId& o) const { return o.value == value; }
+ inline bool operator!=(const ElementId& o) const { return o.value != value; }
+ inline bool operator<(const ElementId& o) const { return value < o.value; }
+ inline explicit operator bool() const { return !!value; }
+
+ void AddToTracedValue(base::trace_event::TracedValue* res) const;
+ std::unique_ptr<base::Value> AsValue() const;
+
+ void ToProtobuf(proto::ElementId* proto) const;
+ void FromProtobuf(const proto::ElementId& proto);
+
+ uint64_t value;
Ian Vollick 2016/06/01 18:08:25 I went with a uint64_t here because I wanted cc to
ajuma 2016/06/01 23:53:42 (1) has the nice feature that you avoid bitwise OR
Ian Vollick 2016/06/02 19:03:11 I've tried out the helper function in the latest p
+};
+
+ElementId CC_EXPORT LayerIdToElementIdForTesting(int layer_id);
+
+struct ElementIdHash {
+ size_t operator()(ElementId key) const {
+ return std::hash<uint64_t>()(key.value);
+ }
+};
+
+// Stream operator so ElementId can be used in assertion statements.
+CC_EXPORT std::ostream& operator<<(std::ostream& out, const ElementId& id);
+
+} // namespace cc
+
+#endif // CC_ANIMATION_ELEMENT_ID_H_

Powered by Google App Engine
This is Rietveld 408576698