Make CompositingReasonFinder a static class
This patch makes CompositingReasonFinder a static class (all functions
static) because there is no state that needs to be tracked. This is
just a simplification of the code and should not have any functional
change.
Bug: 915372
Change-Id: I39242f8de43705e3ccc61ae2ff9bb10d410b1823
Reviewed-on: https://chromium-review.googlesource.com/c/1381259
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Commit-Queue: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#617597}
diff --git a/third_party/blink/renderer/core/paint/compositing/compositing_inputs_updater.cc b/third_party/blink/renderer/core/paint/compositing/compositing_inputs_updater.cc
index 0c7bdf6..23841cd 100644
--- a/third_party/blink/renderer/core/paint/compositing/compositing_inputs_updater.cc
+++ b/third_party/blink/renderer/core/paint/compositing/compositing_inputs_updater.cc
@@ -24,12 +24,8 @@
: clip_chain_parent->ClippingContainer();
}
-CompositingInputsUpdater::CompositingInputsUpdater(
- PaintLayer* root_layer,
- CompositingReasonFinder& compositing_reason_finder)
- : geometry_map_(kUseTransforms),
- root_layer_(root_layer),
- compositing_reason_finder_(compositing_reason_finder) {}
+CompositingInputsUpdater::CompositingInputsUpdater(PaintLayer* root_layer)
+ : geometry_map_(kUseTransforms), root_layer_(root_layer) {}
CompositingInputsUpdater::~CompositingInputsUpdater() = default;
@@ -229,8 +225,8 @@
layer->AncestorScrollingLayer()->NeedsCompositedScrolling());
layer->SetPotentialCompositingReasonsFromNonStyle(
- compositing_reason_finder_.NonStyleDeterminedDirectReasons(
- layer, ignore_lcd_text));
+ CompositingReasonFinder::NonStyleDeterminedDirectReasons(
+ *layer, ignore_lcd_text));
if (layer->GetScrollableArea()) {
layer->GetScrollableArea()->UpdateNeedsCompositedScrolling(
diff --git a/third_party/blink/renderer/core/paint/compositing/compositing_inputs_updater.h b/third_party/blink/renderer/core/paint/compositing/compositing_inputs_updater.h
index 823f156..8510932 100644
--- a/third_party/blink/renderer/core/paint/compositing/compositing_inputs_updater.h
+++ b/third_party/blink/renderer/core/paint/compositing/compositing_inputs_updater.h
@@ -11,15 +11,12 @@
namespace blink {
class PaintLayer;
-class CompositingReasonFinder;
class CompositingInputsUpdater {
STACK_ALLOCATED();
public:
- explicit CompositingInputsUpdater(
- PaintLayer* root_layer,
- CompositingReasonFinder& compositing_reason_finder);
+ explicit CompositingInputsUpdater(PaintLayer* root_layer);
~CompositingInputsUpdater();
void Update();
@@ -71,7 +68,6 @@
LayoutGeometryMap geometry_map_;
PaintLayer* root_layer_;
- CompositingReasonFinder& compositing_reason_finder_;
};
} // namespace blink
diff --git a/third_party/blink/renderer/core/paint/compositing/compositing_reason_finder.cc b/third_party/blink/renderer/core/paint/compositing/compositing_reason_finder.cc
index ea2e307..2ce4934 100644
--- a/third_party/blink/renderer/core/paint/compositing/compositing_reason_finder.cc
+++ b/third_party/blink/renderer/core/paint/compositing/compositing_reason_finder.cc
@@ -19,48 +19,42 @@
namespace blink {
-CompositingReasonFinder::CompositingReasonFinder(LayoutView& layout_view)
- : layout_view_(layout_view) {}
-
-bool CompositingReasonFinder::IsMainFrame() const {
- return layout_view_.GetDocument().IsInMainFrame();
-}
-
CompositingReasons CompositingReasonFinder::DirectReasons(
- const PaintLayer* layer,
- bool ignore_lcd_text) const {
+ const PaintLayer& layer,
+ bool ignore_lcd_text) {
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
return CompositingReason::kNone;
- DCHECK_EQ(PotentialCompositingReasonsFromStyle(layer->GetLayoutObject()),
- layer->PotentialCompositingReasonsFromStyle());
+ DCHECK_EQ(PotentialCompositingReasonsFromStyle(layer.GetLayoutObject()),
+ layer.PotentialCompositingReasonsFromStyle());
CompositingReasons style_determined_direct_compositing_reasons =
- layer->PotentialCompositingReasonsFromStyle() &
+ layer.PotentialCompositingReasonsFromStyle() &
CompositingReason::kComboAllDirectStyleDeterminedReasons;
return style_determined_direct_compositing_reasons |
NonStyleDeterminedDirectReasons(layer, ignore_lcd_text);
}
-bool CompositingReasonFinder::RequiresCompositingForScrollableFrame() const {
+bool CompositingReasonFinder::RequiresCompositingForScrollableFrame(
+ const LayoutView& layout_view) {
// Need this done first to determine overflow.
- DCHECK(!layout_view_.NeedsLayout());
- if (IsMainFrame())
+ DCHECK(!layout_view.NeedsLayout());
+ if (layout_view.GetDocument().IsInMainFrame())
return false;
- const auto& settings = *layout_view_.GetDocument().GetSettings();
+ const auto& settings = *layout_view.GetDocument().GetSettings();
if (!settings.GetPreferCompositingToLCDTextEnabled())
return false;
- if (layout_view_.GetFrameView()->Size().IsEmpty())
+ if (layout_view.GetFrameView()->Size().IsEmpty())
return false;
- return layout_view_.GetFrameView()->LayoutViewport()->ScrollsOverflow();
+ return layout_view.GetFrameView()->LayoutViewport()->ScrollsOverflow();
}
CompositingReasons
CompositingReasonFinder::PotentialCompositingReasonsFromStyle(
- LayoutObject& layout_object) const {
+ const LayoutObject& layout_object) {
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
return CompositingReason::kNone;
@@ -137,35 +131,35 @@
}
CompositingReasons CompositingReasonFinder::NonStyleDeterminedDirectReasons(
- const PaintLayer* layer,
- bool ignore_lcd_text) const {
+ const PaintLayer& layer,
+ bool ignore_lcd_text) {
CompositingReasons direct_reasons = CompositingReason::kNone;
- LayoutObject& layout_object = layer->GetLayoutObject();
+ LayoutObject& layout_object = layer.GetLayoutObject();
// TODO(chrishtr): remove this hammer in favor of something more targeted.
// See crbug.com/749349.
- if (layer->ClipParent() && layer->GetLayoutObject().IsOutOfFlowPositioned())
+ if (layer.ClipParent() && layer.GetLayoutObject().IsOutOfFlowPositioned())
direct_reasons |= CompositingReason::kOutOfFlowClipping;
- if (RequiresCompositingForRootScroller(*layer))
+ if (RequiresCompositingForRootScroller(layer))
direct_reasons |= CompositingReason::kRootScroller;
// Composite |layer| if it is inside of an ancestor scrolling layer, but that
// scrolling layer is not on the stacking context ancestor chain of |layer|.
// See the definition of the scrollParent property in Layer for more detail.
- if (const PaintLayer* scrolling_ancestor = layer->AncestorScrollingLayer()) {
- if (scrolling_ancestor->NeedsCompositedScrolling() && layer->ScrollParent())
+ if (const PaintLayer* scrolling_ancestor = layer.AncestorScrollingLayer()) {
+ if (scrolling_ancestor->NeedsCompositedScrolling() && layer.ScrollParent())
direct_reasons |= CompositingReason::kOverflowScrollingParent;
}
- if (RequiresCompositingForScrollDependentPosition(*layer, ignore_lcd_text))
+ if (RequiresCompositingForScrollDependentPosition(layer, ignore_lcd_text))
direct_reasons |= CompositingReason::kScrollDependentPosition;
// TODO(crbug.com/839341): Remove once we support main-thread AnimationWorklet
// and don't need to promote the scroll-source.
- if (layer->GetScrollableArea() && layer->GetLayoutObject().GetNode() &&
+ if (layer.GetScrollableArea() && layer.GetLayoutObject().GetNode() &&
ScrollTimeline::HasActiveScrollTimeline(
- layer->GetLayoutObject().GetNode())) {
+ layer.GetLayoutObject().GetNode())) {
direct_reasons |= CompositingReason::kScrollTimelineTarget;
}
@@ -173,12 +167,13 @@
// 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.
- if (layer->CompositingContainer() &&
- layer->CompositingContainer()->GetLayoutObject().IsVideo())
+ if (layer.CompositingContainer() &&
+ layer.CompositingContainer()->GetLayoutObject().IsVideo())
direct_reasons |= CompositingReason::kVideoOverlay;
- if (layer->IsRootLayer() && (RequiresCompositingForScrollableFrame() ||
- layout_view_.GetFrame()->IsLocalRoot())) {
+ if (layer.IsRootLayer() &&
+ (RequiresCompositingForScrollableFrame(*layout_object.View()) ||
+ layout_object.GetFrame()->IsLocalRoot())) {
direct_reasons |= CompositingReason::kRoot;
}
diff --git a/third_party/blink/renderer/core/paint/compositing/compositing_reason_finder.h b/third_party/blink/renderer/core/paint/compositing/compositing_reason_finder.h
index 87c3b37..4df36f7b 100644
--- a/third_party/blink/renderer/core/paint/compositing/compositing_reason_finder.h
+++ b/third_party/blink/renderer/core/paint/compositing/compositing_reason_finder.h
@@ -21,23 +21,22 @@
DISALLOW_NEW();
public:
- explicit CompositingReasonFinder(LayoutView&);
+ static CompositingReasons PotentialCompositingReasonsFromStyle(
+ const LayoutObject&);
- CompositingReasons PotentialCompositingReasonsFromStyle(LayoutObject&) const;
+ static CompositingReasons NonStyleDeterminedDirectReasons(
+ const PaintLayer&,
+ bool ignore_lcd_text);
- CompositingReasons NonStyleDeterminedDirectReasons(
- const PaintLayer*,
- bool ignore_lcd_text) const;
- LayoutView& layout_view_;
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).
- CompositingReasons DirectReasons(const PaintLayer*,
- bool ignore_lcd_text) const;
+ static CompositingReasons DirectReasons(const PaintLayer&,
+ bool ignore_lcd_text);
- bool RequiresCompositingForScrollableFrame() const;
+ static bool RequiresCompositingForScrollableFrame(const LayoutView&);
static CompositingReasons CompositingReasonsForAnimation(
const ComputedStyle&);
static bool RequiresCompositingForOpacityAnimation(const ComputedStyle&);
@@ -51,9 +50,6 @@
static bool RequiresCompositingForScrollDependentPosition(
const PaintLayer&,
bool ignore_lcd_text);
-
- private:
- bool IsMainFrame() const;
};
} // namespace blink
diff --git a/third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater.cc b/third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater.cc
index aa75b8fac..03f3fc5 100644
--- a/third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater.cc
+++ b/third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater.cc
@@ -210,15 +210,8 @@
}
CompositingRequirementsUpdater::CompositingRequirementsUpdater(
- LayoutView& layout_view,
- CompositingReasonFinder& compositing_reason_finder)
- : layout_view_(layout_view)
-#if DCHECK_IS_ON()
- ,
- compositing_reason_finder_(compositing_reason_finder)
-#endif
-{
-}
+ LayoutView& layout_view)
+ : layout_view_(layout_view) {}
CompositingRequirementsUpdater::~CompositingRequirementsUpdater() = default;
@@ -317,12 +310,12 @@
#if DCHECK_IS_ON()
if (layer_can_be_composited) {
DCHECK(direct_from_paint_layer ==
- compositing_reason_finder_.DirectReasons(
- layer,
+ CompositingReasonFinder::DirectReasons(
+ *layer,
ignore_lcd_text || moves_with_respect_to_compositing_ancestor))
<< " Expected: "
<< CompositingReason::ToString(
- compositing_reason_finder_.DirectReasons(layer, ignore_lcd_text))
+ CompositingReasonFinder::DirectReasons(*layer, ignore_lcd_text))
<< " Actual: " << CompositingReason::ToString(direct_from_paint_layer);
}
#endif
diff --git a/third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater.h b/third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater.h
index 2b4bd5e7..81b6e85 100644
--- a/third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater.h
+++ b/third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater.h
@@ -34,7 +34,6 @@
namespace blink {
-class CompositingReasonFinder;
class PaintLayer;
class LayoutView;
@@ -42,7 +41,7 @@
STACK_ALLOCATED();
public:
- CompositingRequirementsUpdater(LayoutView&, CompositingReasonFinder&);
+ CompositingRequirementsUpdater(LayoutView&);
~CompositingRequirementsUpdater();
// Recurse through the layers in z-index and overflow order (which is
@@ -72,9 +71,6 @@
CompositingReasonsStats&);
LayoutView& layout_view_;
-#if DCHECK_IS_ON()
- CompositingReasonFinder& compositing_reason_finder_;
-#endif
};
} // namespace blink
diff --git a/third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.cc b/third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.cc
index 8748e94..06fff3d 100644
--- a/third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.cc
+++ b/third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.cc
@@ -68,7 +68,6 @@
PaintLayerCompositor::PaintLayerCompositor(LayoutView& layout_view)
: layout_view_(layout_view),
- compositing_reason_finder_(layout_view),
pending_update_type_(kCompositingUpdateNone),
has_accelerated_compositing_(true),
compositing_(false),
@@ -132,7 +131,8 @@
if (!has_accelerated_compositing_)
return false;
return layout_view_.GetFrame()->IsLocalRoot() ||
- compositing_reason_finder_.RequiresCompositingForScrollableFrame();
+ CompositingReasonFinder::RequiresCompositingForScrollableFrame(
+ layout_view_);
}
void PaintLayerCompositor::UpdateAcceleratedCompositingSettings() {
@@ -366,7 +366,7 @@
DCHECK(!HasAcceleratedCompositing());
if (update_type >= kCompositingUpdateAfterCompositingInputChange)
- CompositingInputsUpdater(RootLayer(), compositing_reason_finder_).Update();
+ CompositingInputsUpdater(RootLayer()).Update();
#if DCHECK_IS_ON()
CompositingInputsUpdater::AssertNeedsCompositingInputsUpdateBitsCleared(
@@ -452,7 +452,7 @@
Vector<PaintLayer*> layers_needing_paint_invalidation;
if (update_type >= kCompositingUpdateAfterCompositingInputChange) {
- CompositingInputsUpdater(update_root, compositing_reason_finder_).Update();
+ CompositingInputsUpdater(update_root).Update();
#if DCHECK_IS_ON()
// FIXME: Move this check to the end of the compositing update.
@@ -470,7 +470,7 @@
return;
}
- CompositingRequirementsUpdater(layout_view_, compositing_reason_finder_)
+ CompositingRequirementsUpdater(layout_view_)
.Update(update_root, compositing_reasons_stats);
CompositingLayerAssigner layer_assigner(this);
@@ -782,9 +782,9 @@
void PaintLayerCompositor::UpdatePotentialCompositingReasonsFromStyle(
PaintLayer& layer) {
- layer.SetPotentialCompositingReasonsFromStyle(
- compositing_reason_finder_.PotentialCompositingReasonsFromStyle(
- layer.GetLayoutObject()));
+ auto reasons = CompositingReasonFinder::PotentialCompositingReasonsFromStyle(
+ layer.GetLayoutObject());
+ layer.SetPotentialCompositingReasonsFromStyle(reasons);
}
bool PaintLayerCompositor::CanBeComposited(const PaintLayer* layer) const {
@@ -795,7 +795,7 @@
return false;
const bool has_compositor_animation =
- compositing_reason_finder_.CompositingReasonsForAnimation(
+ CompositingReasonFinder::CompositingReasonsForAnimation(
*layer->GetLayoutObject().Style()) != CompositingReason::kNone;
return has_accelerated_compositing_ &&
(has_compositor_animation || !layer->SubtreeIsInvisible()) &&
diff --git a/third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.h b/third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.h
index 92fdf8f..52f4f7f 100644
--- a/third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.h
+++ b/third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.h
@@ -200,8 +200,6 @@
LayoutView& layout_view_;
- CompositingReasonFinder compositing_reason_finder_;
-
CompositingUpdateType pending_update_type_;
bool has_accelerated_compositing_;