Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/CompositorElementId.h

Issue 2860293002: Change cc::ElementId to be a uint64_t (Closed)
Patch Set: Merge branch 'master' into secondaryid Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 enum class CompositorSubElementId {
17 kPrimary, 17 kPrimary,
18 kScroll, 18 kScroll,
19 kViewport, 19 kViewport,
20 kLinkHighlight 20 kLinkHighlight,
21 // A sentinel to indicate how many enum values there are.
22 kNumSubElementTypes
21 }; 23 };
22 24
23 using CompositorElementId = cc::ElementId; 25 using CompositorElementId = cc::ElementId;
26 using DOMNodeId = uint64_t;
24 27
25 CompositorElementId PLATFORM_EXPORT 28 CompositorElementId PLATFORM_EXPORT
26 CreateCompositorElementId(int dom_node_id, CompositorSubElementId); 29 CreateCompositorElementId(DOMNodeId, CompositorSubElementId);
27 30
28 // Note cc::ElementId has a hash function already implemented via 31 // Note cc::ElementId has a hash function already implemented via
29 // ElementIdHash::operator(). However for consistency's sake we choose to use 32 // ElementIdHash::operator(). However for consistency's sake we choose to use
30 // Blink's hash functions with Blink specific data structures. 33 // Blink's hash functions with Blink specific data structures.
31 struct CompositorElementIdHash { 34 struct CompositorElementIdHash {
32 static unsigned GetHash(const CompositorElementId& p) { 35 static unsigned GetHash(const CompositorElementId& key) {
33 return WTF::HashInts(p.primaryId, p.secondaryId); 36 return WTF::HashInt(static_cast<cc::ElementIdType>(key.id_));
34 } 37 }
35 static bool Equal(const CompositorElementId& a, 38 static bool Equal(const CompositorElementId& a,
36 const CompositorElementId& b) { 39 const CompositorElementId& b) {
37 return a.primaryId == b.primaryId && a.secondaryId == b.secondaryId; 40 return a.id_ == b.id_;
38 } 41 }
39 static const bool safe_to_compare_to_empty_or_deleted = true; 42 static const bool safe_to_compare_to_empty_or_deleted = true;
40 }; 43 };
41 44
45 DOMNodeId PLATFORM_EXPORT DomNodeIdFromCompositorElementId(CompositorElementId);
46 CompositorSubElementId PLATFORM_EXPORT
47 SubElementIdFromCompositorElementId(CompositorElementId);
48
42 struct CompositorElementIdHashTraits 49 struct CompositorElementIdHashTraits
43 : WTF::GenericHashTraits<CompositorElementId> { 50 : WTF::GenericHashTraits<CompositorElementId> {
44 static CompositorElementId EmptyValue() { return CompositorElementId(); } 51 static CompositorElementId EmptyValue() { return CompositorElementId(1); }
45 static void ConstructDeletedValue(CompositorElementId& slot, bool) { 52 static void ConstructDeletedValue(CompositorElementId& slot, bool) {
46 slot = CompositorElementId(-1, -1); 53 slot = CompositorElementId();
47 } 54 }
48 static bool IsDeletedValue(CompositorElementId value) { 55 static bool IsDeletedValue(CompositorElementId value) {
49 return value == CompositorElementId(-1, -1); 56 return value == CompositorElementId();
50 } 57 }
51 }; 58 };
52 59
53 using CompositorElementIdSet = HashSet<CompositorElementId, 60 using CompositorElementIdSet = HashSet<CompositorElementId,
54 CompositorElementIdHash, 61 CompositorElementIdHash,
55 CompositorElementIdHashTraits>; 62 CompositorElementIdHashTraits>;
56 63
57 } // namespace blink 64 } // namespace blink
58 65
59 #endif // CompositorElementId_h 66 #endif // CompositorElementId_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/BUILD.gn ('k') | third_party/WebKit/Source/platform/graphics/CompositorElementId.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698