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

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 // Do not add more of these without adjusting the bitfield arithmetic in
suzyh_UTC10 (ex-contributor) 2017/05/05 04:27:31 (If we don't remove this enum class) Can we enforc
17 // CreateCompositorElementId.
16 enum class CompositorSubElementId { 18 enum class CompositorSubElementId {
pdr. 2017/05/05 03:46:10 Do you know what this is really needed for? I thin
chrishtr 2017/05/05 05:34:52 Thought about this some. Perhaps the reason for th
ajuma 2017/05/05 13:46:42 Yeah, my recollection is that these were added bec
17 kPrimary, 19 kPrimary = 0,
18 kScroll, 20 kScroll = 1,
19 kViewport, 21 kViewport = 2,
20 kLinkHighlight 22 kLinkHighlight = 3
21 }; 23 };
22 24
23 using CompositorElementId = cc::ElementId; 25 using CompositorElementId = cc::ElementId;
26 static const int kInvalidElementId = 0;
suzyh_UTC10 (ex-contributor) 2017/05/05 04:27:31 Why is this redeclared instead of using the Elemen
chrishtr 2017/05/05 05:34:52 Fixed.
24 27
25 CompositorElementId PLATFORM_EXPORT 28 CompositorElementId PLATFORM_EXPORT
26 CreateCompositorElementId(int dom_node_id, CompositorSubElementId); 29 CreateCompositorElementId(int dom_node_id, CompositorSubElementId);
27 30
28 // Note cc::ElementId has a hash function already implemented via 31 int PLATFORM_EXPORT DomNodeIdFromCompositorElementId(CompositorElementId);
29 // ElementIdHash::operator(). However for consistency's sake we choose to use
30 // Blink's hash functions with Blink specific data structures.
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 32
42 struct CompositorElementIdHashTraits 33 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 34
57 } // namespace blink 35 } // namespace blink
58 36
59 #endif // CompositorElementId_h 37 #endif // CompositorElementId_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698