Commit 38825770 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

[PE] Rationalize compositing triggers.

* Compute all triggers except kComboSquashableReasons, kComboCompositedDescendants
and kComboAllCompositedScrollingDeterminedReasons in either style update or
CompositingInputsUpdater.
* Determine composited scrolling (but not the compositing trigger bit) in CompositingInputsUpdater.
* Cache these results on PaintLayer.

This achieves the following goals:
- Separates composited scrolling and awkward LCD text decisions from
the CompositingRequirementsUpdater step.
- Caches more triggers, leading to faster compositing updates in some cases
- Unblocks CL 1072155

Summary of implementation approach:

1. Dirty compositing inputs for all triggers computed there.
2. Compute, and cache on PaintLayer, kComboAllDirectNonStyleDeterminedReasons during
CompositingInputsUpdater.
3. Compute and cache a new DescendantHasDirectCompositingReason dirty bit on PaintLayer.
4. Update composited scrolling in PaintLayerScrollableArea during CompositingInputsUpdater.
This includes the root layer, which uses DescendantHasDirectCompositingReason as one of its
triggers.

Bug:814439,782991

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I21095762cbf806008395c2cf79f4ee038c39cb5f
Reviewed-on: https://chromium-review.googlesource.com/1087791
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarTien-Ren Chen <trchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565925}
parent 1b62d187
......@@ -6,6 +6,7 @@
#include "third_party/blink/renderer/core/layout/layout_box.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
namespace blink {
......@@ -161,6 +162,9 @@ void ScrollTimeline::AttachAnimation() {
.GetLayoutView()
->Compositor()
->SetNeedsCompositingUpdate(kCompositingUpdateRebuildTree);
LayoutBoxModelObject* object = scroll_source_->GetLayoutBoxModelObject();
if (object && object->HasLayer())
object->Layer()->SetNeedsCompositingInputsUpdate();
}
void ScrollTimeline::DetachAnimation() {
......@@ -169,6 +173,10 @@ void ScrollTimeline::DetachAnimation() {
if (layout_view && layout_view->Compositor()) {
layout_view->Compositor()->SetNeedsCompositingUpdate(
kCompositingUpdateRebuildTree);
LayoutBoxModelObject* object = scroll_source_->GetLayoutBoxModelObject();
if (object && object->HasLayer())
object->Layer()->SetNeedsCompositingInputsUpdate();
}
}
......
......@@ -45,6 +45,7 @@
#include "third_party/blink/renderer/core/loader/frame_loader.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/page/scrolling/root_scroller_controller.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/timing/dom_window_performance.h"
#include "third_party/blink/renderer/core/timing/window_performance.h"
#include "third_party/blink/renderer/platform/heap/heap_allocator.h"
......@@ -174,6 +175,10 @@ void HTMLFrameOwnerElement::SetContentFrame(Frame& frame) {
content_frame_ = &frame;
// Invalidate compositing inputs, because a remote frame child can cause the
// owner to become composited.
if (auto* box = GetLayoutBox())
box->Layer()->SetNeedsCompositingInputsUpdate();
SetNeedsStyleRecalc(kLocalStyleChange, StyleChangeReasonForTracing::Create(
StyleChangeReason::kFrame));
......
......@@ -197,6 +197,27 @@ void RootScrollerController::RecomputeEffectiveRootScroller() {
Node* old_effective_root_scroller = effective_root_scroller_;
effective_root_scroller_ = new_effective_root_scroller;
if (new_effective_root_scroller != old_effective_root_scroller) {
if (LayoutBoxModelObject* new_obj =
new_effective_root_scroller->GetLayoutBoxModelObject()) {
if (new_obj->Layer()) {
new_effective_root_scroller->GetLayoutBoxModelObject()
->Layer()
->SetNeedsCompositingInputsUpdate();
}
}
if (old_effective_root_scroller) {
if (LayoutBoxModelObject* old_obj =
old_effective_root_scroller->GetLayoutBoxModelObject()) {
if (old_obj->Layer()) {
old_effective_root_scroller->GetLayoutBoxModelObject()
->Layer()
->SetNeedsCompositingInputsUpdate();
}
}
}
}
ApplyRootScrollerProperties(*old_effective_root_scroller);
ApplyRootScrollerProperties(*effective_root_scroller_);
......
......@@ -167,6 +167,79 @@ from layout
v
```
#### SPv1 compositing algorithm
The SPv1 compositing system chooses which `LayoutObject`s paint into their
own composited backing texture. This is called "having a compositing trigger".
These textures correspond to GraphicsLayers. There are also additional
`GraphicsLayer`s which represent property tree-related effects.
All elements which do not have a compositing trigger paint into the texture
of the nearest `LayoutObject`with a compositing trigger on its
*compositing container chain* (except for squashed layers; see below). For
historical, practical and implementation detail reasons, only `LayoutObject`s
with `PaintLayer`s can have a compositing trigger. See crbug.com/370604 for a
bug tracking this limitation, which is often referred to as the "fundamental
compositing bug".
The various compositing triggers are listed
[here](../../platform/graphics/compositing_reasons.h).
They fall in to several categories:
1. Direct reasons due to CSS style (see `CompositingReason::kComboAllDirectStyleDeterminedReasons`)
2. Direct reasons due to other conditions (see `CompositingReason::kComboAllDirectNonStyleDeterminedReasons`)
3. Composited scrolling-dependent reasons (see `CompositingReason::kComboAllCompositedScrollingDeterminedReasons`)
4. Composited descendant-dependent reasons (see `CompositingReason::kComboCompositedDescendants`)
5. Overlap-dependent reasons (See `CompositingReasons::kComboSquashableReasons`)
The triggers have no effect unless `PaintLayerCompositor::CanBeComposited`
returns true.
Category (1) always triggers compositing of a `LayoutObject` based on its own
style. Category (2) triggers based on the `LayoutObject`'s style, its DOM
ancestors, and whether it is a certain kind of frame root. Category (3)
triggers based on whether composited scrolling applies to the `LayoutObject`,
or the `LayoutObject` moves relative to a composited scroller (position: fixed
or position: sticky). Category (4) triggers if there are any stacking
descendants of the `LayoutObject` that end up composited. Category 5 triggers
if the `LayoutObject` paints after and overlaps (or may overlap) another
composited layer.
Note that composited scrolling is special. Several ways it is special:
* Composited descendants do _not_ necessarily cause composited scrolling of an
ancestor.
* The presence of LCD text prevents composited scrolling in the
absence of other overriding triggers.
* Local frame roots always use
composited scrolling if they have overflow.
* Non-local frame roots use
composited scrolling if they have overflow and any composited descendants.
* Composited scrolling is indicated by a bit on PaintLayerScrollableArea, not
a direct compositing reason. This bit is then transformed into a compositing
reason from category (3) during the CompositingRequirementsUpdater
Note that overlap triggers have two special behaviors:
* Any `LayoutObject`
which may overlap a `LayoutObject` that uses composited scrolling or a
transform animation, paints after it, and scrolls with respect to it, receives
an overlap trigger. In some cases this trigger is too aggressive.
* Inline CSS
transform is treated as if it was a transform animation. (This is a heuristic
to speed up the compositing step but leads to more composited layers.)
The sequence of work during the `DocumentLifecycle` to compute these triggers
is as follows:
* `kInStyleRecalc`: compute (1) and most of (4) by calling
`CompositingReasonFinder::PotentialCompositingReasonsFromStyle` and caching
the result on `PaintLayer`, accessible via
`PaintLayer::PotentialCompositingReasonsFromStyle`. Dirty bits in
`StyleDifference` determine whether this has to be re-computed on a particular
lifecycle update.
* `kInCompositingUpdate`: compute (2) `CompositingInputsUpdater`. Also
set the composited scrolling bit on `PaintLayerScrollableArea` if applicable.
* `kCompositingInputsClean`: compute (3), the rest of (4), and (5), in
`CompositingRequirementsUpdater`
### BlinkGenPropertyTrees
This mode is for incrementally shipping completed features from SPv2. It is
......@@ -325,7 +398,7 @@ is created for the root `LayoutView`. During the tree walk, one
information to provide O(1) complexity access to them if possible:
* Paint invalidation container: Since as indicated by the definitions in
[Glossaries](#Other glossaries), the paint invalidation container for
[Glossaries](#other-glossaries), the paint invalidation container for
stacked objects can differ from normal objects, we have to track both
separately. Here is an example:
......
......@@ -23,8 +23,12 @@ static const LayoutBoxModelObject* ClippingContainerFromClipChainParent(
: clip_chain_parent->ClippingContainer();
}
CompositingInputsUpdater::CompositingInputsUpdater(PaintLayer* root_layer)
: geometry_map_(kUseTransforms), root_layer_(root_layer) {}
CompositingInputsUpdater::CompositingInputsUpdater(
PaintLayer* root_layer,
CompositingReasonFinder& compositing_reason_finder)
: geometry_map_(kUseTransforms),
root_layer_(root_layer),
compositing_reason_finder_(compositing_reason_finder) {}
CompositingInputsUpdater::~CompositingInputsUpdater() = default;
......@@ -36,10 +40,6 @@ void CompositingInputsUpdater::Update() {
void CompositingInputsUpdater::UpdateRecursive(PaintLayer* layer,
UpdateType update_type,
AncestorInfo info) {
if (!layer->ChildNeedsCompositingInputsUpdate() &&
update_type != kForceUpdate)
return;
LayoutBoxModelObject& layout_object = layer->GetLayoutObject();
const ComputedStyle& style = layout_object.StyleRef();
......@@ -189,11 +189,54 @@ void CompositingInputsUpdater::UpdateRecursive(PaintLayer* layer,
info.needs_reparent_scroll_for_fixed = false;
}
// The sequence of updates to compositing triggers goes like this:
// 1. Apply all triggers from kComboAllDirectNonStyleDeterminedReasons for
// |layer|. This may depend on ancestor composited scrolling (i.e. step
// 2 for an ancestor PaintLayer).
// 2. Put |layer| in composited scrolling mode if needed.
// 3. Reset DescendantHasDirectCompositingReason to false for |layer|.
// 4. Recurse into child PaintLayers.
// 5. Set DescendantHasDirectCompositingReason to true if it was for any
// child.
// 6. If |layer| is the root, composite if
// DescendantHasDirectCompositingReason is true for |layer|.
bool ignore_lcd_text =
(layer->AncestorScrollingLayer() &&
!layer->AncestorScrollingLayer()->IsRootLayer() &&
layer->AncestorScrollingLayer()->NeedsCompositedScrolling());
layer->SetPotentialCompositingReasonsFromNonStyle(
compositing_reason_finder_.NonStyleDeterminedDirectReasons(
layer, ignore_lcd_text));
if (layer->GetScrollableArea()) {
layer->GetScrollableArea()->UpdateNeedsCompositedScrolling(
layer->GetLayoutObject().View()->Compositor()->CanBeComposited(layer) &&
layer->DirectCompositingReasons());
}
bool should_recurse =
layer->ChildNeedsCompositingInputsUpdate() || update_type == kForceUpdate;
layer->SetDescendantHasDirectCompositingReason(false);
bool descendant_has_direct_compositing_reason = false;
for (PaintLayer* child = layer->FirstChild(); child;
child = child->NextSibling())
UpdateRecursive(child, update_type, info);
child = child->NextSibling()) {
if (should_recurse)
UpdateRecursive(child, update_type, info);
descendant_has_direct_compositing_reason |=
child->DescendantHasDirectCompositingReason() ||
child->DirectCompositingReasons();
}
layer->SetDescendantHasDirectCompositingReason(
descendant_has_direct_compositing_reason);
if (layer->IsRootLayer() && layer->ScrollsOverflow() &&
layer->DescendantHasDirectCompositingReason() &&
!layer->NeedsCompositedScrolling())
layer->GetScrollableArea()->UpdateNeedsCompositedScrolling(true);
layer->DidUpdateCompositingInputs();
layer->ClearChildNeedsCompositingInputsUpdate();
geometry_map_.PopMappingsToAncestor(layer->Parent());
......
......@@ -11,12 +11,15 @@
namespace blink {
class PaintLayer;
class CompositingReasonFinder;
class CompositingInputsUpdater {
STACK_ALLOCATED();
public:
explicit CompositingInputsUpdater(PaintLayer* root_layer);
explicit CompositingInputsUpdater(
PaintLayer* root_layer,
CompositingReasonFinder& compositing_reason_finder);
~CompositingInputsUpdater();
void Update();
......@@ -62,6 +65,7 @@ class CompositingInputsUpdater {
LayoutGeometryMap geometry_map_;
PaintLayer* root_layer_;
CompositingReasonFinder& compositing_reason_finder_;
};
} // namespace blink
......
......@@ -56,7 +56,6 @@ CompositingReasons CompositingReasonFinder::DirectReasons(
NonStyleDeterminedDirectReasons(layer, ignore_lcd_text);
}
// This information doesn't appear to be incorporated into CompositingReasons.
bool CompositingReasonFinder::RequiresCompositingForScrollableFrame() const {
// Need this done first to determine overflow.
DCHECK(!layout_view_.NeedsLayout());
......@@ -164,9 +163,6 @@ CompositingReasons CompositingReasonFinder::NonStyleDeterminedDirectReasons(
if (layer->ClipParent() && layer->GetLayoutObject().IsOutOfFlowPositioned())
direct_reasons |= CompositingReason::kOutOfFlowClipping;
if (layer->NeedsCompositedScrolling())
direct_reasons |= CompositingReason::kOverflowScrollingTouch;
if (RequiresCompositingForRootScroller(*layer))
direct_reasons |= CompositingReason::kRootScroller;
......@@ -189,6 +185,11 @@ CompositingReasons CompositingReasonFinder::NonStyleDeterminedDirectReasons(
direct_reasons |= CompositingReason::kScrollTimelineTarget;
}
if (layer->IsRootLayer() && (RequiresCompositingForScrollableFrame() ||
layout_view_.GetFrame()->IsLocalRoot())) {
direct_reasons |= CompositingReason::kRoot;
}
direct_reasons |= layout_object.AdditionalCompositingReasons();
DCHECK(
......
......@@ -26,6 +26,13 @@ class CORE_EXPORT CompositingReasonFinder {
CompositingReasons PotentialCompositingReasonsFromStyle(LayoutObject&) const;
CompositingReasons NonStyleDeterminedDirectReasons(
const PaintLayer*,
bool ignore_lcd_text) const;
LayoutView& layout_view_;
CompositingTriggerFlags compositing_triggers_;
DISALLOW_COPY_AND_ASSIGN(CompositingReasonFinder);
// Returns the direct reasons for compositing the given layer. If
// |ignoreLCDText| is true promotion will not try to preserve subpixel text
// rendering (i.e. partially transparent layers will be promoted).
......@@ -51,13 +58,6 @@ class CORE_EXPORT CompositingReasonFinder {
private:
bool IsMainFrame() const;
CompositingReasons NonStyleDeterminedDirectReasons(
const PaintLayer*,
bool ignore_lcd_text) const;
LayoutView& layout_view_;
CompositingTriggerFlags compositing_triggers_;
DISALLOW_COPY_AND_ASSIGN(CompositingReasonFinder);
};
} // namespace blink
......
......@@ -32,6 +32,16 @@ class CompositingReasonFinderTestPlatform : public TestingPlatformSupport {
bool IsLowEndDevice() override { return true; }
};
TEST_F(CompositingReasonFinderTest, CompositingReasonDependencies) {
EXPECT_FALSE(CompositingReason::kComboAllDirectNonStyleDeterminedReasons &
(~CompositingReason::kComboAllDirectReasons));
EXPECT_EQ(CompositingReason::kComboAllDirectReasons,
CompositingReason::kComboAllDirectStyleDeterminedReasons |
CompositingReason::kComboAllDirectNonStyleDeterminedReasons);
EXPECT_FALSE(CompositingReason::kComboAllDirectNonStyleDeterminedReasons &
CompositingReason::kComboAllStyleDeterminedReasons);
}
TEST_F(CompositingReasonFinderTest, DontPromoteTrivial3DLowEnd) {
ScopedTestingPlatformSupport<CompositingReasonFinderTestPlatform> platform;
......
......@@ -243,29 +243,6 @@ void CompositingRequirementsUpdater::Update(
absolute_descendant_bounding_box, compositing_reasons_stats);
}
void CompositingRequirementsUpdater::MaybeEnableCompositedScrolling(
PaintLayer* layer,
CompositingReasons& reasons) {
// Add CompositingReasonOverflowScrollingTouch for layers that do not
// already have it but need it.
// Note that m_compositingReasonFinder.directReasons(layer) already includes
// CompositingReasonOverflowScrollingTouch for anything that has
// layer->needsCompositedScrolling() true. That is, for cases where we
// explicitly decide not to have LCD text or cases where the layer will
// still support LCD text even if the layer is composited.
if (reasons && layer->ScrollsOverflow() &&
!layer->NeedsCompositedScrolling()) {
// We can get here for a scroller that will be composited for some other
// reason and hence will already use grayscale AA text. We recheck for
// needsCompositedScrolling ignoring LCD to correctly add the
// CompositingReasonOverflowScrollingTouch reason to layers that can
// support it with grayscale AA text.
layer->GetScrollableArea()->UpdateNeedsCompositedScrolling(true);
if (layer->NeedsCompositedScrolling())
reasons |= CompositingReason::kOverflowScrollingTouch;
}
}
void CompositingRequirementsUpdater::UpdateRecursive(
PaintLayer* ancestor_layer,
PaintLayer* layer,
......@@ -286,15 +263,16 @@ void CompositingRequirementsUpdater::UpdateRecursive(
// PaintLayer children and whose children can't use its backing to render
// into. These children (the controls) always need to be promoted into their
// own layers to draw on top of the accelerated video.
// TODO(chrishtr): Fix this Don't mess with direct reasons in this method.
if (current_recursion_data.compositing_ancestor_ &&
current_recursion_data.compositing_ancestor_->GetLayoutObject().IsVideo())
direct_reasons |= CompositingReason::kVideoOverlay;
bool has_composited_scrolling_ancestor =
layer->AncestorScrollingLayer() &&
(compositing_reason_finder_.DirectReasons(layer->AncestorScrollingLayer(),
false) &
CompositingReason::kOverflowScrollingTouch);
layer->AncestorScrollingLayer()->GetScrollableArea() &&
layer->AncestorScrollingLayer()->NeedsCompositedScrolling();
bool use_clipped_bounding_rect =
!has_composited_scrolling_ancestor ||
......@@ -309,23 +287,39 @@ void CompositingRequirementsUpdater::UpdateRecursive(
const bool moves_with_respect_to_compositing_ancestor =
layer->SticksToScroller() &&
!current_recursion_data.compositing_ancestor_->IsRootLayer();
// TODO(chrishtr): use |hasCompositedScrollingAncestor| instead.
// TODO(chrishtr): use |has_composited_scrolling_ancestor| instead.
const bool ignore_lcd_text =
current_recursion_data.has_composited_scrolling_ancestor_ ||
moves_with_respect_to_compositing_ancestor;
direct_reasons |=
compositing_reason_finder_.DirectReasons(layer, ignore_lcd_text);
current_recursion_data.has_composited_scrolling_ancestor_;
bool can_be_composited = compositor->CanBeComposited(layer);
if (can_be_composited) {
reasons_to_composite |= direct_reasons;
CompositingReasons direct_from_paint_layer =
layer->DirectCompositingReasons();
if (layer->IsRootLayer() && compositor->RootShouldAlwaysComposite())
reasons_to_composite |= CompositingReason::kRoot;
if (compositing_reason_finder_.RequiresCompositingForScrollDependentPosition(
layer,
ignore_lcd_text || moves_with_respect_to_compositing_ancestor)) {
direct_from_paint_layer |= CompositingReason::kScrollDependentPosition;
}
MaybeEnableCompositedScrolling(layer, reasons_to_composite);
DCHECK(
direct_from_paint_layer ==
compositing_reason_finder_.DirectReasons(
layer, ignore_lcd_text || moves_with_respect_to_compositing_ancestor))
<< " Expected: "
<< CompositingReason::ToString(
compositing_reason_finder_.DirectReasons(layer, ignore_lcd_text))
<< " Actual: " << CompositingReason::ToString(direct_from_paint_layer);
direct_reasons |= direct_from_paint_layer;
if (layer->GetScrollableArea() &&
layer->GetScrollableArea()->NeedsCompositedScrolling()) {
direct_reasons |= CompositingReason::kOverflowScrollingTouch;
}
bool can_be_composited = compositor->CanBeComposited(layer);
if (can_be_composited)
reasons_to_composite |= direct_reasons;
if ((reasons_to_composite & CompositingReason::kOverflowScrollingTouch) &&
!layer->IsRootLayer())
current_recursion_data.has_composited_scrolling_ancestor_ = true;
......@@ -527,15 +521,16 @@ void CompositingRequirementsUpdater::UpdateRecursive(
if (child_recursion_data.subtree_is_compositing_ ||
RequiresCompositingOrSquashing(reasons_to_composite) ||
compositor->RootShouldAlwaysComposite()) {
#if DCHECK_IS_ON()
// The reason for compositing should not be due to composited scrolling.
// It should only be compositing in order to represent composited content
// within a composited subframe.
bool was = layer->NeedsCompositedScrolling();
layer->GetScrollableArea()->UpdateNeedsCompositedScrolling(true);
DCHECK(was == layer->NeedsCompositedScrolling());
#endif
reasons_to_composite |= CompositingReason::kRoot;
current_recursion_data.subtree_is_compositing_ = true;
// Try again to enable composited scrolling if root became composited due
// to subtree_is_compositing_ or overlap.
// TODO(skobes): At this point we've already done recursion to descendant
// layers, possibly with has_composited_scrolling_ancestor_ == false.
// We should refactor overlap testing etc. to be independent of having
// composited scrolling ancestors. See crbug.com/777672, crbug.com/782991.
MaybeEnableCompositedScrolling(layer, reasons_to_composite);
} else {
compositor->SetCompositingModeEnabled(false);
reasons_to_composite = CompositingReason::kNone;
......
......@@ -71,8 +71,6 @@ class CompositingRequirementsUpdater {
IntRect& absolute_descendant_bounding_box,
CompositingReasonsStats&);
void MaybeEnableCompositedScrolling(PaintLayer*, CompositingReasons&);
LayoutView& layout_view_;
CompositingReasonFinder& compositing_reason_finder_;
};
......
......@@ -365,7 +365,7 @@ void PaintLayerCompositor::UpdateWithoutAcceleratedCompositing(
DCHECK(!HasAcceleratedCompositing());
if (update_type >= kCompositingUpdateAfterCompositingInputChange)
CompositingInputsUpdater(RootLayer()).Update();
CompositingInputsUpdater(RootLayer(), compositing_reason_finder_).Update();
#if DCHECK_IS_ON()
CompositingInputsUpdater::AssertNeedsCompositingInputsUpdateBitsCleared(
......@@ -441,7 +441,7 @@ void PaintLayerCompositor::UpdateIfNeeded(
Vector<PaintLayer*> layers_needing_paint_invalidation;
if (update_type >= kCompositingUpdateAfterCompositingInputChange) {
CompositingInputsUpdater(update_root).Update();
CompositingInputsUpdater(update_root, compositing_reason_finder_).Update();
#if DCHECK_IS_ON()
// FIXME: Move this check to the end of the compositing update.
......@@ -886,6 +886,11 @@ void PaintLayerCompositor::AttachRootLayer() {
// CompositedLayerMapping::updateGraphicsLayerConfiguration() for the
// frame's layoutObject in the parent document.
owner_element->SetNeedsCompositingUpdate();
if (owner_element->GetLayoutObject()) {
ToLayoutBoxModelObject(owner_element->GetLayoutObject())
->Layer()
->SetNeedsCompositingInputsUpdate();
}
root_layer_attachment_ = kRootLayerAttachedViaEnclosingFrame;
}
}
......
......@@ -123,6 +123,7 @@ using namespace HTMLNames;
PaintLayerRareData::PaintLayerRareData()
: enclosing_pagination_layer(nullptr),
potential_compositing_reasons_from_style(CompositingReason::kNone),
potential_compositing_reasons_from_non_style(CompositingReason::kNone),
compositing_reasons(CompositingReason::kNone),
squashing_disallowed_reasons(SquashingDisallowedReason::kNone),
grouped_mapping(nullptr) {}
......@@ -162,6 +163,8 @@ PaintLayer::PaintLayer(LayoutBoxModelObject& layout_object)
self_painting_status_changed_(false),
filter_on_effect_node_dirty_(false),
is_under_svg_hidden_container_(false),
descendant_has_direct_compositing_reason_(false),
needs_compositing_reasons_update_(true),
layout_object_(layout_object),
parent_(nullptr),
previous_(nullptr),
......@@ -228,14 +231,11 @@ void PaintLayer::ContentChanged(ContentChangeType change_type) {
DisableCompositingQueryAsserts disabler;
if (Compositor()) {
if (change_type == kCanvasChanged) {
Compositor()->SetNeedsCompositingUpdate(
kCompositingUpdateAfterCompositingInputChange);
}
if (change_type == kCanvasChanged)
SetNeedsCompositingInputsUpdate();
if (change_type == kCanvasContextChanged) {
Compositor()->SetNeedsCompositingUpdate(
kCompositingUpdateAfterCompositingInputChange);
SetNeedsCompositingInputsUpdate();
// Although we're missing test coverage, we need to call
// GraphicsLayer::SetContentsToCcLayer with the new cc::Layer for this
......@@ -1121,11 +1121,9 @@ void PaintLayer::UpdateAncestorDependentCompositingInputs(
needs_ancestor_dependent_compositing_inputs_update_ = false;
}
void PaintLayer::DidUpdateCompositingInputs() {
void PaintLayer::ClearChildNeedsCompositingInputsUpdate() {
DCHECK(!NeedsCompositingInputsUpdate());
child_needs_compositing_inputs_update_ = false;
if (scrollable_area_)
scrollable_area_->UpdateNeedsCompositedScrolling();
}
bool PaintLayer::HasNonIsolatedDescendantWithBlendMode() const {
......
......@@ -124,6 +124,8 @@ struct PaintLayerRareData {
// compositing state of this layer.
CompositingReasons potential_compositing_reasons_from_style;
CompositingReasons potential_compositing_reasons_from_non_style;
// Once computed, indicates all that a layer needs to become composited using
// the CompositingReasons enum bitfield.
CompositingReasons compositing_reasons;
......@@ -686,6 +688,14 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient {
bool ScrollsOverflow() const;
CompositingReasons DirectCompositingReasons() const {
return rare_data_
? ((rare_data_->potential_compositing_reasons_from_style |
rare_data_->potential_compositing_reasons_from_non_style) &
CompositingReason::kComboAllDirectReasons)
: CompositingReason::kNone;
}
CompositingReasons PotentialCompositingReasonsFromStyle() const {
return rare_data_ ? rare_data_->potential_compositing_reasons_from_style
: CompositingReason::kNone;
......@@ -696,6 +706,17 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient {
if (rare_data_ || reasons != CompositingReason::kNone)
EnsureRareData().potential_compositing_reasons_from_style = reasons;
}
CompositingReasons PotentialCompositingReasonsFromNonStyle() const {
return rare_data_ ? rare_data_->potential_compositing_reasons_from_non_style
: CompositingReason::kNone;
}
void SetPotentialCompositingReasonsFromNonStyle(CompositingReasons reasons) {
DCHECK(reasons ==
(reasons &
CompositingReason::kComboAllDirectNonStyleDeterminedReasons));
if (rare_data_ || reasons != CompositingReason::kNone)
EnsureRareData().potential_compositing_reasons_from_non_style = reasons;
}
bool HasStyleDeterminedDirectCompositingReasons() const {
return PotentialCompositingReasonsFromStyle() &
......@@ -752,7 +773,7 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient {
}
void UpdateAncestorDependentCompositingInputs(
const AncestorDependentCompositingInputs&);
void DidUpdateCompositingInputs();
void ClearChildNeedsCompositingInputsUpdate();
const AncestorDependentCompositingInputs&
GetAncestorDependentCompositingInputs() const {
......@@ -992,6 +1013,13 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient {
previous_paint_phase_descendant_block_backgrounds_was_empty_ = is_empty;
}
bool DescendantHasDirectCompositingReason() const {
return descendant_has_direct_compositing_reason_;
}
void SetDescendantHasDirectCompositingReason(bool value) {
descendant_has_direct_compositing_reason_ = value;
}
ClipRectsCache* GetClipRectsCache() const { return clip_rects_cache_.get(); }
ClipRectsCache& EnsureClipRectsCache() const {
if (!clip_rects_cache_)
......@@ -1257,6 +1285,7 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient {
// ancestor.
unsigned is_under_svg_hidden_container_ : 1;
unsigned descendant_has_direct_compositing_reason_ : 1;
unsigned needs_compositing_reasons_update_ : 1;
LayoutBoxModelObject& layout_object_;
......
......@@ -124,11 +124,16 @@ class PLATFORM_EXPORT CompositingReason {
k3DTransform | kBackfaceVisibilityHidden | kComboActiveAnimation |
kTransitionProperty | kWillChangeCompositingHint | kBackdropFilter,
kComboAllDirectReasons =
kComboAllDirectStyleDeterminedReasons | kVideo | kCanvas | kPlugin |
kIFrame | kScrollDependentPosition | kOverflowScrollingTouch |
kOverflowScrollingParent | kOutOfFlowClipping | kVideoOverlay |
kRootScroller,
kComboAllDirectNonStyleDeterminedReasons =
kVideo | kCanvas | kPlugin | kIFrame | kOverflowScrollingParent |
kOutOfFlowClipping | kVideoOverlay | kRoot | kRootScroller |
kScrollDependentPosition | kScrollTimelineTarget,
kComboAllDirectReasons = kComboAllDirectStyleDeterminedReasons |
kComboAllDirectNonStyleDeterminedReasons,
kComboAllCompositedScrollingDeterminedReasons =
kScrollDependentPosition | kOverflowScrollingTouch,
kComboCompositedDescendants =
kTransformWithCompositedDescendants | kIsolateCompositedDescendants |
......
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