Chromium Code Reviews| 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 "platform/graphics/CompositorElementId.h" | 5 #include "platform/graphics/CompositorElementId.h" |
| 6 | 6 |
| 7 namespace blink { | 7 namespace blink { |
| 8 | 8 |
| 9 CompositorElementId CreateCompositorElementId( | 9 CompositorElementId CreateCompositorElementId( |
| 10 int dom_node_id, | 10 uint64_t dom_node_id, |
| 11 CompositorSubElementId sub_element_id) { | 11 CompositorSubElementId sub_element_id) { |
| 12 return CompositorElementId(dom_node_id, static_cast<int>(sub_element_id)); | 12 DCHECK(dom_node_id > 0 && dom_node_id < std::numeric_limits<uint64_t>::max() / |
| 13 kNumSubElementTypes); | |
| 14 uint64_t element_id = dom_node_id; | |
| 15 element_id = | |
| 16 element_id << 2; // Shift to make room for sub_element_id enum bits. | |
| 17 element_id += static_cast<uint64_t>(sub_element_id); | |
| 18 return CompositorElementId(element_id); | |
| 19 } | |
| 20 | |
| 21 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.
| |
| 22 return id >> 2; | |
| 23 } | |
| 24 | |
| 25 CompositorSubElementId SubElementIdFromCompositorElementId( | |
| 26 CompositorElementId id) { | |
| 27 return static_cast<CompositorSubElementId>(id % kNumSubElementTypes); | |
| 13 } | 28 } |
| 14 | 29 |
| 15 } // namespace blink | 30 } // namespace blink |
| OLD | NEW |