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

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

Issue 2698473006: Set layer scroll data from PaintArtifactCompositor (Closed)
Patch Set: More comments Created 3 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/compositing/PropertyTreeManager.h" 5 #include "platform/graphics/compositing/PropertyTreeManager.h"
6 6
7 #include "cc/layers/layer.h" 7 #include "cc/layers/layer.h"
8 #include "cc/trees/clip_node.h" 8 #include "cc/trees/clip_node.h"
9 #include "cc/trees/effect_node.h" 9 #include "cc/trees/effect_node.h"
10 #include "cc/trees/layer_tree_host.h" 10 #include "cc/trees/layer_tree_host.h"
11 #include "cc/trees/property_tree.h" 11 #include "cc/trees/property_tree.h"
12 #include "cc/trees/scroll_node.h" 12 #include "cc/trees/scroll_node.h"
13 #include "cc/trees/transform_node.h" 13 #include "cc/trees/transform_node.h"
14 #include "platform/graphics/paint/ClipPaintPropertyNode.h" 14 #include "platform/graphics/paint/ClipPaintPropertyNode.h"
15 #include "platform/graphics/paint/EffectPaintPropertyNode.h" 15 #include "platform/graphics/paint/EffectPaintPropertyNode.h"
16 #include "platform/graphics/paint/GeometryMapper.h" 16 #include "platform/graphics/paint/GeometryMapper.h"
17 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" 17 #include "platform/graphics/paint/ScrollPaintPropertyNode.h"
18 #include "platform/graphics/paint/TransformPaintPropertyNode.h" 18 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
19 #include "public/platform/WebLayerScrollClient.h"
19 20
20 namespace blink { 21 namespace blink {
21 22
22 namespace { 23 namespace {
23 24
24 static constexpr int kInvalidNodeId = -1; 25 static constexpr int kInvalidNodeId = -1;
25 // cc's property trees use 0 for the root node (always non-null). 26 // cc's property trees use 0 for the root node (always non-null).
26 static constexpr int kRealRootNodeId = 0; 27 static constexpr int kRealRootNodeId = 0;
27 // cc allocates special nodes for root effects such as the device scale. 28 // cc allocates special nodes for root effects such as the device scale.
28 static constexpr int kSecondaryRootNodeId = 1; 29 static constexpr int kSecondaryRootNodeId = 1;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 return kSecondaryRootNodeId; 258 return kSecondaryRootNodeId;
258 259
259 auto it = m_scrollNodeMap.find(scrollNode); 260 auto it = m_scrollNodeMap.find(scrollNode);
260 if (it != m_scrollNodeMap.end()) 261 if (it != m_scrollNodeMap.end())
261 return it->value; 262 return it->value;
262 263
263 int parentId = ensureCompositorScrollNode(scrollNode->parent()); 264 int parentId = ensureCompositorScrollNode(scrollNode->parent());
264 int id = scrollTree().Insert(cc::ScrollNode(), parentId); 265 int id = scrollTree().Insert(cc::ScrollNode(), parentId);
265 266
266 cc::ScrollNode& compositorNode = *scrollTree().Node(id); 267 cc::ScrollNode& compositorNode = *scrollTree().Node(id);
267 // TODO(wkorman): Fix owning layer id to reference a layer id rather than a
268 // scroll node index.
269 compositorNode.owning_layer_id = parentId;
270 m_propertyTrees
271 .layer_id_to_scroll_node_index[compositorNode.owning_layer_id] = id;
272
273 compositorNode.scrollable = true; 268 compositorNode.scrollable = true;
274 269
275 compositorNode.scroll_clip_layer_bounds.SetSize(scrollNode->clip().width(), 270 compositorNode.scroll_clip_layer_bounds.SetSize(scrollNode->clip().width(),
276 scrollNode->clip().height()); 271 scrollNode->clip().height());
277 compositorNode.bounds.SetSize(scrollNode->bounds().width(), 272 compositorNode.bounds.SetSize(scrollNode->bounds().width(),
278 scrollNode->bounds().height()); 273 scrollNode->bounds().height());
279 compositorNode.user_scrollable_horizontal = 274 compositorNode.user_scrollable_horizontal =
280 scrollNode->userScrollableHorizontal(); 275 scrollNode->userScrollableHorizontal();
281 compositorNode.user_scrollable_vertical = 276 compositorNode.user_scrollable_vertical =
282 scrollNode->userScrollableVertical(); 277 scrollNode->userScrollableVertical();
(...skipping 29 matching lines...) Expand all
312 // cc's transform node to remove the 2d scroll translation and instead set the 307 // cc's transform node to remove the 2d scroll translation and instead set the
313 // scroll_offset field. 308 // scroll_offset field.
314 auto scrollOffsetSize = scrollOffsetNode->matrix().to2DTranslation(); 309 auto scrollOffsetSize = scrollOffsetNode->matrix().to2DTranslation();
315 auto scrollOffset = 310 auto scrollOffset =
316 gfx::ScrollOffset(-scrollOffsetSize.width(), -scrollOffsetSize.height()); 311 gfx::ScrollOffset(-scrollOffsetSize.width(), -scrollOffsetSize.height());
317 DCHECK(compositorTransformNode.local.IsIdentityOr2DTranslation()); 312 DCHECK(compositorTransformNode.local.IsIdentityOr2DTranslation());
318 compositorTransformNode.scroll_offset = scrollOffset; 313 compositorTransformNode.scroll_offset = scrollOffset;
319 compositorTransformNode.local.MakeIdentity(); 314 compositorTransformNode.local.MakeIdentity();
320 compositorTransformNode.scrolls = true; 315 compositorTransformNode.scrolls = true;
321 transformTree().set_needs_update(true); 316 transformTree().set_needs_update(true);
322 // TODO(pdr): The scroll tree's scroll offset will need to be set here. 317 // TODO(pdr): Because of a layer dependancy, the scroll tree scroll offset is
318 // set in updateLayerScrollMapping but that should occur here.
319 }
320
321 void PropertyTreeManager::updateLayerScrollMapping(
322 cc::Layer* layer,
323 const TransformPaintPropertyNode* transform) {
324 auto* enclosingScrollNode = transform->findEnclosingScrollNode();
325 int scrollNodeId = ensureCompositorScrollNode(enclosingScrollNode);
326 layer->SetScrollTreeIndex(scrollNodeId);
327 int layerId = layer->id();
328 m_propertyTrees.layer_id_to_scroll_node_index[layerId] = scrollNodeId;
329
330 if (!transform->isScrollTranslation())
331 return;
332
333 auto& compositorScrollNode = *scrollTree().Node(scrollNodeId);
334
335 // TODO(pdr): Remove the scroll node's owning_layer_id. This approach of
336 // setting owning_layer_id only when it is not set lets us maintain a 1:1
337 // mapping from layer to scroll node.
338 if (compositorScrollNode.owning_layer_id == cc::Layer::INVALID_ID) {
339 compositorScrollNode.owning_layer_id = layerId;
340 auto& compositorTransformNode =
341 *transformTree().Node(compositorScrollNode.transform_id);
342 // TODO(pdr): Set this in updateScrollAndScrollTranslationNodes once the
343 // layer id is no longer needed.
344 scrollTree().SetScrollOffset(layerId,
345 compositorTransformNode.scroll_offset);
346 if (auto* scrollClient = enclosingScrollNode->scrollClient()) {
347 layer->set_did_scroll_callback(
348 base::Bind(&blink::WebLayerScrollClient::didScroll,
349 base::Unretained(scrollClient)));
350 }
351 }
323 } 352 }
324 353
325 int PropertyTreeManager::switchToEffectNode( 354 int PropertyTreeManager::switchToEffectNode(
326 const EffectPaintPropertyNode& nextEffect) { 355 const EffectPaintPropertyNode& nextEffect) {
327 const EffectPaintPropertyNode* ancestor = 356 const EffectPaintPropertyNode* ancestor =
328 GeometryMapper::lowestCommonAncestor(currentEffectNode(), &nextEffect); 357 GeometryMapper::lowestCommonAncestor(currentEffectNode(), &nextEffect);
329 DCHECK(ancestor) << "Malformed effect tree. All nodes must be descendant of " 358 DCHECK(ancestor) << "Malformed effect tree. All nodes must be descendant of "
330 "EffectPaintPropertyNode::root()."; 359 "EffectPaintPropertyNode::root().";
331 while (currentEffectNode() != ancestor) 360 while (currentEffectNode() != ancestor)
332 m_effectStack.pop_back(); 361 m_effectStack.pop_back();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 m_effectStack.push_back(BlinkEffectAndCcIdPair{nextEffect, effectNode.id}); 441 m_effectStack.push_back(BlinkEffectAndCcIdPair{nextEffect, effectNode.id});
413 442
414 dummyLayer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber); 443 dummyLayer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber);
415 dummyLayer->SetTransformTreeIndex(kSecondaryRootNodeId); 444 dummyLayer->SetTransformTreeIndex(kSecondaryRootNodeId);
416 dummyLayer->SetClipTreeIndex(outputClipId); 445 dummyLayer->SetClipTreeIndex(outputClipId);
417 dummyLayer->SetEffectTreeIndex(effectNode.id); 446 dummyLayer->SetEffectTreeIndex(effectNode.id);
418 dummyLayer->SetScrollTreeIndex(kRealRootNodeId); 447 dummyLayer->SetScrollTreeIndex(kRealRootNodeId);
419 } 448 }
420 449
421 } // namespace blink 450 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698