| 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 kNumSubElementTypes = 4 |
| 21 }; | 24 }; |
| 22 | 25 |
| 23 using CompositorElementId = cc::ElementId; | 26 using CompositorElementId = cc::ElementId; |
| 27 static const CompositorElementId kInvalidElementId = 0; |
| 24 | 28 |
| 25 CompositorElementId PLATFORM_EXPORT | 29 CompositorElementId PLATFORM_EXPORT |
| 26 CreateCompositorElementId(int dom_node_id, CompositorSubElementId); | 30 CreateCompositorElementId(uint64_t dom_node_id, CompositorSubElementId); |
| 27 | 31 |
| 28 // Note cc::ElementId has a hash function already implemented via | 32 uint64_t PLATFORM_EXPORT DomNodeIdFromCompositorElementId(CompositorElementId); |
| 29 // ElementIdHash::operator(). However for consistency's sake we choose to use | 33 CompositorSubElementId PLATFORM_EXPORT |
| 30 // Blink's hash functions with Blink specific data structures. | 34 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 | 35 |
| 42 struct CompositorElementIdHashTraits | 36 using CompositorElementIdSet = HashSet<CompositorElementId>; |
| 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 | 37 |
| 57 } // namespace blink | 38 } // namespace blink |
| 58 | 39 |
| 59 #endif // CompositorElementId_h | 40 #endif // CompositorElementId_h |
| OLD | NEW |