| 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 static CompositorElementId CreateCompositorElementId( |
| 10 DOMNodeId dom_node_id, | 10 uint64_t blink_id, |
| 11 CompositorSubElementId sub_element_id) { | 11 CompositorElementIdNamespace namespace_id) { |
| 12 DCHECK(dom_node_id > 0 && | 12 DCHECK( |
| 13 dom_node_id < std::numeric_limits<DOMNodeId>::max() / | 13 blink_id > 0 && |
| 14 static_cast<unsigned>( | 14 blink_id < |
| 15 CompositorSubElementId::kNumSubElementTypes)); | 15 std::numeric_limits<uint64_t>::max() / |
| 16 cc::ElementIdType id = | 16 static_cast<unsigned>( |
| 17 dom_node_id << 2; // Shift to make room for sub_element_id enum bits. | 17 CompositorElementIdNamespace::kMaxRepresentableNamespaceId)); |
| 18 id += static_cast<uint64_t>(sub_element_id); | 18 // Shift to make room for namespace_id enum bits. |
| 19 cc::ElementIdType id = blink_id << kCompositorNamespaceBitCount; |
| 20 id += static_cast<uint64_t>(namespace_id); |
| 19 return CompositorElementId(id); | 21 return CompositorElementId(id); |
| 20 } | 22 } |
| 21 | 23 |
| 22 DOMNodeId DomNodeIdFromCompositorElementId(CompositorElementId element_id) { | 24 CompositorElementId PLATFORM_EXPORT |
| 23 return element_id.id_ >> 2; | 25 CompositorElementIdFromDOMNodeId(DOMNodeId id, |
| 26 CompositorElementIdNamespace namespace_id) { |
| 27 return CreateCompositorElementId(id, namespace_id); |
| 24 } | 28 } |
| 25 | 29 |
| 26 CompositorSubElementId SubElementIdFromCompositorElementId( | 30 CompositorElementId PLATFORM_EXPORT |
| 31 CompositorElementIdFromScrollbarId(ScrollbarId id, |
| 32 CompositorElementIdNamespace namespace_id) { |
| 33 return CreateCompositorElementId(id, namespace_id); |
| 34 } |
| 35 |
| 36 uint64_t IdFromCompositorElementId(CompositorElementId element_id) { |
| 37 return element_id.id_ >> kCompositorNamespaceBitCount; |
| 38 } |
| 39 |
| 40 CompositorElementIdNamespace NamespaceFromCompositorElementId( |
| 27 CompositorElementId element_id) { | 41 CompositorElementId element_id) { |
| 28 return static_cast<CompositorSubElementId>( | 42 return static_cast<CompositorElementIdNamespace>( |
| 29 element_id.id_ % | 43 element_id.id_ % |
| 30 static_cast<unsigned>(CompositorSubElementId::kNumSubElementTypes)); | 44 static_cast<uint64_t>( |
| 45 CompositorElementIdNamespace::kMaxRepresentableNamespaceId)); |
| 31 } | 46 } |
| 32 | 47 |
| 33 } // namespace blink | 48 } // namespace blink |
| OLD | NEW |