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 < std::numeric_limits<DOMNodeId>::max() / |
| 14 static_cast<unsigned>( |
| 15 CompositorSubElementId::kNumSubElementTypes)); |
| 16 cc::ElementIdType id = |
| 17 dom_node_id << 2; // Shift to make room for sub_element_id enum bits. |
| 18 id += static_cast<uint64_t>(sub_element_id); |
| 19 return CompositorElementId(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>( |
| 29 element_id.id_ % |
| 30 static_cast<unsigned>(CompositorSubElementId::kNumSubElementTypes)); |
13 } | 31 } |
14 | 32 |
15 } // namespace blink | 33 } // namespace blink |
OLD | NEW |