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 bd031eace7f0c77a60702366cdd1cc662408c75d..b2793d24acdd602848fe76e9b153877b68173804 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); |
@@ -614,6 +618,7 @@ TEST_F(LayerTreeHostImplTest, ScrollDeltaTreeButNoChanges) { |
->AddChild(LayerImpl::Create(host_impl_->active_tree(), 6)); |
host_impl_->active_tree()->SetRootLayer(std::move(root)); |
} |
+ host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
LayerImpl* root = host_impl_->active_tree()->root_layer(); |
ExpectClearedScrollDeltasRecursive(root); |
@@ -1359,6 +1364,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); |
@@ -1445,6 +1452,7 @@ TEST_F(LayerTreeHostImplTest, AnimationSchedulingCommitToActiveTree) { |
EXPECT_FALSE(did_request_commit_); |
// Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away. |
+ host_impl_->ReleaseOutputSurface(); |
host_impl_ = nullptr; |
} |
@@ -1463,6 +1471,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); |
@@ -1495,6 +1505,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_); |
@@ -2486,7 +2498,6 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) { |
CreateScrollAndContentsLayers( |
host_impl_->pending_tree(), |
gfx::Size(100, 100)); |
- host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
host_impl_->ActivateSyncTree(); |
DrawFrame(); |
@@ -2710,6 +2721,9 @@ class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl { |
class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest { |
protected: |
void SetupLayers(LayerTreeSettings settings) { |
+ host_impl_->ReleaseOutputSurface(); |
enne (OOO)
2016/06/27 22:22:20
What's with this setup function and some tests tha
danakj
2016/06/27 22:24:36
Well, some tests replace host_impl_ with their own
|
+ host_impl_ = nullptr; |
+ |
gfx::Size content_size(100, 100); |
LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = |
@@ -2921,6 +2935,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(); |
@@ -3164,6 +3179,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(); |
@@ -3879,7 +3896,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(); |
@@ -3979,6 +3995,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); |
@@ -5860,12 +5877,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) { |
@@ -7031,6 +7048,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) { |
@@ -7349,6 +7368,7 @@ TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { |
my_host_impl->DrawLayers(&frame); |
my_host_impl->DidDrawAllLayers(frame); |
} |
+ my_host_impl->ReleaseOutputSurface(); |
} |
TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { |
@@ -7379,6 +7399,7 @@ TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { |
my_host_impl->DrawLayers(&frame); |
my_host_impl->DidDrawAllLayers(frame); |
} |
+ my_host_impl->ReleaseOutputSurface(); |
} |
TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { |
@@ -7749,6 +7770,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_, |
@@ -7931,6 +7955,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 |
@@ -10277,6 +10302,7 @@ TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) { |
layer->tilings()->UpdateTilePriorities(gfx::Rect(gfx::Size(10, 10)), 1.f, 1.0, |
Occlusion(), true); |
host_impl_->pending_tree()->SetRootLayer(std::move(layer)); |
+ host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
FakePictureLayerImpl* root_layer = static_cast<FakePictureLayerImpl*>( |
host_impl_->pending_tree()->root_layer()); |
@@ -10878,6 +10904,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; |