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 DOMNodeId 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 && |
| 13 dom_node_id < |
| 14 std::numeric_limits<DOMNodeId>::max() / kNumSubElementTypes); |
| 15 CompositorElementId element_id; |
| 16 element_id.id = dom_node_id |
| 17 << 2; // Shift to make room for sub_element_id enum bits. |
| 18 element_id.id += static_cast<uint64_t>(sub_element_id); |
| 19 return element_id; |
| 20 } |
| 21 |
| 22 DOMNodeId DomNodeIdFromCompositorElementId(CompositorElementId element_id) { |
| 23 return element_id.id >> 2; |
| 24 } |
| 25 |
| 26 CompositorSubElementId SubElementIdFromCompositorElementId( |
| 27 CompositorElementId element_id) { |
| 28 return static_cast<CompositorSubElementId>(element_id.id % |
| 29 kNumSubElementTypes); |
13 } | 30 } |
14 | 31 |
15 } // namespace blink | 32 } // namespace blink |
OLD | NEW |