| 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 enum class CompositorSubElementId { | 16 // Do not add more of these without adjusting the bitfield arithmetic in |
| 17 kPrimary, | 17 // CreateCompositorElementId. |
| 18 kScroll, | 18 enum CompositorSubElementId { |
| 19 kViewport, | 19 kPrimary = 0, |
| 20 kLinkHighlight | 20 kScroll = 1, |
| 21 kViewport = 2, |
| 22 kLinkHighlight = 3, |
| 23 // A sentinel to indicate how many enum values there are: |
| 24 kNumSubElementTypes |
| 21 }; | 25 }; |
| 22 | 26 |
| 23 using CompositorElementId = cc::ElementId; | 27 using CompositorElementId = cc::ElementId; |
| 28 using DOMNodeId = uint64_t; |
| 24 | 29 |
| 25 CompositorElementId PLATFORM_EXPORT | 30 CompositorElementId PLATFORM_EXPORT |
| 26 CreateCompositorElementId(int dom_node_id, CompositorSubElementId); | 31 CreateCompositorElementId(DOMNodeId, CompositorSubElementId); |
| 27 | 32 |
| 28 // Note cc::ElementId has a hash function already implemented via | 33 DOMNodeId PLATFORM_EXPORT DomNodeIdFromCompositorElementId(CompositorElementId); |
| 29 // ElementIdHash::operator(). However for consistency's sake we choose to use | 34 CompositorSubElementId PLATFORM_EXPORT |
| 30 // Blink's hash functions with Blink specific data structures. | 35 SubElementIdFromCompositorElementId(CompositorElementId); |
| 31 struct CompositorElementIdHash { | |
| 32 static unsigned GetHash(const CompositorElementId& p) { | |
| 33 return WTF::HashInts(p.primaryId, p.secondaryId); | |
| 34 } | |
| 35 static bool Equal(const CompositorElementId& a, | |
| 36 const CompositorElementId& b) { | |
| 37 return a.primaryId == b.primaryId && a.secondaryId == b.secondaryId; | |
| 38 } | |
| 39 static const bool safe_to_compare_to_empty_or_deleted = true; | |
| 40 }; | |
| 41 | 36 |
| 42 struct CompositorElementIdHashTraits | 37 using CompositorElementIdSet = HashSet<CompositorElementId::Id>; |
| 43 : WTF::GenericHashTraits<CompositorElementId> { | |
| 44 static CompositorElementId EmptyValue() { return CompositorElementId(); } | |
| 45 static void ConstructDeletedValue(CompositorElementId& slot, bool) { | |
| 46 slot = CompositorElementId(-1, -1); | |
| 47 } | |
| 48 static bool IsDeletedValue(CompositorElementId value) { | |
| 49 return value == CompositorElementId(-1, -1); | |
| 50 } | |
| 51 }; | |
| 52 | |
| 53 using CompositorElementIdSet = HashSet<CompositorElementId, | |
| 54 CompositorElementIdHash, | |
| 55 CompositorElementIdHashTraits>; | |
| 56 | 38 |
| 57 } // namespace blink | 39 } // namespace blink |
| 58 | 40 |
| 59 #endif // CompositorElementId_h | 41 #endif // CompositorElementId_h |
| OLD | NEW |