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

Unified Diff: third_party/WebKit/Source/platform/graphics/CompositorElementId.cpp

Issue 2860293002: Change cc::ElementId to be a uint64_t (Closed)
Patch Set: none Created 3 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: third_party/WebKit/Source/platform/graphics/CompositorElementId.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/CompositorElementId.cpp b/third_party/WebKit/Source/platform/graphics/CompositorElementId.cpp
index eeb495fbacd4780e0671a07ae53022b945c3aa39..69f2588009ca93dbc9b93413cefa11580cdf8480 100644
--- a/third_party/WebKit/Source/platform/graphics/CompositorElementId.cpp
+++ b/third_party/WebKit/Source/platform/graphics/CompositorElementId.cpp
@@ -7,9 +7,24 @@
namespace blink {
CompositorElementId CreateCompositorElementId(
- int dom_node_id,
+ uint64_t dom_node_id,
CompositorSubElementId sub_element_id) {
- return CompositorElementId(dom_node_id, static_cast<int>(sub_element_id));
+ DCHECK(dom_node_id > 0 && dom_node_id < std::numeric_limits<uint64_t>::max() /
+ kNumSubElementTypes);
+ uint64_t element_id = dom_node_id;
+ element_id =
+ element_id << 2; // Shift to make room for sub_element_id enum bits.
+ element_id += static_cast<uint64_t>(sub_element_id);
+ return CompositorElementId(element_id);
+}
+
+uint64_t DomNodeIdFromCompositorElementId(CompositorElementId id) {
wkorman 2017/05/05 20:06:10 Naming style question -- feel like usually we see
chrishtr 2017/05/05 20:46:09 Not sure. Happy to change if you want.
+ return id >> 2;
+}
+
+CompositorSubElementId SubElementIdFromCompositorElementId(
+ CompositorElementId id) {
+ return static_cast<CompositorSubElementId>(id % kNumSubElementTypes);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698