Commit 4f119828 authored by Saman Sami's avatar Saman Sami Committed by Commit Bot

Enforce valid LocalSurfaceId in LayerTreeImpl if Surface Sync is on

With surface sync on, the active tree is always expected to have a valid LocalSurfaceId, otherwise
surface invariants violations might be caused.

Bug: 672962
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel
Change-Id: I71dea254f4208c76189dacfb4c4682aa6a5d72cb
Reviewed-on: https://chromium-review.googlesource.com/960585Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Commit-Queue: Saman Sami <samans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542934}
parent a3db9c71
......@@ -1962,8 +1962,14 @@ bool LayerTreeHostImpl::DrawLayers(FrameData* frame) {
compositor_frame.render_pass_list = std::move(frame->render_passes);
// TODO(fsamuel): Once all clients get their viz::LocalSurfaceId from their
// parent, the viz::LocalSurfaceId should hang off CompositorFrameMetadata.
if (settings_.enable_surface_synchronization &&
active_tree()->local_surface_id().is_valid()) {
if (settings_.enable_surface_synchronization) {
// If surface synchronization is on, we should always have a valid
// LocalSurfaceId in LayerTreeImpl unless we don't have a scheduler because
// without a scheduler commits are not deferred and LayerTrees without valid
// LocalSurfaceId might slip through, but single-thread-without-scheduler
// mode is only used in tests so it doesn't matter.
CHECK(!settings_.single_thread_proxy_scheduler ||
active_tree()->local_surface_id().is_valid());
layer_tree_frame_sink_->SetLocalSurfaceId(
active_tree()->local_surface_id());
last_draw_local_surface_id_ = active_tree()->local_surface_id();
......
......@@ -177,7 +177,11 @@ class LayerTreeHostImplTest : public testing::Test,
animation_task_ = task;
requested_animation_delay_ = delay;
}
void DidActivateSyncTree() override {}
void DidActivateSyncTree() override {
// Make sure the active tree always has a valid LocalSurfaceId.
host_impl_->active_tree()->set_local_surface_id(
viz::LocalSurfaceId(1, base::UnguessableToken::Deserialize(2u, 3u)));
}
void WillPrepareTiles() override {}
void DidPrepareTiles() override {}
void DidCompletePageScaleAnimationOnImplThread() override {
......@@ -237,6 +241,8 @@ class LayerTreeHostImplTest : public testing::Test,
bool init = host_impl_->InitializeRenderer(layer_tree_frame_sink_.get());
host_impl_->SetViewportSize(gfx::Size(10, 10));
host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
host_impl_->active_tree()->set_local_surface_id(
viz::LocalSurfaceId(1, base::UnguessableToken::Deserialize(2u, 3u)));
// Set the viz::BeginFrameArgs so that methods which use it are able to.
host_impl_->WillBeginImplFrame(viz::CreateBeginFrameArgsForTesting(
BEGINFRAME_FROM_HERE, 0, 1,
......@@ -3496,6 +3502,8 @@ class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest {
host_impl_->active_tree()->BuildPropertyTreesForTesting();
host_impl_->active_tree()->DidBecomeActive();
host_impl_->active_tree()->HandleScrollbarShowRequestsFromMain();
host_impl_->active_tree()->set_local_surface_id(
viz::LocalSurfaceId(1, base::UnguessableToken::Deserialize(2u, 3u)));
DrawFrame();
// SetScrollElementId will initialize the scrollbar which will cause it to
......@@ -8796,7 +8804,10 @@ class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest {
VerifyLayerIsLargerThanViewport(last_on_draw_render_passes_);
}
void DidActivateSyncTree() override { did_activate_pending_tree_ = true; }
void DidActivateSyncTree() override {
LayerTreeHostImplTest::DidActivateSyncTree();
did_activate_pending_tree_ = true;
}
void set_gutter_quad_material(viz::DrawQuad::Material material) {
gutter_quad_material_ = material;
......@@ -8979,6 +8990,8 @@ TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) {
root->test_properties()->AddChild(std::move(child));
layer_tree_host_impl->active_tree()->SetRootLayerForTesting(std::move(root));
layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting();
layer_tree_host_impl->active_tree()->set_local_surface_id(
viz::LocalSurfaceId(1, base::UnguessableToken::Deserialize(2u, 3u)));
TestFrameData frame;
......
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