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

Skip whole RunPaintLifecyclePhase when printing or painting preview

Change-Id: I6fdca5b9b5ebde0af04fb8dbdc6aa524ac8e5255
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2548140Reviewed-by: default avatarStefan Zager <szager@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829262}
parent 116a68e5
...@@ -2786,11 +2786,10 @@ void LocalFrameView::RunPaintLifecyclePhase(PaintBenchmarkMode benchmark_mode) { ...@@ -2786,11 +2786,10 @@ void LocalFrameView::RunPaintLifecyclePhase(PaintBenchmarkMode benchmark_mode) {
// While printing or capturing a paint preview of a document, the paint walk // While printing or capturing a paint preview of a document, the paint walk
// is done into a special canvas. There is no point doing a normal paint step // is done into a special canvas. There is no point doing a normal paint step
// (or animations update) when in this mode. // (or animations update) when in this mode.
bool is_capturing_layout = if (frame_->GetDocument()->IsPrintingOrPaintingPreview())
frame_->GetDocument()->IsPrintingOrPaintingPreview(); return;
bool repainted = false;
if (!is_capturing_layout) bool repainted = PaintTree(benchmark_mode);
repainted = PaintTree(benchmark_mode);
if (benchmark_mode == if (benchmark_mode ==
PaintBenchmarkMode::kForcePaintArtifactCompositorUpdate || PaintBenchmarkMode::kForcePaintArtifactCompositorUpdate ||
...@@ -2801,79 +2800,74 @@ void LocalFrameView::RunPaintLifecyclePhase(PaintBenchmarkMode benchmark_mode) { ...@@ -2801,79 +2800,74 @@ void LocalFrameView::RunPaintLifecyclePhase(PaintBenchmarkMode benchmark_mode) {
paint_artifact_compositor_->SetNeedsUpdate(); paint_artifact_compositor_->SetNeedsUpdate();
} }
if (!is_capturing_layout) { bool needed_update =
bool needed_update = !paint_artifact_compositor_ || !paint_artifact_compositor_ || paint_artifact_compositor_->NeedsUpdate();
paint_artifact_compositor_->NeedsUpdate(); PushPaintArtifactToCompositor(repainted);
PushPaintArtifactToCompositor(repainted); size_t total_animations_count = 0;
size_t total_animations_count = 0; bool current_frame_had_raf = false;
bool current_frame_had_raf = false; bool next_frame_has_pending_raf = false;
bool next_frame_has_pending_raf = false; ForAllNonThrottledLocalFrameViews(
ForAllNonThrottledLocalFrameViews([this, &total_animations_count, [this, &total_animations_count, &current_frame_had_raf,
&current_frame_had_raf, &next_frame_has_pending_raf](LocalFrameView& frame_view) {
&next_frame_has_pending_raf]( if (auto* scrollable_area = frame_view.GetScrollableArea())
LocalFrameView& frame_view) { scrollable_area->UpdateCompositorScrollAnimations();
if (auto* scrollable_area = frame_view.GetScrollableArea()) if (const auto* animating_scrollable_areas =
scrollable_area->UpdateCompositorScrollAnimations(); frame_view.AnimatingScrollableAreas()) {
if (const auto* animating_scrollable_areas = for (PaintLayerScrollableArea* area : *animating_scrollable_areas)
frame_view.AnimatingScrollableAreas()) { area->UpdateCompositorScrollAnimations();
for (PaintLayerScrollableArea* area : *animating_scrollable_areas) }
area->UpdateCompositorScrollAnimations(); frame_view.GetLayoutView()
} ->GetDocument()
frame_view.GetLayoutView() .GetDocumentAnimations()
->GetDocument() .UpdateAnimations(DocumentLifecycle::kPaintClean,
.GetDocumentAnimations() paint_artifact_compositor_.get());
.UpdateAnimations(DocumentLifecycle::kPaintClean, Document& document = frame_view.GetLayoutView()->GetDocument();
paint_artifact_compositor_.get()); total_animations_count +=
Document& document = frame_view.GetLayoutView()->GetDocument(); document.GetDocumentAnimations().GetAnimationsCount();
total_animations_count += current_frame_had_raf |= document.CurrentFrameHadRAF();
document.GetDocumentAnimations().GetAnimationsCount(); next_frame_has_pending_raf |= document.NextFrameHasPendingRAF();
current_frame_had_raf |= document.CurrentFrameHadRAF(); });
next_frame_has_pending_raf |= document.NextFrameHasPendingRAF();
});
if (GetLayoutView()->GetDocument().View() &&
GetLayoutView()->GetDocument().View()->GetCompositorAnimationHost()) {
GetLayoutView()
->GetDocument()
.View()
->GetCompositorAnimationHost()
->SetAnimationCounts(total_animations_count, current_frame_had_raf,
next_frame_has_pending_raf);
}
// Initialize animation properties in the newly created paint property if (GetLayoutView()->GetDocument().View() &&
// nodes according to the current animation state. This is mainly for GetLayoutView()->GetDocument().View()->GetCompositorAnimationHost()) {
// the running composited animations which didn't change state during GetLayoutView()
// above UpdateAnimations() but associated with new paint property nodes. ->GetDocument()
if (needed_update) { .View()
auto* root_layer = RootCcLayer(); ->GetCompositorAnimationHost()
if (root_layer && root_layer->layer_tree_host()) { ->SetAnimationCounts(total_animations_count, current_frame_had_raf,
root_layer->layer_tree_host() next_frame_has_pending_raf);
->mutator_host() }
->InitClientAnimationState();
} // Initialize animation properties in the newly created paint property
// nodes according to the current animation state. This is mainly for
// the running composited animations which didn't change state during
// above UpdateAnimations() but associated with new paint property nodes.
if (needed_update) {
auto* root_layer = RootCcLayer();
if (root_layer && root_layer->layer_tree_host()) {
root_layer->layer_tree_host()->mutator_host()->InitClientAnimationState();
} }
}
// Notify the controller that the artifact has been pushed and some // Notify the controller that the artifact has been pushed and some
// lifecycle state can be freed (such as raster invalidations). // lifecycle state can be freed (such as raster invalidations).
if (paint_controller_) if (paint_controller_)
paint_controller_->FinishCycle(); paint_controller_->FinishCycle();
if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) {
auto* root = GetLayoutView()->Compositor()->PaintRootGraphicsLayer(); auto* root = GetLayoutView()->Compositor()->PaintRootGraphicsLayer();
if (root) { if (root) {
ForAllPaintingGraphicsLayers(*root, [](GraphicsLayer& layer) { ForAllPaintingGraphicsLayers(*root, [](GraphicsLayer& layer) {
// Notify the paint controller that the artifact has been pushed and // Notify the paint controller that the artifact has been pushed and
// some lifecycle state can be freed (such as raster invalidations). // some lifecycle state can be freed (such as raster invalidations).
layer.GetPaintController().FinishCycle(); layer.GetPaintController().FinishCycle();
}); });
}
} }
if (paint_artifact_compositor_)
paint_artifact_compositor_->ClearPropertyTreeChangedState();
} }
if (paint_artifact_compositor_)
paint_artifact_compositor_->ClearPropertyTreeChangedState();
if (GetPage()) if (GetPage())
GetPage()->Animator().ReportFrameAnimations(GetCompositorAnimationHost()); GetPage()->Animator().ReportFrameAnimations(GetCompositorAnimationHost());
} }
......
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