| 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 #ifndef CompositorElementId_h | 5 #ifndef CompositorElementId_h |
| 6 #define CompositorElementId_h | 6 #define CompositorElementId_h |
| 7 | 7 |
| 8 #include "cc/trees/element_id.h" | 8 #include "cc/trees/element_id.h" |
| 9 #include "platform/PlatformExport.h" | 9 #include "platform/PlatformExport.h" |
| 10 #include "platform/wtf/HashFunctions.h" | 10 #include "platform/wtf/HashFunctions.h" |
| 11 #include "platform/wtf/HashSet.h" | 11 #include "platform/wtf/HashSet.h" |
| 12 #include "platform/wtf/HashTraits.h" | 12 #include "platform/wtf/HashTraits.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 const int kCompositorNamespaceBitCount = 3; | 16 const int kCompositorNamespaceBitCount = 3; |
| 17 | 17 |
| 18 enum class CompositorElementIdNamespace { | 18 enum class CompositorElementIdNamespace { |
| 19 kPrimary, | 19 kPrimary, |
| 20 kRootScroll, |
| 20 kScroll, | 21 kScroll, |
| 22 kScrollbar, |
| 23 kScrollState, |
| 21 kViewport, | 24 kViewport, |
| 22 kLinkHighlight, | 25 kLinkHighlight, |
| 23 kScrollbar, | 26 kPrimaryCompositorProxy, |
| 27 kScrollCompositorProxy, |
| 24 // A sentinel to indicate the maximum representable namespace id | 28 // A sentinel to indicate the maximum representable namespace id |
| 25 // (the maximum is one less than this value). | 29 // (the maximum is one less than this value). |
| 26 kMaxRepresentableNamespaceId = 1 << kCompositorNamespaceBitCount | 30 kMaxRepresentableNamespaceId = 1 << kCompositorNamespaceBitCount |
| 27 }; | 31 }; |
| 28 | 32 |
| 29 using CompositorElementId = cc::ElementId; | 33 using CompositorElementId = cc::ElementId; |
| 34 using PaintLayerId = uint64_t; |
| 35 using ScrollbarId = uint64_t; |
| 30 using DOMNodeId = uint64_t; | 36 using DOMNodeId = uint64_t; |
| 31 using ScrollbarId = uint64_t; | |
| 32 | 37 |
| 33 CompositorElementId PLATFORM_EXPORT | 38 CompositorElementId PLATFORM_EXPORT |
| 39 CompositorElementIdFromPaintLayerId(PaintLayerId, |
| 40 CompositorElementIdNamespace); |
| 41 |
| 42 // This method should only be used for "special" layers that are not allocated |
| 43 // during the normal lifecycle. Examples include VisualViewport, |
| 44 // root scrolling (when rootLayerScrollingEnabled is off), and LinkHighlight, |
| 45 // or when CompositorProxies are involved. |
| 46 |
| 47 // Otherwise, CompositorElementIdFromPaintLayerId is preferred for performance |
| 48 // reasons (since computing a DOMNodeId requires a hash map lookup), |
| 49 // and future compatibility with multicol/pagination. |
| 50 CompositorElementId PLATFORM_EXPORT |
| 34 CompositorElementIdFromDOMNodeId(DOMNodeId, CompositorElementIdNamespace); | 51 CompositorElementIdFromDOMNodeId(DOMNodeId, CompositorElementIdNamespace); |
| 35 | 52 |
| 36 CompositorElementId PLATFORM_EXPORT | 53 CompositorElementId PLATFORM_EXPORT |
| 37 CompositorElementIdFromScrollbarId(ScrollbarId, | 54 CompositorElementIdFromScrollbarId(ScrollbarId, |
| 38 CompositorElementIdNamespace); | 55 CompositorElementIdNamespace); |
| 39 | 56 |
| 40 // Note cc::ElementId has a hash function already implemented via | 57 // Note cc::ElementId has a hash function already implemented via |
| 41 // ElementIdHash::operator(). However for consistency's sake we choose to use | 58 // ElementIdHash::operator(). However for consistency's sake we choose to use |
| 42 // Blink's hash functions with Blink specific data structures. | 59 // Blink's hash functions with Blink specific data structures. |
| 43 struct CompositorElementIdHash { | 60 struct CompositorElementIdHash { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 65 } | 82 } |
| 66 }; | 83 }; |
| 67 | 84 |
| 68 using CompositorElementIdSet = HashSet<CompositorElementId, | 85 using CompositorElementIdSet = HashSet<CompositorElementId, |
| 69 CompositorElementIdHash, | 86 CompositorElementIdHash, |
| 70 CompositorElementIdHashTraits>; | 87 CompositorElementIdHashTraits>; |
| 71 | 88 |
| 72 } // namespace blink | 89 } // namespace blink |
| 73 | 90 |
| 74 #endif // CompositorElementId_h | 91 #endif // CompositorElementId_h |
| OLD | NEW |