Commit f20bcf6a authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Invalidate GraphicsLayer::CcLayer() when switching "create layers after paint"

When we switch on "create layers after paint" and back, the contents of
the original GraphicsLayer::CcLayer() and RasterInvalidator which are
not used during "create layers after paint" may not be valid.
Invalidate them to ensure correct rendering.

Bug: 1132218
Change-Id: Ia717e8202e2627cedbc9e5305619223a5a833f47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2432766Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811013}
parent 0175c35a
...@@ -320,15 +320,29 @@ bool GraphicsLayer::Paint() { ...@@ -320,15 +320,29 @@ bool GraphicsLayer::Paint() {
} }
void GraphicsLayer::UpdateShouldCreateLayersAfterPaint() { void GraphicsLayer::UpdateShouldCreateLayersAfterPaint() {
should_create_layers_after_paint_ = false; bool new_create_layers_after_paint = ComputeShouldCreateLayersAfterPaint();
if (new_create_layers_after_paint != should_create_layers_after_paint_) {
should_create_layers_after_paint_ = new_create_layers_after_paint;
// Depending on |should_create_layers_after_paint_|, raster invalidation
// will happen in via two different code paths. When it changes we need to
// fully invalidate because the incremental raster invalidations of these
// code paths will not work. Nor calling this->SetNeedsDisplay() because it
// will also clear PaintController which contains what we have just painted.
CcLayer().SetNeedsDisplay();
if (raster_invalidator_)
raster_invalidator_->ClearOldStates();
}
}
bool GraphicsLayer::ComputeShouldCreateLayersAfterPaint() const {
if (!RuntimeEnabledFeatures::CompositeSVGEnabled()) if (!RuntimeEnabledFeatures::CompositeSVGEnabled())
return; return false;
if (!PaintsContentOrHitTest()) if (!PaintsContentOrHitTest())
return; return false;
// Only layerize content under SVG for now. This requires that the SVG root // Only layerize content under SVG for now. This requires that the SVG root
// has a GraphicsLayer. // has a GraphicsLayer.
if (!client_.IsSVGRoot()) if (!client_.IsSVGRoot())
return; return false;
const PaintChunkSubset paint_chunks = const PaintChunkSubset paint_chunks =
PaintChunkSubset(GetPaintController().PaintChunks()); PaintChunkSubset(GetPaintController().PaintChunks());
for (const auto& paint_chunk : paint_chunks) { for (const auto& paint_chunk : paint_chunks) {
...@@ -337,11 +351,10 @@ void GraphicsLayer::UpdateShouldCreateLayersAfterPaint() { ...@@ -337,11 +351,10 @@ void GraphicsLayer::UpdateShouldCreateLayersAfterPaint() {
continue; continue;
// TODO(pdr): Check for direct compositing reasons along the chain from // TODO(pdr): Check for direct compositing reasons along the chain from
// this state to the layer state. // this state to the layer state.
if (chunk_state.HasDirectCompositingReasons()) { if (chunk_state.HasDirectCompositingReasons())
should_create_layers_after_paint_ = true; return true;
return;
}
} }
return false;
} }
bool GraphicsLayer::PaintWithoutCommitForTesting( bool GraphicsLayer::PaintWithoutCommitForTesting(
......
...@@ -246,6 +246,7 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient, ...@@ -246,6 +246,7 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient,
size_t GetApproximateUnsharedMemoryUsage() const final; size_t GetApproximateUnsharedMemoryUsage() const final;
void UpdateShouldCreateLayersAfterPaint(); void UpdateShouldCreateLayersAfterPaint();
bool ComputeShouldCreateLayersAfterPaint() const;
// Returns true if PaintController::PaintArtifact() changed and needs commit. // Returns true if PaintController::PaintArtifact() changed and needs commit.
bool PaintWithoutCommit(const IntRect* interest_rect = nullptr); bool PaintWithoutCommit(const IntRect* interest_rect = nullptr);
......
<!DOCTYPE html>
<div style="width: 200px; height: 200px; background: green"></div>
<!DOCTYPE html>
<html class="reftest-wait">
<link rel="match" href="svg-child-will-change-transform-invalidation-ref.html">
<svg id="svg" viewBox="0 0 100 100" style="width: 200px; height: 200px; transform: translateZ(0)">
<rect id="rect" width="100%" height="100%" fill="red"/>
</svg>
<script src="/common/reftest-wait.js"></script>
<script src="/common/rendering-utils.js"></script>
<script>
waitForAtLeastOneFrame().then(() => {
rect.style.willChange = 'transform';
waitForAtLeastOneFrame().then(() => {
rect.setAttribute("fill", "green");
waitForAtLeastOneFrame().then(() => {
rect.style.willChange = 'initial';
takeScreenshot();
});
});
});
</script>
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