Commit f9f88ae5 authored by Eric Karl's avatar Eric Karl Committed by Commit Bot

Temporary fix for top controls ratio propagation from main to impl

The impl tree viewport changes caused by |top_controls_shown_ratio_|
changes are not reflected on the main thread when the top controls are
partially shown. This causes a mismatch each time we push property trees
from main > impl.

This change provides a temporary fix by updating the viewport any time
we push main > impl when in a partially shown state.

Long term we should propagate these changes to the main tree and
avoid this workaround.

Bug: 875943
Change-Id: I47e6a5127e6a2c76b5286e257904d2501e3859a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1795572
Commit-Queue: Eric Karl <ericrk@chromium.org>
Commit-Queue: Khushal <khushalsagar@chromium.org>
Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Auto-Submit: Eric Karl <ericrk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695372}
parent 01844d62
......@@ -1619,6 +1619,15 @@ void LayerTreeHost::PushLayerTreePropertiesTo(LayerTreeImpl* tree_impl) {
tree_impl->RequestForceSendMetadata();
tree_impl->set_has_ever_been_drawn(false);
// TODO(ericrk): The viewport changes caused by |top_controls_shown_ratio_|
// changes should propagate back to the main tree. This does not currently
// happen, so we must force the impl tree to update its viewports if
// |top_controls_shown_ratio_| is greater than 0.0f and less than 1.0f
// (partially shown). crbug.com/875943
if (top_controls_shown_ratio_ > 0.0f && top_controls_shown_ratio_ < 1.0f) {
tree_impl->UpdateViewportContainerSizes();
}
}
void LayerTreeHost::PushSurfaceRangesTo(LayerTreeImpl* tree_impl) {
......
......@@ -8811,5 +8811,52 @@ class LayerTreeHostTestPartialTileDamage : public LayerTreeHostTest {
MULTI_THREAD_TEST_F(LayerTreeHostTestPartialTileDamage);
// Make sure that a change in top controls shown ratio causes an update to the
// pending tree's viewports.
class LayerTreeHostTopControlsDeltaTriggersViewportUpdate
: public LayerTreeHostTest {
public:
void BeginTest() override { PostSetNeedsCommitToMainThread(); }
void SetupTree() override {
LayerTreeHostTest::SetupTree();
Layer* root_layer = layer_tree_host()->root_layer();
// Set up scrollable root.
root_layer->SetBounds(gfx::Size(100, 100));
SetupViewport(root_layer, gfx::Size(50, 50), root_layer->bounds());
// Set browser controls to be partially shown.
layer_tree_host()->SetBrowserControlsHeight(kTopControlsHeight, 0.0f,
true /* shrink */);
layer_tree_host()->SetBrowserControlsShownRatio(kTopControlsShownRatio);
}
void BeginCommitOnThread(LayerTreeHostImpl* impl) override {
// Before commit the inner_viewport_container_bounds_delta() value should
// not reflect the partially shown top controls.
float bounds_delta = impl->pending_tree()
->property_trees()
->inner_viewport_container_bounds_delta()
.y();
EXPECT_EQ(bounds_delta, 0.0f);
}
void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
// After commit the inner_viewport_container_bounds_delta() value should
// reflect the partially shown top controls.
float bounds_delta = impl->pending_tree()
->property_trees()
->inner_viewport_container_bounds_delta()
.y();
EXPECT_EQ(bounds_delta,
kTopControlsHeight - kTopControlsHeight * kTopControlsShownRatio);
EndTest();
}
static constexpr float kTopControlsHeight = 10.0f;
static constexpr float kTopControlsShownRatio = 0.3f;
};
MULTI_THREAD_TEST_F(LayerTreeHostTopControlsDeltaTriggersViewportUpdate);
} // namespace
} // namespace cc
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