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

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

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 #include "platform/graphics/CompositorElementId.h" 5 #include "platform/graphics/CompositorElementId.h"
6 6
7 namespace blink { 7 namespace blink {
8 8
9 static const int numBitsToShift = 3;
wkorman 2017/05/12 22:29:39 See prev comment re: kNamespaceBits.
chrishtr 2017/05/12 23:44:16 Done.
10
9 CompositorElementId CreateCompositorElementId( 11 CompositorElementId CreateCompositorElementId(
10 DOMNodeId dom_node_id, 12 uint64_t dom_node_id,
11 CompositorSubElementId sub_element_id) { 13 CompositorElementIdNamespace namespace_id) {
12 DCHECK(dom_node_id > 0 && 14 DCHECK(
13 dom_node_id < std::numeric_limits<DOMNodeId>::max() / 15 dom_node_id > 0 &&
14 static_cast<unsigned>( 16 dom_node_id <
15 CompositorSubElementId::kNumSubElementTypes)); 17 std::numeric_limits<uint64_t>::max() /
16 cc::ElementIdType id = 18 static_cast<unsigned>(
17 dom_node_id << 2; // Shift to make room for sub_element_id enum bits. 19 CompositorElementIdNamespace::kMaxRepresentableNamespaceId));
18 id += static_cast<uint64_t>(sub_element_id); 20 // Shift to make room for namespace_id enum bits.
21 cc::ElementIdType id = dom_node_id << numBitsToShift;
22 id += static_cast<uint64_t>(namespace_id);
19 return CompositorElementId(id); 23 return CompositorElementId(id);
20 } 24 }
21 25
22 DOMNodeId DomNodeIdFromCompositorElementId(CompositorElementId element_id) { 26 uint64_t IdFromCompositorElementId(CompositorElementId element_id) {
23 return element_id.id_ >> 2; 27 return element_id.id_ >> numBitsToShift;
24 } 28 }
25 29
26 CompositorSubElementId SubElementIdFromCompositorElementId( 30 CompositorElementIdNamespace NamespaceFromCompositorElementId(
27 CompositorElementId element_id) { 31 CompositorElementId element_id) {
28 return static_cast<CompositorSubElementId>( 32 return static_cast<CompositorElementIdNamespace>(
29 element_id.id_ % 33 element_id.id_ %
30 static_cast<unsigned>(CompositorSubElementId::kNumSubElementTypes)); 34 static_cast<uint64_t>(
35 CompositorElementIdNamespace::kMaxRepresentableNamespaceId));
31 } 36 }
32 37
33 } // namespace blink 38 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698