Skip to content

Commit

Permalink
Remove pre-BlinkGenPropertyTrees codepaths
Browse files Browse the repository at this point in the history
Now that BlinkGenPropertyTrees (BGPT) has launched, we can remove the
pre-BGPT code.

Bug: 989251
Change-Id: I7c64da9fd5e593436301936abcef3e39198ccbe2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1752244
Commit-Queue: Philip Rogers <pdr@chromium.org>
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686614}
  • Loading branch information
progers authored and Commit Bot committed Aug 13, 2019
1 parent d99ce4e commit d6c4a0c
Show file tree
Hide file tree
Showing 65 changed files with 396 additions and 3,503 deletions.
10 changes: 2 additions & 8 deletions third_party/blink/renderer/core/animation/animation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,8 @@ class AnimationAnimationTestNoCompositing : public RenderingTest {

bool SimulateFrame(double time_ms) {
last_frame_time = time_ms;
const PaintArtifactCompositor* paint_artifact_compositor = nullptr;
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled() ||
RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled()) {
paint_artifact_compositor = GetDocument()
.GetFrame()
->View()
->GetPaintArtifactCompositorForTesting();
}
const auto* paint_artifact_compositor =
GetDocument().GetFrame()->View()->GetPaintArtifactCompositor();
GetDocument().GetAnimationClock().UpdateTime(
base::TimeTicks() + base::TimeDelta::FromMillisecondsD(time_ms));
GetDocument().GetPendingAnimations().Update(paint_artifact_compositor,
Expand Down
22 changes: 6 additions & 16 deletions third_party/blink/renderer/core/animation/compositor_animations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,6 @@ bool HasIncompatibleAnimations(const Element& target_element,

CompositorElementIdNamespace CompositorElementNamespaceForProperty(
CSSPropertyID property) {
if (!RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled() &&
!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) {
// Pre-BlinkGenPropertyTrees, all animations affect the primary
// ElementId namespace.
return CompositorElementIdNamespace::kPrimary;
}
switch (property) {
case CSSPropertyID::kOpacity:
case CSSPropertyID::kBackdropFilter:
Expand Down Expand Up @@ -517,16 +511,12 @@ void CompositorAnimations::AttachCompositedLayers(

CompositorElementIdNamespace element_id_namespace =
CompositorElementIdNamespace::kPrimary;
// With BlinkGenPropertyTrees we create an animation namespace element id
// when an element has created all property tree nodes which may be required
// by the keyframe effects. The animation affects multiple element ids, and
// one is pushed each KeyframeModel. See |GetAnimationOnCompositor|.
// Currently we use the kPrimaryEffect node to know if nodes have been
// created for animations.
if (RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled() ||
RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) {
element_id_namespace = CompositorElementIdNamespace::kPrimaryEffect;
}
// We create an animation namespace element id when an element has created all
// property tree nodes which may be required by the keyframe effects. The
// animation affects multiple element ids, and one is pushed each
// KeyframeModel. See |GetAnimationOnCompositor|. We use the kPrimaryEffect
// node to know if nodes have been created for animations.
element_id_namespace = CompositorElementIdNamespace::kPrimaryEffect;
compositor_animation->AttachElement(CompositorElementIdFromUniqueObjectId(
element.GetLayoutObject()->UniqueId(), element_id_namespace));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1835,9 +1835,8 @@ TEST_P(AnimationCompositorAnimationsTest, TrackRafAnimationNoneRegistered) {
}

TEST_P(AnimationCompositorAnimationsTest, CompositedTransformAnimation) {
if (!RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled() ||
// TODO(wangxianzhu): Fix this test for CompositeAfterPaint.
RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
// TODO(wangxianzhu): Fix this test for CompositeAfterPaint.
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
return;

LoadTestData("transform-animation.html");
Expand Down Expand Up @@ -1873,9 +1872,8 @@ TEST_P(AnimationCompositorAnimationsTest, CompositedTransformAnimation) {
}

TEST_P(AnimationCompositorAnimationsTest, CompositedScaleAnimation) {
if (!RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled() ||
// TODO(wangxianzhu): Fix this test for CompositeAfterPaint.
RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
// TODO(wangxianzhu): Fix this test for CompositeAfterPaint.
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
return;

LoadTestData("scale-animation.html");
Expand Down Expand Up @@ -1912,11 +1910,8 @@ TEST_P(AnimationCompositorAnimationsTest, CompositedScaleAnimation) {

TEST_P(AnimationCompositorAnimationsTest,
NonAnimatedTransformPropertyChangeGetsUpdated) {
// This test doesn't apply for pre-BlinkGenPropertyTrees due to the element id
// namespaces.
if (!RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled() ||
// TODO(wangxianzhu): Fix this test for CompositeAfterPaint.
RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
// TODO(wangxianzhu): Fix this test for CompositeAfterPaint.
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
return;

LoadTestData("transform-animation-update.html");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1410,12 +1410,6 @@ TEST_F(DisplayLockContextTest, DescendantAllowedTouchAction) {

TEST_F(DisplayLockContextTest,
CompositedLayerLockCausesGraphicsLayersCollection) {
// This test only tests the BGPT path.
if (!RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled() ||
RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) {
return;
}

ResizeAndFocus();
GetDocument().GetSettings()->SetPreferCompositingToLCDTextEnabled(true);

Expand Down
4 changes: 2 additions & 2 deletions third_party/blink/renderer/core/exported/web_layer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class WebLayerListTest : public PaintTestConfigurations, public testing::Test {

private:
PaintArtifactCompositor* paint_artifact_compositor() {
return GetLocalFrameView()->GetPaintArtifactCompositorForTesting();
return GetLocalFrameView()->GetPaintArtifactCompositor();
}

frame_test_helpers::TestWebWidgetClient web_widget_client_;
Expand Down Expand Up @@ -282,7 +282,7 @@ class WebLayerListSimTest : public PaintTestConfigurations, public SimTest {
}

PaintArtifactCompositor* paint_artifact_compositor() {
return MainFrame().GetFrameView()->GetPaintArtifactCompositorForTesting();
return MainFrame().GetFrameView()->GetPaintArtifactCompositor();
}
};

Expand Down
3 changes: 1 addition & 2 deletions third_party/blink/renderer/core/exported/web_view_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1535,8 +1535,7 @@ void WebViewImpl::EndUpdateLayers() {
MainFrameImpl()->GetFrame()->View()->EnsureUkmAggregator().RecordSample(
LocalFrameUkmAggregator::kUpdateLayers,
update_layers_start_time_.value(), base::TimeTicks::Now());
if (RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled())
probe::LayerTreeDidChange(MainFrameImpl()->GetFrame());
probe::LayerTreeDidChange(MainFrameImpl()->GetFrame());
}
update_layers_start_time_.reset();
}
Expand Down
10 changes: 0 additions & 10 deletions third_party/blink/renderer/core/frame/frame_overlay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ void FrameOverlay::UpdatePrePaint() {
layer_ = std::make_unique<GraphicsLayer>(*this);
layer_->SetDrawsContent(true);
layer_->SetHitTestable(false);

if (!RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled()) {
// This is required for contents of overlay to stay in sync with the page
// while scrolling. When BlinkGenPropertyTrees is enabled, scrolling is
// prevented by using the root scroll node in the root property tree
// state.
cc::Layer* cc_layer = layer_->CcLayer();
cc_layer->AddMainThreadScrollingReasons(
cc::MainThreadScrollingReason::kFrameOverlay);
}
}

DCHECK(parent_layer);
Expand Down
8 changes: 1 addition & 7 deletions third_party/blink/renderer/core/frame/frame_test_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -624,13 +624,7 @@ content::LayerTreeView* LayerTreeViewFactory::Initialize(
// Use synchronous compositing so that the MessageLoop becomes idle and the
// test makes progress.
settings.single_thread_proxy_scheduler = false;
// Both BlinkGenPropertyTrees and CompositeAfterPaint should imply layer lists
// in the compositor. Some code across the boundaries makes assumptions based
// on this so ensure tests run using this configuration as well.
if (RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled() ||
RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) {
settings.use_layer_lists = true;
}
settings.use_layer_lists = true;

layer_tree_view_ = std::make_unique<content::LayerTreeView>(
specified_delegate ? specified_delegate : &delegate_,
Expand Down
143 changes: 52 additions & 91 deletions third_party/blink/renderer/core/frame/local_frame_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2425,8 +2425,7 @@ bool LocalFrameView::RunPrePaintLifecyclePhase(
// PrePaintTreeWalk can reach this frame.
frame_view.SetNeedsPaintPropertyUpdate();
// We may record more foreign layers under the frame.
if (RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled())
frame_view.GraphicsLayersDidChange();
frame_view.GraphicsLayersDidChange();
if (auto* owner = frame_view.GetLayoutEmbeddedContent())
owner->SetShouldCheckForPaintInvalidation();
}
Expand Down Expand Up @@ -2495,56 +2494,51 @@ void LocalFrameView::RunPaintLifecyclePhase() {
}
}

if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled() ||
RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled()) {
if (!print_mode_enabled) {
bool needed_update = !paint_artifact_compositor_ ||
paint_artifact_compositor_->NeedsUpdate();
PushPaintArtifactToCompositor();
ForAllNonThrottledLocalFrameViews([this](LocalFrameView& frame_view) {
DocumentAnimations::UpdateAnimations(
frame_view.GetLayoutView()->GetDocument(),
DocumentLifecycle::kPaintClean, paint_artifact_compositor_.get());
});
if (!print_mode_enabled) {
bool needed_update = !paint_artifact_compositor_ ||
paint_artifact_compositor_->NeedsUpdate();
PushPaintArtifactToCompositor();
ForAllNonThrottledLocalFrameViews([this](LocalFrameView& frame_view) {
DocumentAnimations::UpdateAnimations(
frame_view.GetLayoutView()->GetDocument(),
DocumentLifecycle::kPaintClean, paint_artifact_compositor_.get());
});

// 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();
}
// 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
// lifecycle state can be freed (such as raster invalidations).
if (paint_controller_)
paint_controller_->FinishCycle();

// PaintController for BlinkGenPropertyTrees is transient.
if (RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled() &&
!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) {
// Property tree changed state is typically cleared through
// |PaintController::FinishCycle| but that will be a no-op because
// the paint controller is transient, so force the changed state to be
// cleared here.
if (paint_controller_) {
paint_controller_->ClearPropertyTreeChangedStateTo(
PropertyTreeState::Root());
}
auto* root = GetLayoutView()->Compositor()->PaintRootGraphicsLayer();
if (root) {
ForAllGraphicsLayers(*root, [](GraphicsLayer& layer) {
if (layer.PaintsContentOrHitTest() && layer.HasLayerState()) {
layer.GetPaintController().ClearPropertyTreeChangedStateTo(
layer.GetPropertyTreeState());
}
});
}
// Notify the controller that the artifact has been pushed and some
// lifecycle state can be freed (such as raster invalidations).
if (paint_controller_)
paint_controller_->FinishCycle();

if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) {
// Property tree changed state is typically cleared through
// |PaintController::FinishCycle| but that will be a no-op because
// the paint controller is transient, so force the changed state to be
// cleared here.
if (paint_controller_) {
paint_controller_->ClearPropertyTreeChangedStateTo(
PropertyTreeState::Root());
}
auto* root = GetLayoutView()->Compositor()->PaintRootGraphicsLayer();
if (root) {
ForAllGraphicsLayers(*root, [](GraphicsLayer& layer) {
if (layer.PaintsContentOrHitTest() && layer.HasLayerState()) {
layer.GetPaintController().ClearPropertyTreeChangedStateTo(
layer.GetPropertyTreeState());
}
});
}
}
}
Expand Down Expand Up @@ -2591,7 +2585,6 @@ static void RecordGraphicsLayerAsForeignLayer(

static void CollectViewportLayersForLayerList(GraphicsContext& context,
VisualViewport& visual_viewport) {
DCHECK(RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled());
RecordGraphicsLayerAsForeignLayer(context, visual_viewport.ContainerLayer());
RecordGraphicsLayerAsForeignLayer(context, visual_viewport.PageScaleLayer());
RecordGraphicsLayerAsForeignLayer(context, visual_viewport.ScrollLayer());
Expand All @@ -2600,8 +2593,6 @@ static void CollectViewportLayersForLayerList(GraphicsContext& context,
static void CollectDrawableLayersForLayerListRecursively(
GraphicsContext& context,
const GraphicsLayer* layer) {
DCHECK(RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled());

if (!layer || layer->Client().ShouldThrottleRendering() ||
layer->Client().IsUnderSVGHiddenContainer()) {
return;
Expand Down Expand Up @@ -2629,7 +2620,6 @@ static void CollectDrawableLayersForLayerListRecursively(
layer->GetContentsPropertyTreeState());
}

DCHECK(!layer->ContentsClippingMaskLayer());
for (const auto* child : layer->Children())
CollectDrawableLayersForLayerListRecursively(context, child);
CollectDrawableLayersForLayerListRecursively(context, layer->MaskLayer());
Expand All @@ -2638,8 +2628,6 @@ static void CollectDrawableLayersForLayerListRecursively(
static void CollectLinkHighlightLayersForLayerListRecursively(
GraphicsContext& context,
const GraphicsLayer* layer) {
DCHECK(RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled());

if (!layer || layer->Client().ShouldThrottleRendering())
return;

Expand Down Expand Up @@ -2748,25 +2736,12 @@ void LocalFrameView::PaintTree() {
}

const cc::Layer* LocalFrameView::RootCcLayer() const {
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled() ||
RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled()) {
return paint_artifact_compositor_ ? paint_artifact_compositor_->RootLayer()
: nullptr;
}

if (const auto* root_graphics_layer =
frame_->GetPage()->GetVisualViewport().RootGraphicsLayer()) {
return root_graphics_layer->CcLayer();
}
return nullptr;
return paint_artifact_compositor_ ? paint_artifact_compositor_->RootLayer()
: nullptr;
}

void LocalFrameView::PushPaintArtifactToCompositor() {
TRACE_EVENT0("blink", "LocalFrameView::pushPaintArtifactToCompositor");

DCHECK(RuntimeEnabledFeatures::CompositeAfterPaintEnabled() ||
RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled());

if (!frame_->GetSettings()->GetAcceleratedCompositingEnabled())
return;

Expand All @@ -2781,8 +2756,7 @@ void LocalFrameView::PushPaintArtifactToCompositor() {
// The layer being scrolled is destroyed before the
// ScrollingCoordinator.
WrapWeakPersistent(page->GetScrollingCoordinator())));
if (RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled())
GetLayoutView()->Compositor()->AttachRootLayerViaChromeClient();
GetLayoutView()->Compositor()->AttachRootLayerViaChromeClient();
page->GetChromeClient().AttachRootLayer(
paint_artifact_compositor_->RootLayer(), &GetFrame());
}
Expand All @@ -2809,8 +2783,7 @@ void LocalFrameView::PushPaintArtifactToCompositor() {
settings.prefer_compositing_to_lcd_text =
page->GetSettings().GetPreferCompositingToLCDTextEnabled();

if (RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled() &&
!RuntimeEnabledFeatures::CompositeAfterPaintEnabled() &&
if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled() &&
!paint_controller_) {
// BlinkGenPropertyTrees just needs a transient PaintController to collect
// the foreign layers which doesn't need caching. It also shouldn't affect
Expand Down Expand Up @@ -4017,8 +3990,7 @@ void LocalFrameView::RenderThrottlingStatusChanged() {
DCHECK(!frame_->GetDocument() || !frame_->GetDocument()->InStyleRecalc());

// We may record more/less foreign layers under the frame.
if (RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled())
GraphicsLayersDidChange();
GraphicsLayersDidChange();

if (!CanThrottleRendering())
InvalidateForThrottlingChange();
Expand Down Expand Up @@ -4361,21 +4333,10 @@ MainThreadScrollingReasons LocalFrameView::GetMainThreadScrollingReasons()

String LocalFrameView::MainThreadScrollingReasonsAsText() {
MainThreadScrollingReasons reasons = 0;
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled() ||
RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled()) {
DCHECK(Lifecycle().GetState() >= DocumentLifecycle::kPrePaintClean);
const auto* properties = GetLayoutView()->FirstFragment().PaintProperties();
if (properties && properties->Scroll())
reasons = properties->Scroll()->GetMainThreadScrollingReasons();
} else {
DCHECK(Lifecycle().GetState() >= DocumentLifecycle::kCompositingClean);
reasons = main_thread_scrolling_reasons_;
if (auto* layer_for_scrolling = LayoutViewport()->LayerForScrolling()) {
if (cc::Layer* cc_layer = layer_for_scrolling->CcLayer())
reasons = cc_layer->GetMainThreadScrollingReasons();
}
}

DCHECK(Lifecycle().GetState() >= DocumentLifecycle::kPrePaintClean);
const auto* properties = GetLayoutView()->FirstFragment().PaintProperties();
if (properties && properties->Scroll())
reasons = properties->Scroll()->GetMainThreadScrollingReasons();
return String(cc::MainThreadScrollingReason::AsText(reasons).c_str());
}

Expand Down

0 comments on commit d6c4a0c

Please sign in to comment.