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

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

Issue 2725513002: Increment property tree sequence number when updating. (Closed)
Patch Set: Add comment. Created 3 years, 9 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 #include "cc/layers/content_layer_client.h" 10 #include "cc/layers/content_layer_client.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 } 55 }
56 56
57 template <typename T> 57 template <typename T>
58 static std::unique_ptr<JSONArray> sizeAsJSONArray(const T& size) { 58 static std::unique_ptr<JSONArray> sizeAsJSONArray(const T& size) {
59 std::unique_ptr<JSONArray> array = JSONArray::create(); 59 std::unique_ptr<JSONArray> array = JSONArray::create();
60 array->pushDouble(size.width()); 60 array->pushDouble(size.width());
61 array->pushDouble(size.height()); 61 array->pushDouble(size.height());
62 return array; 62 return array;
63 } 63 }
64 64
65 // cc property trees make use of a sequence number to identify when tree
66 // topology changes. For now we naively increment the sequence number each time
67 // we update the property trees. We should explore optimizing our management of
68 // the sequence number through the use of a dirty bit or similar. See
69 // http://crbug.com/692842#c4.
70 static int sPropertyTreeSequenceNumber = 1;
71
65 class PaintArtifactCompositor::ContentLayerClientImpl 72 class PaintArtifactCompositor::ContentLayerClientImpl
66 : public cc::ContentLayerClient { 73 : public cc::ContentLayerClient {
67 WTF_MAKE_NONCOPYABLE(ContentLayerClientImpl); 74 WTF_MAKE_NONCOPYABLE(ContentLayerClientImpl);
68 USING_FAST_MALLOC(ContentLayerClientImpl); 75 USING_FAST_MALLOC(ContentLayerClientImpl);
69 76
70 public: 77 public:
71 ContentLayerClientImpl(DisplayItem::Id paintChunkId) 78 ContentLayerClientImpl(DisplayItem::Id paintChunkId)
72 : m_id(paintChunkId), 79 : m_id(paintChunkId),
73 m_debugName(paintChunkId.client.debugName()), 80 m_debugName(paintChunkId.client.debugName()),
74 m_ccPictureLayer(cc::PictureLayer::Create(this)) {} 81 m_ccPictureLayer(cc::PictureLayer::Create(this)) {}
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 696
690 // The tree will be null after detaching and this update can be ignored. 697 // The tree will be null after detaching and this update can be ignored.
691 // See: WebViewImpl::detachPaintArtifactCompositor(). 698 // See: WebViewImpl::detachPaintArtifactCompositor().
692 if (!layerTreeHost) 699 if (!layerTreeHost)
693 return; 700 return;
694 701
695 if (m_extraDataForTestingEnabled) 702 if (m_extraDataForTestingEnabled)
696 m_extraDataForTesting = WTF::wrapUnique(new ExtraDataForTesting); 703 m_extraDataForTesting = WTF::wrapUnique(new ExtraDataForTesting);
697 704
698 m_rootLayer->RemoveAllChildren(); 705 m_rootLayer->RemoveAllChildren();
699 m_rootLayer->set_property_tree_sequence_number( 706
700 PropertyTreeManager::kPropertyTreeSequenceNumber); 707 m_rootLayer->set_property_tree_sequence_number(sPropertyTreeSequenceNumber);
701 708
702 PropertyTreeManager propertyTreeManager(*layerTreeHost->property_trees(), 709 PropertyTreeManager propertyTreeManager(*layerTreeHost->property_trees(),
703 m_rootLayer.get()); 710 m_rootLayer.get(),
711 sPropertyTreeSequenceNumber);
704 712
705 Vector<PendingLayer, 0> pendingLayers; 713 Vector<PendingLayer, 0> pendingLayers;
706 collectPendingLayers(paintArtifact, pendingLayers, geometryMapper); 714 collectPendingLayers(paintArtifact, pendingLayers, geometryMapper);
707 715
708 Vector<std::unique_ptr<ContentLayerClientImpl>> newContentLayerClients; 716 Vector<std::unique_ptr<ContentLayerClientImpl>> newContentLayerClients;
709 newContentLayerClients.reserveCapacity(paintArtifact.paintChunks().size()); 717 newContentLayerClients.reserveCapacity(paintArtifact.paintChunks().size());
710 for (const PendingLayer& pendingLayer : pendingLayers) { 718 for (const PendingLayer& pendingLayer : pendingLayers) {
711 gfx::Vector2dF layerOffset; 719 gfx::Vector2dF layerOffset;
712 scoped_refptr<cc::Layer> layer = compositedLayerForPendingLayer( 720 scoped_refptr<cc::Layer> layer = compositedLayerForPendingLayer(
713 paintArtifact, pendingLayer, layerOffset, newContentLayerClients, 721 paintArtifact, pendingLayer, layerOffset, newContentLayerClients,
714 rasterChunkInvalidations, storeDebugInfo, geometryMapper); 722 rasterChunkInvalidations, storeDebugInfo, geometryMapper);
715 723
716 const auto* transform = pendingLayer.propertyTreeState.transform(); 724 const auto* transform = pendingLayer.propertyTreeState.transform();
717 int transformId = 725 int transformId =
718 propertyTreeManager.ensureCompositorTransformNode(transform); 726 propertyTreeManager.ensureCompositorTransformNode(transform);
719 int clipId = propertyTreeManager.ensureCompositorClipNode( 727 int clipId = propertyTreeManager.ensureCompositorClipNode(
720 pendingLayer.propertyTreeState.clip()); 728 pendingLayer.propertyTreeState.clip());
721 int effectId = propertyTreeManager.switchToEffectNode( 729 int effectId = propertyTreeManager.switchToEffectNode(
722 *pendingLayer.propertyTreeState.effect()); 730 *pendingLayer.propertyTreeState.effect());
723 731
724 layer->set_offset_to_transform_parent(layerOffset); 732 layer->set_offset_to_transform_parent(layerOffset);
725 layer->SetElementId(pendingLayer.propertyTreeState.compositorElementId()); 733 layer->SetElementId(pendingLayer.propertyTreeState.compositorElementId());
726 734
727 m_rootLayer->AddChild(layer); 735 m_rootLayer->AddChild(layer);
728 layer->set_property_tree_sequence_number( 736 layer->set_property_tree_sequence_number(sPropertyTreeSequenceNumber);
729 PropertyTreeManager::kPropertyTreeSequenceNumber);
730 layer->SetTransformTreeIndex(transformId); 737 layer->SetTransformTreeIndex(transformId);
731 layer->SetClipTreeIndex(clipId); 738 layer->SetClipTreeIndex(clipId);
732 layer->SetEffectTreeIndex(effectId); 739 layer->SetEffectTreeIndex(effectId);
733 propertyTreeManager.updateLayerScrollMapping(layer.get(), transform); 740 propertyTreeManager.updateLayerScrollMapping(layer.get(), transform);
734 741
735 layer->SetShouldCheckBackfaceVisibility(pendingLayer.backfaceHidden); 742 layer->SetShouldCheckBackfaceVisibility(pendingLayer.backfaceHidden);
736 743
737 if (m_extraDataForTestingEnabled) 744 if (m_extraDataForTestingEnabled)
738 m_extraDataForTesting->contentLayers.push_back(layer); 745 m_extraDataForTesting->contentLayers.push_back(layer);
739 } 746 }
740 m_contentLayerClients.clear(); 747 m_contentLayerClients.clear();
741 m_contentLayerClients.swap(newContentLayerClients); 748 m_contentLayerClients.swap(newContentLayerClients);
742 749
743 // Mark the property trees as having been rebuilt. 750 // Mark the property trees as having been rebuilt.
744 layerTreeHost->property_trees()->sequence_number = 751 layerTreeHost->property_trees()->sequence_number =
745 PropertyTreeManager::kPropertyTreeSequenceNumber; 752 sPropertyTreeSequenceNumber;
746 layerTreeHost->property_trees()->needs_rebuild = false; 753 layerTreeHost->property_trees()->needs_rebuild = false;
747 layerTreeHost->property_trees()->ResetCachedData(); 754 layerTreeHost->property_trees()->ResetCachedData();
755
756 sPropertyTreeSequenceNumber++;
748 } 757 }
749 758
750 #ifndef NDEBUG 759 #ifndef NDEBUG
751 void PaintArtifactCompositor::showDebugData() { 760 void PaintArtifactCompositor::showDebugData() {
752 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo) 761 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo)
753 ->toPrettyJSONString() 762 ->toPrettyJSONString()
754 .utf8() 763 .utf8()
755 .data(); 764 .data();
756 } 765 }
757 #endif 766 #endif
758 767
759 } // namespace blink 768 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698