Commit 715567f6 authored by Philip Rogers's avatar Philip Rogers Committed by Commit Bot

Move PaintController::FinishCycle to the end of paint

PaintController::FinishCycle needs to be called after committing
display items and is used to free state such as raster invalidations.
The call to FinishCycle from GraphicsLayer::PaintRecursively has been
moved to LocalFrameView::RunPaintLifecyclePhase. This makes the
CompositeAfterPaint (CAP) and pre-CAP code more similar, as FinishCycle
is always called at the end of RunPaintLifecyclePhase. This approach is
needed for CompositeSVG (see: https://crrev.com/c/2250514) which needs
to delay raster invalidation until after PaintArtifactCompositor
updates (like CAP).

Bug: 1101002
Change-Id: I41fc782a0f9f2ca5e3fcd0fe55d9e12bcc643528
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2287813Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786369}
parent cb33270c
...@@ -2687,6 +2687,9 @@ void LocalFrameView::RunPaintLifecyclePhase() { ...@@ -2687,6 +2687,9 @@ void LocalFrameView::RunPaintLifecyclePhase() {
if (root) { if (root) {
ForAllGraphicsLayers(*root, [](GraphicsLayer& layer) { ForAllGraphicsLayers(*root, [](GraphicsLayer& layer) {
if (layer.PaintsContentOrHitTest() && layer.HasLayerState()) { if (layer.PaintsContentOrHitTest() && layer.HasLayerState()) {
// Notify the paint controller that the artifact has been pushed and
// some lifecycle state can be freed (such as raster invalidations).
layer.GetPaintController().FinishCycle();
layer.GetPaintController().ClearPropertyTreeChangedStateTo( layer.GetPaintController().ClearPropertyTreeChangedStateTo(
layer.GetPropertyTreeState()); layer.GetPropertyTreeState());
} }
......
...@@ -265,38 +265,23 @@ IntRect GraphicsLayer::InterestRect() { ...@@ -265,38 +265,23 @@ IntRect GraphicsLayer::InterestRect() {
} }
bool GraphicsLayer::PaintRecursively() { bool GraphicsLayer::PaintRecursively() {
Vector<GraphicsLayer*> repainted_layers;
PaintRecursivelyInternal(repainted_layers);
// Notify the controllers that the artifact has been pushed and some
// lifecycle state can be freed (such as raster invalidations).
for (auto* layer : repainted_layers) {
#if DCHECK_IS_ON()
if (VLOG_IS_ON(2))
LOG(ERROR) << "FinishCycle for GraphicsLayer: " << layer->DebugName();
#endif
layer->GetPaintController().FinishCycle();
}
return !repainted_layers.IsEmpty();
}
void GraphicsLayer::PaintRecursivelyInternal(
Vector<GraphicsLayer*>& repainted_layers) {
// TODO(crbug.com/1033240): Debugging information for the referenced bug. // TODO(crbug.com/1033240): Debugging information for the referenced bug.
// Remove when it is fixed. // Remove when it is fixed.
CHECK(&client_); CHECK(&client_);
if (client_.PaintBlockedByDisplayLockIncludingAncestors( if (client_.PaintBlockedByDisplayLockIncludingAncestors(
DisplayLockContextLifecycleTarget::kSelf)) { DisplayLockContextLifecycleTarget::kSelf)) {
return; return false;
} }
bool painted = false;
if (PaintsContentOrHitTest()) { if (PaintsContentOrHitTest()) {
if (Paint()) if (Paint())
repainted_layers.push_back(this); painted = true;
} }
for (auto* child : Children()) for (auto* child : Children())
child->PaintRecursivelyInternal(repainted_layers); painted |= child->PaintRecursively();
return painted;
} }
bool GraphicsLayer::Paint() { bool GraphicsLayer::Paint() {
......
...@@ -184,6 +184,7 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient, ...@@ -184,6 +184,7 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient,
PaintInvalidationReason); PaintInvalidationReason);
IntRect InterestRect(); IntRect InterestRect();
// Returns true if this or any descendant is repainted.
bool PaintRecursively(); bool PaintRecursively();
// Returns true if this layer is repainted. // Returns true if this layer is repainted.
bool Paint(); bool Paint();
...@@ -246,7 +247,6 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient, ...@@ -246,7 +247,6 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient,
bool FillsBoundsCompletely() const override { return false; } bool FillsBoundsCompletely() const override { return false; }
size_t GetApproximateUnsharedMemoryUsage() const final; size_t GetApproximateUnsharedMemoryUsage() const final;
void PaintRecursivelyInternal(Vector<GraphicsLayer*>& repainted_layers);
void UpdateSafeOpaqueBackgroundColor(); void UpdateSafeOpaqueBackgroundColor();
// Returns true if PaintController::PaintArtifact() changed and needs commit. // Returns true if PaintController::PaintArtifact() changed and needs commit.
......
...@@ -132,6 +132,7 @@ TEST_P(GraphicsLayerTest, PaintRecursively) { ...@@ -132,6 +132,7 @@ TEST_P(GraphicsLayerTest, PaintRecursively) {
transform_root)); transform_root));
layers_.graphics_layer_client().SetNeedsRepaint(true); layers_.graphics_layer_client().SetNeedsRepaint(true);
layers_.graphics_layer().PaintRecursively(); layers_.graphics_layer().PaintRecursively();
layers_.graphics_layer().GetPaintController().FinishCycle();
} }
TEST_P(GraphicsLayerTest, SetDrawsContentFalse) { TEST_P(GraphicsLayerTest, SetDrawsContentFalse) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment