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

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

Issue 2877033002: Fix cc scrollbar layer issues with initialization, and use element ids throughout. (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 const int kCompositorNamespaceBitCount = 3;
17
18 enum class CompositorElementIdNamespace {
17 kPrimary, 19 kPrimary,
18 kScroll, 20 kScroll,
19 kViewport, 21 kViewport,
20 kLinkHighlight, 22 kLinkHighlight,
21 // A sentinel to indicate how many enum values there are. 23 kScrollbar,
22 kNumSubElementTypes 24 // A sentinel to indicate the maximum representable namespace id
25 // (the maximum is one less than this value).
26 kMaxRepresentableNamespaceId = 1 << kCompositorNamespaceBitCount
23 }; 27 };
24 28
25 using CompositorElementId = cc::ElementId; 29 using CompositorElementId = cc::ElementId;
26 using DOMNodeId = uint64_t; 30 using DOMNodeId = uint64_t;
31 using ScrollbarId = uint64_t;
27 32
28 CompositorElementId PLATFORM_EXPORT 33 CompositorElementId PLATFORM_EXPORT
29 CreateCompositorElementId(DOMNodeId, CompositorSubElementId); 34 CompositorElementIdFromDOMNodeId(DOMNodeId, CompositorElementIdNamespace);
35
36 CompositorElementId PLATFORM_EXPORT
37 CompositorElementIdFromScrollbarId(ScrollbarId,
38 CompositorElementIdNamespace);
30 39
31 // Note cc::ElementId has a hash function already implemented via 40 // Note cc::ElementId has a hash function already implemented via
32 // ElementIdHash::operator(). However for consistency's sake we choose to use 41 // ElementIdHash::operator(). However for consistency's sake we choose to use
33 // Blink's hash functions with Blink specific data structures. 42 // Blink's hash functions with Blink specific data structures.
34 struct CompositorElementIdHash { 43 struct CompositorElementIdHash {
35 static unsigned GetHash(const CompositorElementId& key) { 44 static unsigned GetHash(const CompositorElementId& key) {
36 return WTF::HashInt(static_cast<cc::ElementIdType>(key.id_)); 45 return WTF::HashInt(static_cast<cc::ElementIdType>(key.id_));
37 } 46 }
38 static bool Equal(const CompositorElementId& a, 47 static bool Equal(const CompositorElementId& a,
39 const CompositorElementId& b) { 48 const CompositorElementId& b) {
40 return a.id_ == b.id_; 49 return a.id_ == b.id_;
41 } 50 }
42 static const bool safe_to_compare_to_empty_or_deleted = true; 51 static const bool safe_to_compare_to_empty_or_deleted = true;
43 }; 52 };
44 53
45 DOMNodeId PLATFORM_EXPORT DomNodeIdFromCompositorElementId(CompositorElementId); 54 uint64_t PLATFORM_EXPORT IdFromCompositorElementId(CompositorElementId);
46 CompositorSubElementId PLATFORM_EXPORT 55 CompositorElementIdNamespace PLATFORM_EXPORT
47 SubElementIdFromCompositorElementId(CompositorElementId); 56 NamespaceFromCompositorElementId(CompositorElementId);
48 57
49 struct CompositorElementIdHashTraits 58 struct CompositorElementIdHashTraits
50 : WTF::GenericHashTraits<CompositorElementId> { 59 : WTF::GenericHashTraits<CompositorElementId> {
51 static CompositorElementId EmptyValue() { return CompositorElementId(1); } 60 static CompositorElementId EmptyValue() { return CompositorElementId(1); }
52 static void ConstructDeletedValue(CompositorElementId& slot, bool) { 61 static void ConstructDeletedValue(CompositorElementId& slot, bool) {
53 slot = CompositorElementId(); 62 slot = CompositorElementId();
54 } 63 }
55 static bool IsDeletedValue(CompositorElementId value) { 64 static bool IsDeletedValue(CompositorElementId value) {
56 return value == CompositorElementId(); 65 return value == CompositorElementId();
57 } 66 }
58 }; 67 };
59 68
60 using CompositorElementIdSet = HashSet<CompositorElementId, 69 using CompositorElementIdSet = HashSet<CompositorElementId,
61 CompositorElementIdHash, 70 CompositorElementIdHash,
62 CompositorElementIdHashTraits>; 71 CompositorElementIdHashTraits>;
63 72
64 } // namespace blink 73 } // namespace blink
65 74
66 #endif // CompositorElementId_h 75 #endif // CompositorElementId_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698