Index: cc/trees/layer_tree_host_impl_unittest.cc |
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc |
index da8e236d7aa3458cf38f823ba3ffb3b1d261fbb9..c7e3f8f485e15b499fe229928d9f261e61628445 100644 |
--- a/cc/trees/layer_tree_host_impl_unittest.cc |
+++ b/cc/trees/layer_tree_host_impl_unittest.cc |
@@ -119,7 +119,10 @@ class LayerTreeHostImplTest : public testing::Test, |
CreateHostImpl(DefaultSettings(), CreateOutputSurface()); |
} |
- void TearDown() override {} |
+ void TearDown() override { |
+ if (host_impl_) |
+ host_impl_->ReleaseOutputSurface(); |
+ } |
void UpdateRendererCapabilitiesOnImplThread() override {} |
void DidLoseOutputSurfaceOnImplThread() override {} |
@@ -191,6 +194,8 @@ class LayerTreeHostImplTest : public testing::Test, |
const LayerTreeSettings& settings, |
std::unique_ptr<OutputSurface> output_surface, |
TaskRunnerProvider* task_runner_provider) { |
+ if (host_impl_) |
+ host_impl_->ReleaseOutputSurface(); |
host_impl_ = LayerTreeHostImpl::Create( |
settings, this, task_runner_provider, &stats_instrumentation_, |
&shared_bitmap_manager_, &gpu_memory_buffer_manager_, |
@@ -343,17 +348,15 @@ class LayerTreeHostImplTest : public testing::Test, |
Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, |
kOuterViewportScrollLayerId); |
+ layer_tree_impl->property_trees()->needs_rebuild = true; |
+ layer_tree_impl->BuildLayerListAndPropertyTreesForTesting(); |
layer_tree_impl->DidBecomeActive(); |
return layer_tree_impl->InnerViewportScrollLayer(); |
} |
LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { |
- LayerImpl* scroll_layer = CreateScrollAndContentsLayers( |
- host_impl_->active_tree(), content_size); |
- SetNeedsRebuildPropertyTrees(); |
- RebuildPropertyTrees(); |
- host_impl_->active_tree()->DidBecomeActive(); |
- return scroll_layer; |
+ return CreateScrollAndContentsLayers(host_impl_->active_tree(), |
+ content_size); |
} |
// Sets up a typical virtual viewport setup with one child content layer. |
@@ -381,6 +384,7 @@ class LayerTreeHostImplTest : public testing::Test, |
->parent; |
inner_clip_layer->SetBounds(viewport_size); |
host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size); |
+ host_impl_->active_tree()->property_trees()->needs_rebuild = true; |
host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
host_impl_->SetViewportSize(viewport_size); |
@@ -1361,6 +1365,8 @@ TEST_F(LayerTreeHostImplTest, AnimationSchedulingActiveTree) { |
child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
child->SetDrawsContent(true); |
+ host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
+ |
// Add a translate from 6,7 to 8,9. |
TransformOperations start; |
start.AppendTranslate(6.f, 7.f, 0.f); |
@@ -1447,6 +1453,7 @@ TEST_F(LayerTreeHostImplTest, AnimationSchedulingCommitToActiveTree) { |
EXPECT_FALSE(did_request_commit_); |
// Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away. |
+ host_impl_->ReleaseOutputSurface(); |
host_impl_ = nullptr; |
} |
@@ -1465,6 +1472,8 @@ TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) { |
child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
child->SetDrawsContent(true); |
+ host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
+ |
// Add a translate animation. |
TransformOperations start; |
start.AppendTranslate(6.f, 7.f, 0.f); |
@@ -1497,6 +1506,8 @@ TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) { |
root->test_properties()->RemoveChild(child); |
child = nullptr; |
+ host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
+ |
// Doing Animate() doesn't request another frame after the current one. |
host_impl_->Animate(); |
EXPECT_FALSE(did_request_next_frame_); |
@@ -2488,7 +2499,6 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) { |
CreateScrollAndContentsLayers( |
host_impl_->pending_tree(), |
gfx::Size(100, 100)); |
- host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
host_impl_->ActivateSyncTree(); |
host_impl_->active_tree()->SetRootLayerFromLayerListForTesting(); |
DrawFrame(); |
@@ -2713,6 +2723,9 @@ class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl { |
class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest { |
protected: |
void SetupLayers(LayerTreeSettings settings) { |
+ host_impl_->ReleaseOutputSurface(); |
+ host_impl_ = nullptr; |
+ |
gfx::Size content_size(100, 100); |
LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = |
@@ -2924,6 +2937,7 @@ class LayerTreeHostImplTestScrollbarOpacity : public LayerTreeHostImplTest { |
scrollbar->SetScrollLayerId(scroll->id()); |
container->test_properties()->AddChild(std::move(scrollbar)); |
host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
+ host_impl_->pending_tree()->property_trees()->needs_rebuild = true; |
host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
host_impl_->ActivateSyncTree(); |
@@ -3167,6 +3181,8 @@ void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale( |
->InnerViewportContainerLayer() |
->test_properties() |
->AddChild(std::move(scrollbar)); |
+ host_impl_->active_tree()->property_trees()->needs_rebuild = true; |
+ host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
host_impl_->active_tree()->DidBecomeActive(); |
DrawFrame(); |
@@ -3882,7 +3898,6 @@ TEST_F(LayerTreeHostImplTest, ClampingAfterActivation) { |
host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
CreateScrollAndContentsLayers(host_impl_->pending_tree(), |
gfx::Size(100, 100)); |
- host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
host_impl_->ActivateSyncTree(); |
host_impl_->CreatePendingTree(); |
@@ -3982,6 +3997,7 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest { |
tree_impl->SetViewportLayersFromIds(Layer::INVALID_ID, page_scale_layer_id, |
inner_viewport_scroll_layer_id, |
outer_viewport_scroll_layer_id); |
+ tree_impl->property_trees()->needs_rebuild = true; |
tree_impl->BuildLayerListAndPropertyTreesForTesting(); |
host_impl_->SetViewportSize(inner_viewport_size); |
@@ -5867,12 +5883,12 @@ TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { |
host_impl_->CreatePendingTree(); |
host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size); |
- host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
host_impl_->ActivateSyncTree(); |
EXPECT_EQ(gfx::SizeF(new_size), scroll_watcher.scrollable_size()); |
// Tear down the LayerTreeHostImpl before the InputHandlerClient. |
- host_impl_.reset(); |
+ host_impl_->ReleaseOutputSurface(); |
+ host_impl_ = nullptr; |
} |
void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) { |
@@ -7041,6 +7057,8 @@ TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { |
expected_swap_rect = gfx::Rect(0, 0, 10, 10); |
EXPECT_EQ(expected_swap_rect.ToString(), |
fake_output_surface->last_swap_rect().ToString()); |
+ |
+ layer_tree_host_impl->ReleaseOutputSurface(); |
} |
TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { |
@@ -7361,6 +7379,7 @@ TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { |
my_host_impl->DrawLayers(&frame); |
my_host_impl->DidDrawAllLayers(frame); |
} |
+ my_host_impl->ReleaseOutputSurface(); |
} |
TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { |
@@ -7391,6 +7410,7 @@ TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { |
my_host_impl->DrawLayers(&frame); |
my_host_impl->DidDrawAllLayers(frame); |
} |
+ my_host_impl->ReleaseOutputSurface(); |
} |
TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { |
@@ -7763,6 +7783,9 @@ TEST_F(LayerTreeHostImplTest, |
// Checks that we have a non-0 default allocation if we pass a context that |
// doesn't support memory management extensions. |
TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { |
+ host_impl_->ReleaseOutputSurface(); |
+ host_impl_ = nullptr; |
+ |
LayerTreeSettings settings = DefaultSettings(); |
host_impl_ = LayerTreeHostImpl::Create( |
settings, this, &task_runner_provider_, &stats_instrumentation_, |
@@ -7945,6 +7968,7 @@ TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { |
EXPECT_FALSE(context_provider->HasOneRef()); |
EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); |
+ host_impl_->ReleaseOutputSurface(); |
host_impl_ = nullptr; |
// The CopyOutputResult's callback was cancelled, the CopyOutputResult |
@@ -10896,6 +10920,9 @@ TEST_F(LayerTreeHostImplTest, JitterTest) { |
// with a software OutputSurface, LayerTreeHostImpl correctly re-computes GPU |
// rasterization status. |
TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnOutputSurfaceChange) { |
+ host_impl_->ReleaseOutputSurface(); |
+ host_impl_ = nullptr; |
+ |
LayerTreeSettings settings = DefaultSettings(); |
settings.gpu_rasterization_forced = true; |