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

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

Issue 2330863003: Switch to null root property tree nodes [spv2] (Closed)
Patch Set: Rebase from space Created 4 years, 3 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/PaintArtifactCompositor.h" 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h"
6 6
7 #include "cc/layers/content_layer_client.h" 7 #include "cc/layers/content_layer_client.h"
8 #include "cc/layers/layer.h" 8 #include "cc/layers/layer.h"
9 #include "cc/layers/picture_layer.h" 9 #include "cc/layers/picture_layer.h"
10 #include "cc/playback/display_item_list.h" 10 #include "cc/playback/display_item_list.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 211 }
212 212
213 namespace { 213 namespace {
214 214
215 class PropertyTreeManager { 215 class PropertyTreeManager {
216 WTF_MAKE_NONCOPYABLE(PropertyTreeManager); 216 WTF_MAKE_NONCOPYABLE(PropertyTreeManager);
217 public: 217 public:
218 PropertyTreeManager(cc::PropertyTrees& propertyTrees, cc::Layer* rootLayer) 218 PropertyTreeManager(cc::PropertyTrees& propertyTrees, cc::Layer* rootLayer)
219 : m_propertyTrees(propertyTrees) 219 : m_propertyTrees(propertyTrees)
220 , m_rootLayer(rootLayer) 220 , m_rootLayer(rootLayer)
221 #if DCHECK_IS_ON()
222 , m_isFirstEffectEver(true)
223 #endif
224 { 221 {
225 m_effectStack.append(BlinkEffectAndCcIdPair{nullptr, kSecondaryRootNodeI d}); 222 m_effectStack.append(BlinkEffectAndCcIdPair{nullptr, kSecondaryRootNodeI d});
226 } 223 }
227 224
228 // TODO(pdr): This will need to be unified with how viewport scale works. 225 // TODO(pdr): This will need to be unified with how viewport scale works.
229 void setDeviceScaleFactor(float); 226 void setDeviceScaleFactor(float);
230 227
231 int compositorIdForTransformNode(const TransformPaintPropertyNode*); 228 int compositorIdForTransformNode(const TransformPaintPropertyNode*);
232 int compositorIdForClipNode(const ClipPaintPropertyNode*); 229 int compositorIdForClipNode(const ClipPaintPropertyNode*);
233 int switchToEffectNode(const EffectPaintPropertyNode& nextEffect); 230 int switchToEffectNode(const EffectPaintPropertyNode* nextEffect);
234 int compositorIdForCurrentEffectNode() const { return m_effectStack.last().i d; } 231 int compositorIdForCurrentEffectNode() const { return m_effectStack.last().i d; }
235 int compositorIdForScrollNode(const ScrollPaintPropertyNode*); 232 int compositorIdForScrollNode(const ScrollPaintPropertyNode*);
236 233
237 // Scroll offset has special treatment in the transform and scroll trees. 234 // Scroll offset has special treatment in the transform and scroll trees.
238 void updateScrollOffset(int layerId, int scrollId); 235 void updateScrollOffset(int layerId, int scrollId);
239 236
240 private: 237 private:
241 void buildEffectNodesRecursively(const EffectPaintPropertyNode* nextEffect); 238 void buildEffectNodesRecursively(const EffectPaintPropertyNode* nextEffect);
242 239
243 cc::TransformTree& transformTree() { return m_propertyTrees.transform_tree; } 240 cc::TransformTree& transformTree() { return m_propertyTrees.transform_tree; }
(...skipping 16 matching lines...) Expand all
260 HashMap<const ScrollPaintPropertyNode*, int> m_scrollNodeMap; 257 HashMap<const ScrollPaintPropertyNode*, int> m_scrollNodeMap;
261 258
262 struct BlinkEffectAndCcIdPair { 259 struct BlinkEffectAndCcIdPair {
263 const EffectPaintPropertyNode* effect; 260 const EffectPaintPropertyNode* effect;
264 int id; 261 int id;
265 }; 262 };
266 Vector<BlinkEffectAndCcIdPair> m_effectStack; 263 Vector<BlinkEffectAndCcIdPair> m_effectStack;
267 264
268 #if DCHECK_IS_ON() 265 #if DCHECK_IS_ON()
269 HashSet<const EffectPaintPropertyNode*> m_effectNodesConverted; 266 HashSet<const EffectPaintPropertyNode*> m_effectNodesConverted;
270 bool m_isFirstEffectEver;
271 #endif 267 #endif
272 }; 268 };
273 269
274 void PropertyTreeManager::setDeviceScaleFactor(float deviceScaleFactor) 270 void PropertyTreeManager::setDeviceScaleFactor(float deviceScaleFactor)
275 { 271 {
276 auto& rootTransformNode = *transformTree().Node(kSecondaryRootNodeId); 272 auto& rootTransformNode = *transformTree().Node(kSecondaryRootNodeId);
277 rootTransformNode.local.Scale(deviceScaleFactor, deviceScaleFactor); 273 rootTransformNode.local.Scale(deviceScaleFactor, deviceScaleFactor);
278 } 274 }
279 275
280 int PropertyTreeManager::compositorIdForTransformNode(const TransformPaintProper tyNode* transformNode) 276 int PropertyTreeManager::compositorIdForTransformNode(const TransformPaintProper tyNode* transformNode)
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 depthB--; 424 depthB--;
429 } 425 }
430 DCHECK_EQ(depthA, depthB); 426 DCHECK_EQ(depthA, depthB);
431 while (nodeA != nodeB) { 427 while (nodeA != nodeB) {
432 nodeA = nodeA->parent(); 428 nodeA = nodeA->parent();
433 nodeB = nodeB->parent(); 429 nodeB = nodeB->parent();
434 } 430 }
435 return nodeA; 431 return nodeA;
436 } 432 }
437 433
438 int PropertyTreeManager::switchToEffectNode(const EffectPaintPropertyNode& nextE ffect) 434 int PropertyTreeManager::switchToEffectNode(const EffectPaintPropertyNode* nextE ffect)
439 { 435 {
440 const EffectPaintPropertyNode* ancestor = lowestCommonAncestor(currentEffect Node(), &nextEffect); 436 const EffectPaintPropertyNode* ancestor = lowestCommonAncestor(currentEffect Node(), nextEffect);
441 while (currentEffectNode() != ancestor) 437 while (currentEffectNode() != ancestor)
442 m_effectStack.removeLast(); 438 m_effectStack.removeLast();
443 439
444 #if DCHECK_IS_ON() 440 if (!nextEffect)
445 DCHECK(m_isFirstEffectEver || currentEffectNode()) << "Malformed effect tree . Nodes in the same property tree should have common root."; 441 return kSecondaryRootNodeId;
446 m_isFirstEffectEver = false; 442
447 #endif 443 buildEffectNodesRecursively(nextEffect);
448 buildEffectNodesRecursively(&nextEffect);
449 444
450 return compositorIdForCurrentEffectNode(); 445 return compositorIdForCurrentEffectNode();
451 } 446 }
452 447
453 void PropertyTreeManager::buildEffectNodesRecursively(const EffectPaintPropertyN ode* nextEffect) 448 void PropertyTreeManager::buildEffectNodesRecursively(const EffectPaintPropertyN ode* nextEffect)
454 { 449 {
455 if (nextEffect == currentEffectNode()) 450 if (nextEffect == currentEffectNode())
456 return; 451 return;
457 DCHECK(nextEffect); 452 DCHECK(nextEffect);
458 453
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 513
519 m_contentLayerClients.clear(); 514 m_contentLayerClients.clear();
520 m_contentLayerClients.reserveCapacity(paintArtifact.paintChunks().size()); 515 m_contentLayerClients.reserveCapacity(paintArtifact.paintChunks().size());
521 for (const PaintChunk& paintChunk : paintArtifact.paintChunks()) { 516 for (const PaintChunk& paintChunk : paintArtifact.paintChunks()) {
522 gfx::Vector2dF layerOffset; 517 gfx::Vector2dF layerOffset;
523 scoped_refptr<cc::Layer> layer = layerForPaintChunk(paintArtifact, paint Chunk, layerOffset); 518 scoped_refptr<cc::Layer> layer = layerForPaintChunk(paintArtifact, paint Chunk, layerOffset);
524 519
525 int transformId = propertyTreeManager.compositorIdForTransformNode(paint Chunk.properties.transform.get()); 520 int transformId = propertyTreeManager.compositorIdForTransformNode(paint Chunk.properties.transform.get());
526 int scrollId = propertyTreeManager.compositorIdForScrollNode(paintChunk. properties.scroll.get()); 521 int scrollId = propertyTreeManager.compositorIdForScrollNode(paintChunk. properties.scroll.get());
527 int clipId = propertyTreeManager.compositorIdForClipNode(paintChunk.prop erties.clip.get()); 522 int clipId = propertyTreeManager.compositorIdForClipNode(paintChunk.prop erties.clip.get());
528 int effectId = propertyTreeManager.switchToEffectNode(*paintChunk.proper ties.effect.get()); 523 int effectId = propertyTreeManager.switchToEffectNode(paintChunk.propert ies.effect.get());
529 524
530 propertyTreeManager.updateScrollOffset(layer->id(), scrollId); 525 propertyTreeManager.updateScrollOffset(layer->id(), scrollId);
531 526
532 layer->set_offset_to_transform_parent(layerOffset); 527 layer->set_offset_to_transform_parent(layerOffset);
533 528
534 m_rootLayer->AddChild(layer); 529 m_rootLayer->AddChild(layer);
535 layer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber); 530 layer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber);
536 layer->SetTransformTreeIndex(transformId); 531 layer->SetTransformTreeIndex(transformId);
537 layer->SetClipTreeIndex(clipId); 532 layer->SetClipTreeIndex(clipId);
538 layer->SetEffectTreeIndex(effectId); 533 layer->SetEffectTreeIndex(effectId);
539 layer->SetScrollTreeIndex(scrollId); 534 layer->SetScrollTreeIndex(scrollId);
540 535
541 // TODO(jbroman): This probably shouldn't be necessary, but it is still 536 // TODO(jbroman): This probably shouldn't be necessary, but it is still
542 // queried by RenderSurfaceImpl. 537 // queried by RenderSurfaceImpl.
543 layer->Set3dSortingContextId(layerTree->property_trees()->transform_tree .Node(transformId)->sorting_context_id); 538 layer->Set3dSortingContextId(layerTree->property_trees()->transform_tree .Node(transformId)->sorting_context_id);
544 539
545 layer->SetShouldCheckBackfaceVisibility(paintChunk.properties.backfaceHi dden); 540 layer->SetShouldCheckBackfaceVisibility(paintChunk.properties.backfaceHi dden);
546 541
547 if (m_extraDataForTestingEnabled) 542 if (m_extraDataForTestingEnabled)
548 m_extraDataForTesting->contentLayers.append(layer); 543 m_extraDataForTesting->contentLayers.append(layer);
549 } 544 }
550 545
551 // Mark the property trees as having been rebuilt. 546 // Mark the property trees as having been rebuilt.
552 layerTree->property_trees()->sequence_number = kPropertyTreeSequenceNumber; 547 layerTree->property_trees()->sequence_number = kPropertyTreeSequenceNumber;
553 layerTree->property_trees()->needs_rebuild = false; 548 layerTree->property_trees()->needs_rebuild = false;
554 } 549 }
555 550
556 } // namespace blink 551 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp ('k') | third_party/WebKit/Source/platform/graphics/paint/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698