| 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 264af100de4932b8c495fbeb8d4f0f65a64cbe2f..1984e512a70c35f8d3a60460c33d2de2a224bee7 100644
|
| --- a/cc/trees/layer_tree_host_impl_unittest.cc
|
| +++ b/cc/trees/layer_tree_host_impl_unittest.cc
|
| @@ -711,14 +711,11 @@ TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) {
|
| }
|
|
|
| TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) {
|
| - std::unique_ptr<TestWebGraphicsContext3D> context_owned =
|
| - TestWebGraphicsContext3D::Create();
|
| - context_owned->set_context_lost(true);
|
| -
|
| // Initialization will fail.
|
| - EXPECT_FALSE(
|
| - CreateHostImpl(DefaultSettings(),
|
| - FakeOutputSurface::Create3d(std::move(context_owned))));
|
| + EXPECT_FALSE(CreateHostImpl(
|
| + DefaultSettings(), FakeOutputSurface::Create3d(
|
| + base::MakeUnique<TestContextProvider::Factory>(
|
| + TestContextProvider::Factory::kFailCreate))));
|
|
|
| SetupScrollAndContentsLayers(gfx::Size(100, 100));
|
|
|
| @@ -6764,10 +6761,11 @@ class FakeDrawableLayerImpl: public LayerImpl {
|
| // can leave the window at the wrong size if we never draw and the proper
|
| // viewport size is never set.
|
| TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) {
|
| - scoped_refptr<TestContextProvider> provider(TestContextProvider::Create());
|
| - std::unique_ptr<OutputSurface> output_surface(
|
| - FakeOutputSurface::Create3d(provider));
|
| + std::unique_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
|
| + base::MakeUnique<TestContextProvider::Factory>()));
|
| CreateHostImpl(DefaultSettings(), std::move(output_surface));
|
| + auto* provider = static_cast<TestContextProvider*>(
|
| + host_impl_->output_surface()->context_provider());
|
|
|
| std::unique_ptr<LayerImpl> root =
|
| FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
|
| @@ -6814,13 +6812,10 @@ TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) {
|
| // Make sure damage tracking propagates all the way to the graphics context,
|
| // where it should request to swap only the sub-buffer that is damaged.
|
| TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) {
|
| - scoped_refptr<TestContextProvider> context_provider(
|
| - TestContextProvider::Create());
|
| - context_provider->BindToCurrentThread();
|
| - context_provider->TestContext3d()->set_have_post_sub_buffer(true);
|
| -
|
| - std::unique_ptr<FakeOutputSurface> output_surface(
|
| - FakeOutputSurface::Create3d(context_provider));
|
| + gpu::Capabilities capabilities;
|
| + capabilities.post_sub_buffer = true;
|
| + std::unique_ptr<FakeOutputSurface> output_surface(FakeOutputSurface::Create3d(
|
| + base::MakeUnique<TestContextProvider::Factory>(capabilities)));
|
| FakeOutputSurface* fake_output_surface = output_surface.get();
|
|
|
| // This test creates its own LayerTreeHostImpl, so
|
| @@ -6979,8 +6974,6 @@ class MockContextHarness {
|
| public:
|
| explicit MockContextHarness(MockContext* context)
|
| : context_(context) {
|
| - context_->set_have_post_sub_buffer(true);
|
| -
|
| // Catch "uninteresting" calls
|
| EXPECT_CALL(*context_, useProgram(_))
|
| .Times(0);
|
| @@ -7040,11 +7033,14 @@ TEST_F(LayerTreeHostImplTest, NoPartialSwap) {
|
| MockContext* mock_context = mock_context_owned.get();
|
| MockContextHarness harness(mock_context);
|
|
|
| + mock_context->set_have_post_sub_buffer(true);
|
| +
|
| // Run test case
|
| LayerTreeSettings settings = DefaultSettings();
|
| settings.renderer_settings.partial_swap_enabled = false;
|
| - CreateHostImpl(settings,
|
| - FakeOutputSurface::Create3d(std::move(mock_context_owned)));
|
| + CreateHostImpl(settings, FakeOutputSurface::Create3d(
|
| + base::MakeUnique<TestContextProvider::Factory>(
|
| + std::move(mock_context_owned))));
|
| SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
|
|
|
| // Without partial swap, and no clipping, no scissor is set.
|
| @@ -7076,14 +7072,17 @@ TEST_F(LayerTreeHostImplTest, NoPartialSwap) {
|
| }
|
|
|
| TEST_F(LayerTreeHostImplTest, PartialSwap) {
|
| - std::unique_ptr<MockContext> context_owned(new MockContext);
|
| - MockContext* mock_context = context_owned.get();
|
| + std::unique_ptr<MockContext> mock_context_owned(new MockContext);
|
| + MockContext* mock_context = mock_context_owned.get();
|
| MockContextHarness harness(mock_context);
|
|
|
| + mock_context->set_have_post_sub_buffer(true);
|
| +
|
| LayerTreeSettings settings = DefaultSettings();
|
| settings.renderer_settings.partial_swap_enabled = true;
|
| - CreateHostImpl(settings,
|
| - FakeOutputSurface::Create3d(std::move(context_owned)));
|
| + CreateHostImpl(settings, FakeOutputSurface::Create3d(
|
| + base::MakeUnique<TestContextProvider::Factory>(
|
| + std::move(mock_context_owned))));
|
| SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
|
|
|
| // The first frame is not a partially-swapped one. No scissor should be set.
|
| @@ -7190,11 +7189,10 @@ static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity(
|
| TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) {
|
| TestSharedBitmapManager shared_bitmap_manager;
|
| TestTaskGraphRunner task_graph_runner;
|
| - scoped_refptr<TestContextProvider> provider(TestContextProvider::Create());
|
| - provider->BindToCurrentThread();
|
| - provider->TestContext3d()->set_have_post_sub_buffer(true);
|
| - std::unique_ptr<OutputSurface> output_surface(
|
| - FakeOutputSurface::Create3d(provider));
|
| + gpu::Capabilities capabilities;
|
| + capabilities.post_sub_buffer = true;
|
| + std::unique_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
|
| + base::MakeUnique<TestContextProvider::Factory>(capabilities)));
|
| std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity(
|
| DefaultSettings(), true, this, &task_runner_provider_,
|
| &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_,
|
| @@ -7220,11 +7218,10 @@ TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) {
|
| TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) {
|
| TestSharedBitmapManager shared_bitmap_manager;
|
| TestTaskGraphRunner task_graph_runner;
|
| - scoped_refptr<TestContextProvider> provider(TestContextProvider::Create());
|
| - provider->BindToCurrentThread();
|
| - provider->TestContext3d()->set_have_post_sub_buffer(true);
|
| - std::unique_ptr<OutputSurface> output_surface(
|
| - FakeOutputSurface::Create3d(provider));
|
| + gpu::Capabilities capabilities;
|
| + capabilities.post_sub_buffer = true;
|
| + std::unique_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
|
| + base::MakeUnique<TestContextProvider::Factory>(capabilities)));
|
| std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity(
|
| DefaultSettings(), false, this, &task_runner_provider_,
|
| &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_,
|
| @@ -7772,11 +7769,11 @@ void ShutdownReleasesContext_Callback(
|
| std::unique_ptr<CopyOutputResult> result) {}
|
|
|
| TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) {
|
| - scoped_refptr<TestContextProvider> context_provider =
|
| - TestContextProvider::Create();
|
| -
|
| CreateHostImpl(DefaultSettings(),
|
| - FakeOutputSurface::Create3d(context_provider));
|
| + FakeOutputSurface::Create3d(
|
| + base::MakeUnique<TestContextProvider::Factory>()));
|
| + auto* provider = static_cast<TestContextProvider*>(
|
| + host_impl_->output_surface()->context_provider());
|
|
|
| SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
|
|
|
| @@ -7792,17 +7789,19 @@ TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) {
|
| host_impl_->DrawLayers(&frame);
|
| host_impl_->DidDrawAllLayers(frame);
|
|
|
| + scoped_refptr<TestContextProvider> saved_context_provider(provider);
|
| +
|
| // The CopyOutputResult's callback has a ref on the ContextProvider and a
|
| // texture in a texture mailbox.
|
| - EXPECT_FALSE(context_provider->HasOneRef());
|
| - EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
|
| + EXPECT_FALSE(saved_context_provider->HasOneRef());
|
| + EXPECT_EQ(1u, saved_context_provider->TestContext3d()->NumTextures());
|
|
|
| host_impl_ = nullptr;
|
|
|
| // The CopyOutputResult's callback was cancelled, the CopyOutputResult
|
| // released, and the texture deleted.
|
| - EXPECT_TRUE(context_provider->HasOneRef());
|
| - EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures());
|
| + EXPECT_TRUE(saved_context_provider->HasOneRef());
|
| + EXPECT_EQ(0u, saved_context_provider->TestContext3d()->NumTextures());
|
| }
|
|
|
| TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) {
|
| @@ -10484,14 +10483,14 @@ TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusModes) {
|
| EXPECT_FALSE(host_impl_->use_gpu_rasterization());
|
| EXPECT_FALSE(host_impl_->use_msaa());
|
|
|
| - std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa =
|
| - TestWebGraphicsContext3D::Create();
|
| - context_with_msaa->SetMaxSamples(8);
|
| -
|
| - LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings();
|
| - msaaSettings.gpu_rasterization_msaa_sample_count = 4;
|
| - EXPECT_TRUE(CreateHostImpl(
|
| - msaaSettings, FakeOutputSurface::Create3d(std::move(context_with_msaa))));
|
| + gpu::Capabilities capabilities_with_msaa;
|
| + capabilities_with_msaa.max_samples = 8;
|
| + LayerTreeSettings msaa_settings = GpuRasterizationEnabledSettings();
|
| + msaa_settings.gpu_rasterization_msaa_sample_count = 4;
|
| + EXPECT_TRUE(CreateHostImpl(msaa_settings,
|
| + FakeOutputSurface::Create3d(
|
| + base::MakeUnique<TestContextProvider::Factory>(
|
| + capabilities_with_msaa))));
|
| host_impl_->SetHasGpuRasterizationTrigger(true);
|
| host_impl_->SetContentIsSuitableForGpuRasterization(false);
|
| EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT,
|
| @@ -10524,11 +10523,11 @@ class MsaaIsSlowLayerTreeHostImplTest : public LayerTreeHostImplTest {
|
| LayerTreeSettings settings = DefaultSettings();
|
| settings.gpu_rasterization_enabled = true;
|
| settings.gpu_rasterization_msaa_sample_count = 4;
|
| - auto context_provider = TestContextProvider::Create();
|
| - context_provider->UnboundTestContext3d()->SetMaxSamples(4);
|
| - context_provider->UnboundTestContext3d()->set_msaa_is_slow(msaa_is_slow);
|
| - auto msaa_is_normal_output_surface =
|
| - FakeOutputSurface::Create3d(context_provider);
|
| + gpu::Capabilities capabilities_with_msaa;
|
| + capabilities_with_msaa.max_samples = 4;
|
| + capabilities_with_msaa.msaa_is_slow = msaa_is_slow;
|
| + auto msaa_is_normal_output_surface = FakeOutputSurface::Create3d(
|
| + base::MakeUnique<TestContextProvider::Factory>(capabilities_with_msaa));
|
| EXPECT_TRUE(
|
| CreateHostImpl(settings, std::move(msaa_is_normal_output_surface)));
|
| }
|
| @@ -10557,21 +10556,20 @@ TEST_F(MsaaIsSlowLayerTreeHostImplTest, GpuRasterizationStatusMsaaIsSlow) {
|
| // A mock output surface which lets us detect calls to ForceReclaimResources.
|
| class MockReclaimResourcesOutputSurface : public FakeOutputSurface {
|
| public:
|
| - static std::unique_ptr<MockReclaimResourcesOutputSurface> Create3d() {
|
| - return base::WrapUnique(new MockReclaimResourcesOutputSurface(
|
| - TestContextProvider::Create(), TestContextProvider::CreateWorker(),
|
| - false));
|
| - }
|
| + MockReclaimResourcesOutputSurface()
|
| + : FakeOutputSurface(base::MakeUnique<TestContextProvider::Factory>(),
|
| + TestContextProvider::Create(),
|
| + false /* delegated rendering */) {}
|
|
|
| MOCK_METHOD0(ForceReclaimResources, void());
|
|
|
| protected:
|
| MockReclaimResourcesOutputSurface(
|
| - scoped_refptr<ContextProvider> context_provider,
|
| + std::unique_ptr<ContextProvider::Factory> compositor_context_factory,
|
| scoped_refptr<ContextProvider> worker_context_provider,
|
| bool delegated_rendering)
|
| - : FakeOutputSurface(context_provider,
|
| - worker_context_provider,
|
| + : FakeOutputSurface(std::move(compositor_context_factory),
|
| + std::move(worker_context_provider),
|
| delegated_rendering) {}
|
| };
|
|
|
| @@ -10581,7 +10579,7 @@ class MockReclaimResourcesOutputSurface : public FakeOutputSurface {
|
| // crbug.com/489515.
|
| TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) {
|
| std::unique_ptr<MockReclaimResourcesOutputSurface> output_surface(
|
| - MockReclaimResourcesOutputSurface::Create3d());
|
| + new MockReclaimResourcesOutputSurface);
|
| // Hold an unowned pointer to the output surface to use for mock expectations.
|
| MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get();
|
|
|
|
|