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

Unified Diff: third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp

Issue 2795263002: Add a new document lifecycle; CompositingInputsClean (Closed)
Patch Set: Rebase Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp
diff --git a/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp b/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp
index ed65ace449e1ab71562bb3a998ee1a51318da56b..5bd2202e29af58b6b0d83f6cc720535872bd2d03 100644
--- a/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp
@@ -184,12 +184,16 @@ static LayoutVideo* FindFullscreenVideoLayoutObject(Document& document) {
return ToLayoutVideo(layout_object);
}
-void PaintLayerCompositor::UpdateIfNeededRecursive() {
+void PaintLayerCompositor::UpdateIfNeededRecursive(
+ DocumentLifecycle::LifecycleState target_state) {
SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.Compositing.UpdateTime");
- UpdateIfNeededRecursiveInternal();
+ UpdateIfNeededRecursiveInternal(target_state);
}
-void PaintLayerCompositor::UpdateIfNeededRecursiveInternal() {
+void PaintLayerCompositor::UpdateIfNeededRecursiveInternal(
+ DocumentLifecycle::LifecycleState target_state) {
+ DCHECK(target_state >= DocumentLifecycle::kCompositingInputsClean);
+
FrameView* view = layout_view_.GetFrameView();
if (view->ShouldThrottleRendering())
return;
@@ -205,10 +209,11 @@ void PaintLayerCompositor::UpdateIfNeededRecursiveInternal() {
// the middle of frame detach.
// TODO(bbudge) Remove this check when trusted Pepper plugins are gone.
if (local_frame->GetDocument()->IsActive() &&
- !local_frame->ContentLayoutItem().IsNull())
+ !local_frame->ContentLayoutItem().IsNull()) {
local_frame->ContentLayoutItem()
.Compositor()
- ->UpdateIfNeededRecursiveInternal();
+ ->UpdateIfNeededRecursiveInternal(target_state);
+ }
}
TRACE_EVENT0("blink", "PaintLayerCompositor::updateIfNeededRecursive");
@@ -226,9 +231,11 @@ void PaintLayerCompositor::UpdateIfNeededRecursiveInternal() {
layout_view_.CommitPendingSelection();
- Lifecycle().AdvanceTo(DocumentLifecycle::kInCompositingUpdate);
- UpdateIfNeeded();
- Lifecycle().AdvanceTo(DocumentLifecycle::kCompositingClean);
+ UpdateIfNeeded(target_state);
+ DCHECK(Lifecycle().GetState() == DocumentLifecycle::kCompositingInputsClean ||
+ Lifecycle().GetState() == DocumentLifecycle::kCompositingClean);
+ if (target_state == DocumentLifecycle::kCompositingInputsClean)
+ return;
Optional<CompositorElementIdSet> composited_element_ids;
DocumentAnimations::UpdateAnimations(layout_view_.GetDocument(),
@@ -371,17 +378,36 @@ GraphicsLayer* PaintLayerCompositor::ParentForContentLayers() const {
return IsMainFrame() ? GetVisualViewport().ScrollLayer() : nullptr;
}
-void PaintLayerCompositor::UpdateIfNeeded() {
+void PaintLayerCompositor::UpdateIfNeeded(
+ DocumentLifecycle::LifecycleState target_state) {
+ DCHECK(target_state >= DocumentLifecycle::kCompositingInputsClean);
+
+ Lifecycle().AdvanceTo(DocumentLifecycle::kInCompositingUpdate);
+
+ if (pending_update_type_ < kCompositingUpdateAfterCompositingInputChange &&
+ target_state == DocumentLifecycle::kCompositingInputsClean) {
+ // The compositing inputs are already clean and that is our target state.
+ // Early-exit here without clearing the pending update type since we haven't
+ // handled e.g. geometry updates.
+ Lifecycle().AdvanceTo(DocumentLifecycle::kCompositingInputsClean);
+ return;
+ }
+
CompositingUpdateType update_type = pending_update_type_;
pending_update_type_ = kCompositingUpdateNone;
if (!HasAcceleratedCompositing()) {
UpdateWithoutAcceleratedCompositing(update_type);
+ Lifecycle().AdvanceTo(
+ std::min(DocumentLifecycle::kCompositingClean, target_state));
return;
}
- if (update_type == kCompositingUpdateNone)
+ if (update_type == kCompositingUpdateNone) {
+ Lifecycle().AdvanceTo(
+ std::min(DocumentLifecycle::kCompositingClean, target_state));
return;
+ }
PaintLayer* update_root = RootLayer();
@@ -396,6 +422,16 @@ void PaintLayerCompositor::UpdateIfNeeded() {
update_root);
#endif
+ // In the case where we only want to make compositing inputs clean, we
+ // early-exit here. Because we have not handled the other implications of
+ // |pending_update_type_| > kCompositingUpdateNone, we must restore the
+ // pending update type for a future call.
+ if (target_state == DocumentLifecycle::kCompositingInputsClean) {
+ pending_update_type_ = update_type;
+ Lifecycle().AdvanceTo(DocumentLifecycle::kCompositingInputsClean);
+ return;
+ }
+
CompositingRequirementsUpdater(layout_view_, compositing_reason_finder_)
.Update(update_root);
@@ -490,6 +526,8 @@ void PaintLayerCompositor::UpdateIfNeeded() {
// Inform the inspector that the layer tree has changed.
if (IsMainFrame())
probe::layerTreeDidChange(layout_view_.GetFrame());
+
+ Lifecycle().AdvanceTo(DocumentLifecycle::kCompositingClean);
}
static void RestartAnimationOnCompositor(const LayoutObject& layout_object) {

Powered by Google App Engine
This is Rietveld 408576698