OLD | NEW |
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/compositing_display_item.h" | 10 #include "cc/playback/compositing_display_item.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 : m_id(paintChunkId), | 76 : m_id(paintChunkId), |
77 m_debugName(paintChunkId.client.debugName()), | 77 m_debugName(paintChunkId.client.debugName()), |
78 m_ccPictureLayer(cc::PictureLayer::Create(this)) {} | 78 m_ccPictureLayer(cc::PictureLayer::Create(this)) {} |
79 | 79 |
80 void SetDisplayList(scoped_refptr<cc::DisplayItemList> ccDisplayItemList) { | 80 void SetDisplayList(scoped_refptr<cc::DisplayItemList> ccDisplayItemList) { |
81 m_ccDisplayItemList = std::move(ccDisplayItemList); | 81 m_ccDisplayItemList = std::move(ccDisplayItemList); |
82 } | 82 } |
83 void SetPaintableRegion(gfx::Rect region) { m_paintableRegion = region; } | 83 void SetPaintableRegion(gfx::Rect region) { m_paintableRegion = region; } |
84 | 84 |
85 void addPaintChunkDebugData(std::unique_ptr<JSONArray> json) { | 85 void addPaintChunkDebugData(std::unique_ptr<JSONArray> json) { |
86 m_paintChunkDebugData.append(std::move(json)); | 86 m_paintChunkDebugData.push_back(std::move(json)); |
87 } | 87 } |
88 void clearPaintChunkDebugData() { m_paintChunkDebugData.clear(); } | 88 void clearPaintChunkDebugData() { m_paintChunkDebugData.clear(); } |
89 | 89 |
90 // cc::ContentLayerClient | 90 // cc::ContentLayerClient |
91 gfx::Rect PaintableRegion() override { return m_paintableRegion; } | 91 gfx::Rect PaintableRegion() override { return m_paintableRegion; } |
92 scoped_refptr<cc::DisplayItemList> PaintContentsToDisplayList( | 92 scoped_refptr<cc::DisplayItemList> PaintContentsToDisplayList( |
93 PaintingControlSetting) override { | 93 PaintingControlSetting) override { |
94 return m_ccDisplayItemList; | 94 return m_ccDisplayItemList; |
95 } | 95 } |
96 bool FillsBoundsCompletely() const override { return false; } | 96 bool FillsBoundsCompletely() const override { return false; } |
(...skipping 25 matching lines...) Expand all Loading... |
122 void setNeedsDisplayRect(const gfx::Rect& rect, | 122 void setNeedsDisplayRect(const gfx::Rect& rect, |
123 RasterInvalidationInfo* rasterInvalidationInfo) { | 123 RasterInvalidationInfo* rasterInvalidationInfo) { |
124 m_ccPictureLayer->SetNeedsDisplayRect(rect); | 124 m_ccPictureLayer->SetNeedsDisplayRect(rect); |
125 | 125 |
126 if (!rasterInvalidationInfo || rect.IsEmpty()) | 126 if (!rasterInvalidationInfo || rect.IsEmpty()) |
127 return; | 127 return; |
128 | 128 |
129 RasterInvalidationTracking& tracking = | 129 RasterInvalidationTracking& tracking = |
130 ccLayersRasterInvalidationTrackingMap().add(m_ccPictureLayer.get()); | 130 ccLayersRasterInvalidationTrackingMap().add(m_ccPictureLayer.get()); |
131 | 131 |
132 tracking.trackedRasterInvalidations.append(*rasterInvalidationInfo); | 132 tracking.trackedRasterInvalidations.push_back(*rasterInvalidationInfo); |
133 | 133 |
134 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { | 134 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { |
135 // TODO(crbug.com/496260): Some antialiasing effects overflow the paint | 135 // TODO(crbug.com/496260): Some antialiasing effects overflow the paint |
136 // invalidation rect. | 136 // invalidation rect. |
137 IntRect r = rasterInvalidationInfo->rect; | 137 IntRect r = rasterInvalidationInfo->rect; |
138 r.inflate(1); | 138 r.inflate(1); |
139 tracking.rasterInvalidationRegionSinceLastPaint.unite(r); | 139 tracking.rasterInvalidationRegionSinceLastPaint.unite(r); |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 // Raster paintChunk.rasterInvalidationRects is in the space of the | 571 // Raster paintChunk.rasterInvalidationRects is in the space of the |
572 // containing transform node, so need to subtract off the layer offset. | 572 // containing transform node, so need to subtract off the layer offset. |
573 ccInvalidationRect.Offset(-ccCombinedBounds.OffsetFromOrigin()); | 573 ccInvalidationRect.Offset(-ccCombinedBounds.OffsetFromOrigin()); |
574 contentLayerClient->setNeedsDisplayRect( | 574 contentLayerClient->setNeedsDisplayRect( |
575 ccInvalidationRect, | 575 ccInvalidationRect, |
576 rasterTracking ? &rasterTracking->trackedRasterInvalidations[index] | 576 rasterTracking ? &rasterTracking->trackedRasterInvalidations[index] |
577 : nullptr); | 577 : nullptr); |
578 } | 578 } |
579 } | 579 } |
580 | 580 |
581 newContentLayerClients.append(std::move(contentLayerClient)); | 581 newContentLayerClients.push_back(std::move(contentLayerClient)); |
582 return ccPictureLayer; | 582 return ccPictureLayer; |
583 } | 583 } |
584 | 584 |
585 namespace { | 585 namespace { |
586 | 586 |
587 class PropertyTreeManager { | 587 class PropertyTreeManager { |
588 WTF_MAKE_NONCOPYABLE(PropertyTreeManager); | 588 WTF_MAKE_NONCOPYABLE(PropertyTreeManager); |
589 | 589 |
590 public: | 590 public: |
591 PropertyTreeManager(cc::PropertyTrees& propertyTrees, cc::Layer* rootLayer) | 591 PropertyTreeManager(cc::PropertyTrees& propertyTrees, cc::Layer* rootLayer) |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 cc::EffectNode& effectNode = | 743 cc::EffectNode& effectNode = |
744 *effectTree.Node(effectTree.Insert(cc::EffectNode(), kInvalidNodeId)); | 744 *effectTree.Node(effectTree.Insert(cc::EffectNode(), kInvalidNodeId)); |
745 DCHECK_EQ(effectNode.id, kSecondaryRootNodeId); | 745 DCHECK_EQ(effectNode.id, kSecondaryRootNodeId); |
746 effectNode.owning_layer_id = m_rootLayer->id(); | 746 effectNode.owning_layer_id = m_rootLayer->id(); |
747 effectNode.transform_id = kRealRootNodeId; | 747 effectNode.transform_id = kRealRootNodeId; |
748 effectNode.clip_id = kSecondaryRootNodeId; | 748 effectNode.clip_id = kSecondaryRootNodeId; |
749 effectNode.has_render_surface = true; | 749 effectNode.has_render_surface = true; |
750 m_propertyTrees.effect_id_to_index_map[effectNode.owning_layer_id] = | 750 m_propertyTrees.effect_id_to_index_map[effectNode.owning_layer_id] = |
751 effectNode.id; | 751 effectNode.id; |
752 | 752 |
753 m_effectStack.append( | 753 m_effectStack.push_back( |
754 BlinkEffectAndCcIdPair{EffectPaintPropertyNode::root(), effectNode.id}); | 754 BlinkEffectAndCcIdPair{EffectPaintPropertyNode::root(), effectNode.id}); |
755 m_rootLayer->SetEffectTreeIndex(effectNode.id); | 755 m_rootLayer->SetEffectTreeIndex(effectNode.id); |
756 } | 756 } |
757 | 757 |
758 void PropertyTreeManager::setupRootScrollNode() { | 758 void PropertyTreeManager::setupRootScrollNode() { |
759 cc::ScrollTree& scrollTree = m_propertyTrees.scroll_tree; | 759 cc::ScrollTree& scrollTree = m_propertyTrees.scroll_tree; |
760 scrollTree.clear(); | 760 scrollTree.clear(); |
761 m_propertyTrees.scroll_id_to_index_map.clear(); | 761 m_propertyTrees.scroll_id_to_index_map.clear(); |
762 cc::ScrollNode& scrollNode = | 762 cc::ScrollNode& scrollNode = |
763 *scrollTree.Node(scrollTree.Insert(cc::ScrollNode(), kRealRootNodeId)); | 763 *scrollTree.Node(scrollTree.Insert(cc::ScrollNode(), kRealRootNodeId)); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 // decision until later phase of the pipeline. Remove premature optimization | 1023 // decision until later phase of the pipeline. Remove premature optimization |
1024 // here once the work is ready. | 1024 // here once the work is ready. |
1025 if (!nextEffect->filter().isEmpty() || | 1025 if (!nextEffect->filter().isEmpty() || |
1026 nextEffect->blendMode() != SkBlendMode::kSrcOver) | 1026 nextEffect->blendMode() != SkBlendMode::kSrcOver) |
1027 effectNode.has_render_surface = true; | 1027 effectNode.has_render_surface = true; |
1028 effectNode.opacity = nextEffect->opacity(); | 1028 effectNode.opacity = nextEffect->opacity(); |
1029 effectNode.filters = nextEffect->filter().asCcFilterOperations(); | 1029 effectNode.filters = nextEffect->filter().asCcFilterOperations(); |
1030 effectNode.blend_mode = nextEffect->blendMode(); | 1030 effectNode.blend_mode = nextEffect->blendMode(); |
1031 m_propertyTrees.effect_id_to_index_map[effectNode.owning_layer_id] = | 1031 m_propertyTrees.effect_id_to_index_map[effectNode.owning_layer_id] = |
1032 effectNode.id; | 1032 effectNode.id; |
1033 m_effectStack.append(BlinkEffectAndCcIdPair{nextEffect, effectNode.id}); | 1033 m_effectStack.push_back(BlinkEffectAndCcIdPair{nextEffect, effectNode.id}); |
1034 | 1034 |
1035 dummyLayer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber); | 1035 dummyLayer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber); |
1036 dummyLayer->SetTransformTreeIndex(kSecondaryRootNodeId); | 1036 dummyLayer->SetTransformTreeIndex(kSecondaryRootNodeId); |
1037 dummyLayer->SetClipTreeIndex(outputClipId); | 1037 dummyLayer->SetClipTreeIndex(outputClipId); |
1038 dummyLayer->SetEffectTreeIndex(effectNode.id); | 1038 dummyLayer->SetEffectTreeIndex(effectNode.id); |
1039 dummyLayer->SetScrollTreeIndex(kRealRootNodeId); | 1039 dummyLayer->SetScrollTreeIndex(kRealRootNodeId); |
1040 } | 1040 } |
1041 | 1041 |
1042 } // namespace | 1042 } // namespace |
1043 | 1043 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 | 1095 |
1096 return paintChunkScreenVisualRect.intersects(pendingLayerScreenVisualRect); | 1096 return paintChunkScreenVisualRect.intersects(pendingLayerScreenVisualRect); |
1097 } | 1097 } |
1098 | 1098 |
1099 PaintArtifactCompositor::PendingLayer::PendingLayer( | 1099 PaintArtifactCompositor::PendingLayer::PendingLayer( |
1100 const PaintChunk& firstPaintChunk) | 1100 const PaintChunk& firstPaintChunk) |
1101 : bounds(firstPaintChunk.bounds), | 1101 : bounds(firstPaintChunk.bounds), |
1102 knownToBeOpaque(firstPaintChunk.knownToBeOpaque), | 1102 knownToBeOpaque(firstPaintChunk.knownToBeOpaque), |
1103 backfaceHidden(firstPaintChunk.properties.backfaceHidden), | 1103 backfaceHidden(firstPaintChunk.properties.backfaceHidden), |
1104 propertyTreeState(firstPaintChunk.properties.propertyTreeState) { | 1104 propertyTreeState(firstPaintChunk.properties.propertyTreeState) { |
1105 paintChunks.append(&firstPaintChunk); | 1105 paintChunks.push_back(&firstPaintChunk); |
1106 } | 1106 } |
1107 | 1107 |
1108 void PaintArtifactCompositor::PendingLayer::add( | 1108 void PaintArtifactCompositor::PendingLayer::add( |
1109 const PaintChunk& paintChunk, | 1109 const PaintChunk& paintChunk, |
1110 GeometryMapper* geometryMapper) { | 1110 GeometryMapper* geometryMapper) { |
1111 DCHECK(paintChunk.properties.backfaceHidden == backfaceHidden); | 1111 DCHECK(paintChunk.properties.backfaceHidden == backfaceHidden); |
1112 paintChunks.append(&paintChunk); | 1112 paintChunks.push_back(&paintChunk); |
1113 FloatRect mappedBounds = paintChunk.bounds; | 1113 FloatRect mappedBounds = paintChunk.bounds; |
1114 if (geometryMapper) { | 1114 if (geometryMapper) { |
1115 bool success = false; | 1115 bool success = false; |
1116 mappedBounds = geometryMapper->localToAncestorRect( | 1116 mappedBounds = geometryMapper->localToAncestorRect( |
1117 mappedBounds, paintChunk.properties.propertyTreeState, | 1117 mappedBounds, paintChunk.properties.propertyTreeState, |
1118 propertyTreeState, success); | 1118 propertyTreeState, success); |
1119 DCHECK(success); | 1119 DCHECK(success); |
1120 } | 1120 } |
1121 bounds.unite(mappedBounds); | 1121 bounds.unite(mappedBounds); |
1122 if (bounds.size() != paintChunks[0]->bounds.size()) { | 1122 if (bounds.size() != paintChunks[0]->bounds.size()) { |
(...skipping 19 matching lines...) Expand all Loading... |
1142 if (canMergeInto(paintArtifact, paintChunk, *candidatePendingLayer)) { | 1142 if (canMergeInto(paintArtifact, paintChunk, *candidatePendingLayer)) { |
1143 candidatePendingLayer->add(paintChunk, &geometryMapper); | 1143 candidatePendingLayer->add(paintChunk, &geometryMapper); |
1144 createNew = false; | 1144 createNew = false; |
1145 break; | 1145 break; |
1146 } | 1146 } |
1147 if (mightOverlap(paintChunk, *candidatePendingLayer, geometryMapper)) { | 1147 if (mightOverlap(paintChunk, *candidatePendingLayer, geometryMapper)) { |
1148 break; | 1148 break; |
1149 } | 1149 } |
1150 } | 1150 } |
1151 if (createNew) | 1151 if (createNew) |
1152 pendingLayers.append(PendingLayer(paintChunk)); | 1152 pendingLayers.push_back(PendingLayer(paintChunk)); |
1153 } | 1153 } |
1154 } | 1154 } |
1155 | 1155 |
1156 void PaintArtifactCompositor::update( | 1156 void PaintArtifactCompositor::update( |
1157 const PaintArtifact& paintArtifact, | 1157 const PaintArtifact& paintArtifact, |
1158 RasterInvalidationTrackingMap<const PaintChunk>* rasterChunkInvalidations, | 1158 RasterInvalidationTrackingMap<const PaintChunk>* rasterChunkInvalidations, |
1159 bool storeDebugInfo) { | 1159 bool storeDebugInfo) { |
1160 #ifndef NDEBUG | 1160 #ifndef NDEBUG |
1161 storeDebugInfo = true; | 1161 storeDebugInfo = true; |
1162 #endif | 1162 #endif |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 | 1213 |
1214 // TODO(jbroman): This probably shouldn't be necessary, but it is still | 1214 // TODO(jbroman): This probably shouldn't be necessary, but it is still |
1215 // queried by RenderSurfaceImpl. | 1215 // queried by RenderSurfaceImpl. |
1216 layer->Set3dSortingContextId(layerTree->property_trees() | 1216 layer->Set3dSortingContextId(layerTree->property_trees() |
1217 ->transform_tree.Node(transformId) | 1217 ->transform_tree.Node(transformId) |
1218 ->sorting_context_id); | 1218 ->sorting_context_id); |
1219 | 1219 |
1220 layer->SetShouldCheckBackfaceVisibility(pendingLayer.backfaceHidden); | 1220 layer->SetShouldCheckBackfaceVisibility(pendingLayer.backfaceHidden); |
1221 | 1221 |
1222 if (m_extraDataForTestingEnabled) | 1222 if (m_extraDataForTestingEnabled) |
1223 m_extraDataForTesting->contentLayers.append(layer); | 1223 m_extraDataForTesting->contentLayers.push_back(layer); |
1224 } | 1224 } |
1225 m_contentLayerClients.clear(); | 1225 m_contentLayerClients.clear(); |
1226 m_contentLayerClients.swap(newContentLayerClients); | 1226 m_contentLayerClients.swap(newContentLayerClients); |
1227 | 1227 |
1228 // Mark the property trees as having been rebuilt. | 1228 // Mark the property trees as having been rebuilt. |
1229 layerTree->property_trees()->sequence_number = kPropertyTreeSequenceNumber; | 1229 layerTree->property_trees()->sequence_number = kPropertyTreeSequenceNumber; |
1230 layerTree->property_trees()->needs_rebuild = false; | 1230 layerTree->property_trees()->needs_rebuild = false; |
1231 layerTree->property_trees()->ResetCachedData(); | 1231 layerTree->property_trees()->ResetCachedData(); |
1232 } | 1232 } |
1233 | 1233 |
1234 #ifndef NDEBUG | 1234 #ifndef NDEBUG |
1235 void PaintArtifactCompositor::showDebugData() { | 1235 void PaintArtifactCompositor::showDebugData() { |
1236 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo) | 1236 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo) |
1237 ->toPrettyJSONString() | 1237 ->toPrettyJSONString() |
1238 .utf8() | 1238 .utf8() |
1239 .data(); | 1239 .data(); |
1240 } | 1240 } |
1241 #endif | 1241 #endif |
1242 | 1242 |
1243 } // namespace blink | 1243 } // namespace blink |
OLD | NEW |