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

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 tests and move increment. 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 static int sPropertyTreeSequenceNumber = 1;
pdr. 2017/02/28 17:44:58 Can you add a short comment here describing what t
wkorman 2017/02/28 20:58:47 Done.
66
65 class PaintArtifactCompositor::ContentLayerClientImpl 67 class PaintArtifactCompositor::ContentLayerClientImpl
66 : public cc::ContentLayerClient { 68 : public cc::ContentLayerClient {
67 WTF_MAKE_NONCOPYABLE(ContentLayerClientImpl); 69 WTF_MAKE_NONCOPYABLE(ContentLayerClientImpl);
68 USING_FAST_MALLOC(ContentLayerClientImpl); 70 USING_FAST_MALLOC(ContentLayerClientImpl);
69 71
70 public: 72 public:
71 ContentLayerClientImpl(DisplayItem::Id paintChunkId) 73 ContentLayerClientImpl(DisplayItem::Id paintChunkId)
72 : m_id(paintChunkId), 74 : m_id(paintChunkId),
73 m_debugName(paintChunkId.client.debugName()), 75 m_debugName(paintChunkId.client.debugName()),
74 m_ccPictureLayer(cc::PictureLayer::Create(this)) {} 76 m_ccPictureLayer(cc::PictureLayer::Create(this)) {}
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 691
690 // The tree will be null after detaching and this update can be ignored. 692 // The tree will be null after detaching and this update can be ignored.
691 // See: WebViewImpl::detachPaintArtifactCompositor(). 693 // See: WebViewImpl::detachPaintArtifactCompositor().
692 if (!layerTreeHost) 694 if (!layerTreeHost)
693 return; 695 return;
694 696
695 if (m_extraDataForTestingEnabled) 697 if (m_extraDataForTestingEnabled)
696 m_extraDataForTesting = WTF::wrapUnique(new ExtraDataForTesting); 698 m_extraDataForTesting = WTF::wrapUnique(new ExtraDataForTesting);
697 699
698 m_rootLayer->RemoveAllChildren(); 700 m_rootLayer->RemoveAllChildren();
699 m_rootLayer->set_property_tree_sequence_number( 701
700 PropertyTreeManager::kPropertyTreeSequenceNumber); 702 m_rootLayer->set_property_tree_sequence_number(sPropertyTreeSequenceNumber);
701 703
702 PropertyTreeManager propertyTreeManager(*layerTreeHost->property_trees(), 704 PropertyTreeManager propertyTreeManager(*layerTreeHost->property_trees(),
703 m_rootLayer.get()); 705 m_rootLayer.get(),
706 sPropertyTreeSequenceNumber);
704 707
705 Vector<PendingLayer, 0> pendingLayers; 708 Vector<PendingLayer, 0> pendingLayers;
706 collectPendingLayers(paintArtifact, pendingLayers, geometryMapper); 709 collectPendingLayers(paintArtifact, pendingLayers, geometryMapper);
707 710
708 Vector<std::unique_ptr<ContentLayerClientImpl>> newContentLayerClients; 711 Vector<std::unique_ptr<ContentLayerClientImpl>> newContentLayerClients;
709 newContentLayerClients.reserveCapacity(paintArtifact.paintChunks().size()); 712 newContentLayerClients.reserveCapacity(paintArtifact.paintChunks().size());
710 for (const PendingLayer& pendingLayer : pendingLayers) { 713 for (const PendingLayer& pendingLayer : pendingLayers) {
711 gfx::Vector2dF layerOffset; 714 gfx::Vector2dF layerOffset;
712 scoped_refptr<cc::Layer> layer = compositedLayerForPendingLayer( 715 scoped_refptr<cc::Layer> layer = compositedLayerForPendingLayer(
713 paintArtifact, pendingLayer, layerOffset, newContentLayerClients, 716 paintArtifact, pendingLayer, layerOffset, newContentLayerClients,
714 rasterChunkInvalidations, storeDebugInfo, geometryMapper); 717 rasterChunkInvalidations, storeDebugInfo, geometryMapper);
715 718
716 const auto* transform = pendingLayer.propertyTreeState.transform(); 719 const auto* transform = pendingLayer.propertyTreeState.transform();
717 int transformId = 720 int transformId =
718 propertyTreeManager.ensureCompositorTransformNode(transform); 721 propertyTreeManager.ensureCompositorTransformNode(transform);
719 int clipId = propertyTreeManager.ensureCompositorClipNode( 722 int clipId = propertyTreeManager.ensureCompositorClipNode(
720 pendingLayer.propertyTreeState.clip()); 723 pendingLayer.propertyTreeState.clip());
721 int effectId = propertyTreeManager.switchToEffectNode( 724 int effectId = propertyTreeManager.switchToEffectNode(
722 *pendingLayer.propertyTreeState.effect()); 725 *pendingLayer.propertyTreeState.effect());
723 726
724 layer->set_offset_to_transform_parent(layerOffset); 727 layer->set_offset_to_transform_parent(layerOffset);
725 layer->SetElementId(pendingLayer.propertyTreeState.compositorElementId()); 728 layer->SetElementId(pendingLayer.propertyTreeState.compositorElementId());
726 729
727 m_rootLayer->AddChild(layer); 730 m_rootLayer->AddChild(layer);
728 layer->set_property_tree_sequence_number( 731 layer->set_property_tree_sequence_number(sPropertyTreeSequenceNumber);
729 PropertyTreeManager::kPropertyTreeSequenceNumber);
730 layer->SetTransformTreeIndex(transformId); 732 layer->SetTransformTreeIndex(transformId);
731 layer->SetClipTreeIndex(clipId); 733 layer->SetClipTreeIndex(clipId);
732 layer->SetEffectTreeIndex(effectId); 734 layer->SetEffectTreeIndex(effectId);
733 propertyTreeManager.updateLayerScrollMapping(layer.get(), transform); 735 propertyTreeManager.updateLayerScrollMapping(layer.get(), transform);
734 736
735 layer->SetShouldCheckBackfaceVisibility(pendingLayer.backfaceHidden); 737 layer->SetShouldCheckBackfaceVisibility(pendingLayer.backfaceHidden);
736 738
737 if (m_extraDataForTestingEnabled) 739 if (m_extraDataForTestingEnabled)
738 m_extraDataForTesting->contentLayers.push_back(layer); 740 m_extraDataForTesting->contentLayers.push_back(layer);
739 } 741 }
740 m_contentLayerClients.clear(); 742 m_contentLayerClients.clear();
741 m_contentLayerClients.swap(newContentLayerClients); 743 m_contentLayerClients.swap(newContentLayerClients);
742 744
743 // Mark the property trees as having been rebuilt. 745 // Mark the property trees as having been rebuilt.
744 layerTreeHost->property_trees()->sequence_number = 746 layerTreeHost->property_trees()->sequence_number =
745 PropertyTreeManager::kPropertyTreeSequenceNumber; 747 sPropertyTreeSequenceNumber;
746 layerTreeHost->property_trees()->needs_rebuild = false; 748 layerTreeHost->property_trees()->needs_rebuild = false;
747 layerTreeHost->property_trees()->ResetCachedData(); 749 layerTreeHost->property_trees()->ResetCachedData();
750
751 sPropertyTreeSequenceNumber++;
748 } 752 }
749 753
750 #ifndef NDEBUG 754 #ifndef NDEBUG
751 void PaintArtifactCompositor::showDebugData() { 755 void PaintArtifactCompositor::showDebugData() {
752 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo) 756 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo)
753 ->toPrettyJSONString() 757 ->toPrettyJSONString()
754 .utf8() 758 .utf8()
755 .data(); 759 .data();
756 } 760 }
757 #endif 761 #endif
758 762
759 } // namespace blink 763 } // 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