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

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: none 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 // 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
suzyh_UTC10 (ex-contributor) 2017/05/08 01:04:15 Add a blank line and comment before this entry to
chrishtr 2017/05/08 16:32:13 Done.
21 }; 24 };
22 25
23 using CompositorElementId = cc::ElementId; 26 using CompositorElementId = cc::ElementId;
27 using DOMNodeId = uint64_t;
24 28
25 CompositorElementId PLATFORM_EXPORT 29 CompositorElementId PLATFORM_EXPORT
26 CreateCompositorElementId(int dom_node_id, CompositorSubElementId); 30 CreateCompositorElementId(DOMNodeId, CompositorSubElementId);
27 31
28 // Note cc::ElementId has a hash function already implemented via 32 DOMNodeId 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::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 37
57 } // namespace blink 38 } // namespace blink
58 39
59 #endif // CompositorElementId_h 40 #endif // CompositorElementId_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698