Commit 93f946c0 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

[Fast compositing] Force compositing requirements update on change of stacking order.

Bug: 855117

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I730e489bf6880252ce5474551e4c624d9baa18d7
Reviewed-on: https://chromium-review.googlesource.com/1112704Reviewed-by: default avatarTien-Ren Chen <trchen@chromium.org>
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569964}
parent cea7267b
<!doctype HTML>
<!-- Removing the will-change: transform on #target wil cause the canvas
to not be stacked, which means that it paints as a child of #reparent.
This exercises changing of stacking parent chain of a composited layer, at the
same time as becoming not composited.
Test passes if it does not crash. -->
<div id=reparent style="position: relative; overflow: hidden">
<canvas id=target style='width:10px; height: 10px; will-change: transform'>
hi
</canvas>
</div>
<iframe id=iframe></iframe>
<script>
if (window.testRunner) {
window.testRunner.waitUntilDone();
window.testRunner.dumpAsText();
}
onload = () => requestAnimationFrame(append);
function append() {
iframe.contentDocument.documentElement.appendChild(reparent);
requestAnimationFrame(removeStacking);
}
function removeStacking() {
iframe.contentDocument.querySelector("#target").style.willChange = '';
if (window.testRunner)
window.testRunner.notifyDone();
}
</script>
...@@ -414,12 +414,15 @@ void CompositingRequirementsUpdater::UpdateRecursive( ...@@ -414,12 +414,15 @@ void CompositingRequirementsUpdater::UpdateRecursive(
// * may have their own reason for compositing, // * may have their own reason for compositing,
// * have compositing already from the previous frame, or // * have compositing already from the previous frame, or
// * may escape |layer|'s clip. // * may escape |layer|'s clip.
// * may need compositing requirements update for another reason (
// e.g. change of stacking order)
bool skip_children = bool skip_children =
!layer->DescendantHasDirectOrScrollingCompositingReason() && !layer->DescendantHasDirectOrScrollingCompositingReason() &&
!needs_recursion_for_composited_scrolling_plus_fixed_or_sticky && !needs_recursion_for_composited_scrolling_plus_fixed_or_sticky &&
!needs_recursion_for_out_of_flow_descendant && !needs_recursion_for_out_of_flow_descendant &&
layer->GetLayoutObject().HasOverflowClip() && layer->GetLayoutObject().HasOverflowClip() &&
!layer->HasCompositingDescendant(); !layer->HasCompositingDescendant() &&
!layer->DescendantMayNeedCompositingRequirementsUpdate();
if (!skip_children && layer->StackingNode()->IsStackingContext()) { if (!skip_children && layer->StackingNode()->IsStackingContext()) {
PaintLayerStackingNodeIterator iterator(*layer->StackingNode(), PaintLayerStackingNodeIterator iterator(*layer->StackingNode(),
...@@ -607,6 +610,7 @@ void CompositingRequirementsUpdater::UpdateRecursive( ...@@ -607,6 +610,7 @@ void CompositingRequirementsUpdater::UpdateRecursive(
// At this point we have finished collecting all reasons to composite this // At this point we have finished collecting all reasons to composite this
// layer. // layer.
layer->SetCompositingReasons(reasons_to_composite); layer->SetCompositingReasons(reasons_to_composite);
layer->ClearNeedsCompositingRequirementsUpdate();
if (reasons_to_composite & CompositingReason::kOverlap) if (reasons_to_composite & CompositingReason::kOverlap)
compositing_reasons_stats.overlap_layers++; compositing_reasons_stats.overlap_layers++;
if (reasons_to_composite & CompositingReason::kComboActiveAnimation) if (reasons_to_composite & CompositingReason::kComboActiveAnimation)
......
...@@ -105,9 +105,7 @@ static CompositingQueryMode g_compositing_query_mode = ...@@ -105,9 +105,7 @@ static CompositingQueryMode g_compositing_query_mode =
struct SameSizeAsPaintLayer : DisplayItemClient { struct SameSizeAsPaintLayer : DisplayItemClient {
int bit_fields; int bit_fields;
#if DCHECK_IS_ON()
int bit_fields2; int bit_fields2;
#endif
void* pointers[11]; void* pointers[11];
LayoutUnit layout_units[4]; LayoutUnit layout_units[4];
IntSize size; IntSize size;
...@@ -172,6 +170,7 @@ PaintLayer::PaintLayer(LayoutBoxModelObject& layout_object) ...@@ -172,6 +170,7 @@ PaintLayer::PaintLayer(LayoutBoxModelObject& layout_object)
is_under_svg_hidden_container_(false), is_under_svg_hidden_container_(false),
descendant_has_direct_or_scrolling_compositing_reason_(false), descendant_has_direct_or_scrolling_compositing_reason_(false),
needs_compositing_reasons_update_(true), needs_compositing_reasons_update_(true),
descendant_may_need_compositing_requirements_update_(false),
layout_object_(layout_object), layout_object_(layout_object),
parent_(nullptr), parent_(nullptr),
previous_(nullptr), previous_(nullptr),
...@@ -1382,6 +1381,9 @@ void PaintLayer::AddChild(PaintLayer* child, PaintLayer* before_child) { ...@@ -1382,6 +1381,9 @@ void PaintLayer::AddChild(PaintLayer* child, PaintLayer* before_child) {
MarkAncestorChainForDescendantDependentFlagsUpdate(); MarkAncestorChainForDescendantDependentFlagsUpdate();
DirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); DirtyAncestorChainHasSelfPaintingLayerDescendantStatus();
// Need to force requirements update, due to change of stacking order.
SetNeedsCompositingRequirementsUpdate();
child->SetNeedsRepaint(); child->SetNeedsRepaint();
} }
...@@ -2326,6 +2328,14 @@ bool PaintLayer::IsReplacedNormalFlowStacking() { ...@@ -2326,6 +2328,14 @@ bool PaintLayer::IsReplacedNormalFlowStacking() {
return true; return true;
} }
void PaintLayer::SetNeedsCompositingRequirementsUpdate() {
for (PaintLayer* curr = Parent();
curr && !curr->DescendantMayNeedCompositingRequirementsUpdate();
curr = curr->Parent()) {
curr->descendant_may_need_compositing_requirements_update_ = true;
}
}
PaintLayer* PaintLayer::HitTestChildren( PaintLayer* PaintLayer::HitTestChildren(
ChildrenIteration childrento_visit, ChildrenIteration childrento_visit,
PaintLayer* root_layer, PaintLayer* root_layer,
......
...@@ -1027,6 +1027,14 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient { ...@@ -1027,6 +1027,14 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient {
descendant_has_direct_or_scrolling_compositing_reason_ = value; descendant_has_direct_or_scrolling_compositing_reason_ = value;
} }
void SetNeedsCompositingRequirementsUpdate();
void ClearNeedsCompositingRequirementsUpdate() {
descendant_may_need_compositing_requirements_update_ = false;
}
bool DescendantMayNeedCompositingRequirementsUpdate() const {
return descendant_may_need_compositing_requirements_update_;
}
ClipRectsCache* GetClipRectsCache() const { return clip_rects_cache_.get(); } ClipRectsCache* GetClipRectsCache() const { return clip_rects_cache_.get(); }
ClipRectsCache& EnsureClipRectsCache() const { ClipRectsCache& EnsureClipRectsCache() const {
if (!clip_rects_cache_) if (!clip_rects_cache_)
...@@ -1302,6 +1310,8 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient { ...@@ -1302,6 +1310,8 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient {
unsigned descendant_has_direct_or_scrolling_compositing_reason_ : 1; unsigned descendant_has_direct_or_scrolling_compositing_reason_ : 1;
unsigned needs_compositing_reasons_update_ : 1; unsigned needs_compositing_reasons_update_ : 1;
unsigned descendant_may_need_compositing_requirements_update_ : 1;
LayoutBoxModelObject& layout_object_; LayoutBoxModelObject& layout_object_;
PaintLayer* parent_; PaintLayer* parent_;
......
...@@ -244,6 +244,8 @@ void PaintLayerStackingNode::StyleDidChange(const ComputedStyle* old_style) { ...@@ -244,6 +244,8 @@ void PaintLayerStackingNode::StyleDidChange(const ComputedStyle* old_style) {
is_stacked_ == should_be_stacked && old_z_index == ZIndex()) is_stacked_ == should_be_stacked && old_z_index == ZIndex())
return; return;
// Need to force requirements update, due to change of stacking order.
Layer()->SetNeedsCompositingRequirementsUpdate();
DirtyStackingContextZOrderLists(); DirtyStackingContextZOrderLists();
if (is_stacking_context) if (is_stacking_context)
......
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