Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 1985973002: Defer compositor context creation to the thread. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..df6b29f0486a0f8def6df1b9727d8c0d2bda6b0c 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -6764,9 +6764,12 @@ 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());
+ TestContextProvider* provider = nullptr;
+ std::unique_ptr<TestContextProvider::DeferredCreate> provider_create(
+ new TestContextProvider::DeferredCreate);
+ provider_create->created_context = &provider;
piman 2016/05/17 03:41:41 here it looks like you could create the TestWGC3D,
std::unique_ptr<OutputSurface> output_surface(
- FakeOutputSurface::Create3d(provider));
+ FakeOutputSurface::Create3d(std::move(provider_create)));
CreateHostImpl(DefaultSettings(), std::move(output_surface));
std::unique_ptr<LayerImpl> root =
@@ -6814,13 +6817,11 @@ 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<TestContextProvider::DeferredCreate> provider_create(
+ new TestContextProvider::DeferredCreate);
+ provider_create->capabilities.post_sub_buffer = true;
std::unique_ptr<FakeOutputSurface> output_surface(
- FakeOutputSurface::Create3d(context_provider));
+ FakeOutputSurface::Create3d(std::move(provider_create)));
FakeOutputSurface* fake_output_surface = output_surface.get();
// This test creates its own LayerTreeHostImpl, so
@@ -6979,8 +6980,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 +7039,16 @@ TEST_F(LayerTreeHostImplTest, NoPartialSwap) {
MockContext* mock_context = mock_context_owned.get();
MockContextHarness harness(mock_context);
+ std::unique_ptr<TestContextProvider::DeferredCreate> compositor_create(
+ new TestContextProvider::DeferredCreate);
+ mock_context->set_have_post_sub_buffer(true);
+ compositor_create->webcontext = std::move(mock_context_owned);
+
// Run test case
LayerTreeSettings settings = DefaultSettings();
settings.renderer_settings.partial_swap_enabled = false;
CreateHostImpl(settings,
- FakeOutputSurface::Create3d(std::move(mock_context_owned)));
+ FakeOutputSurface::Create3d(std::move(compositor_create)));
SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
// Without partial swap, and no clipping, no scissor is set.
@@ -7076,14 +7080,19 @@ 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);
+ std::unique_ptr<TestContextProvider::DeferredCreate> compositor_create(
+ new TestContextProvider::DeferredCreate);
+ mock_context->set_have_post_sub_buffer(true);
+ compositor_create->webcontext = std::move(mock_context_owned);
+
LayerTreeSettings settings = DefaultSettings();
settings.renderer_settings.partial_swap_enabled = true;
CreateHostImpl(settings,
- FakeOutputSurface::Create3d(std::move(context_owned)));
+ FakeOutputSurface::Create3d(std::move(compositor_create)));
SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
// The first frame is not a partially-swapped one. No scissor should be set.
@@ -7190,11 +7199,11 @@ 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<TestContextProvider::DeferredCreate> provider_create(
+ new TestContextProvider::DeferredCreate);
+ provider_create->capabilities.post_sub_buffer = true;
std::unique_ptr<OutputSurface> output_surface(
- FakeOutputSurface::Create3d(provider));
+ FakeOutputSurface::Create3d(std::move(provider_create)));
std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity(
DefaultSettings(), true, this, &task_runner_provider_,
&shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_,
@@ -7220,11 +7229,11 @@ 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<TestContextProvider::DeferredCreate> provider_create(
+ new TestContextProvider::DeferredCreate);
+ provider_create->capabilities.post_sub_buffer = true;
std::unique_ptr<OutputSurface> output_surface(
- FakeOutputSurface::Create3d(provider));
+ FakeOutputSurface::Create3d(std::move(provider_create)));
std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity(
DefaultSettings(), false, this, &task_runner_provider_,
&shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_,
@@ -7772,11 +7781,11 @@ void ShutdownReleasesContext_Callback(
std::unique_ptr<CopyOutputResult> result) {}
TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) {
- scoped_refptr<TestContextProvider> context_provider =
- TestContextProvider::Create();
-
+ TestContextProvider* context_provider = nullptr;
+ auto context_create = base::MakeUnique<TestContextProvider::DeferredCreate>();
+ context_create->created_context = &context_provider;
CreateHostImpl(DefaultSettings(),
- FakeOutputSurface::Create3d(context_provider));
+ FakeOutputSurface::Create3d(std::move(context_create)));
SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
@@ -7792,17 +7801,19 @@ TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) {
host_impl_->DrawLayers(&frame);
host_impl_->DidDrawAllLayers(frame);
+ scoped_refptr<TestContextProvider> saved_context_provider(context_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 +10495,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);
+ std::unique_ptr<TestContextProvider::DeferredCreate> context_with_msaa(
+ new TestContextProvider::DeferredCreate);
+ context_with_msaa->capabilities.max_samples = 8;
- LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings();
- msaaSettings.gpu_rasterization_msaa_sample_count = 4;
- EXPECT_TRUE(CreateHostImpl(
- msaaSettings, FakeOutputSurface::Create3d(std::move(context_with_msaa))));
+ LayerTreeSettings msaa_settings = GpuRasterizationEnabledSettings();
+ msaa_settings.gpu_rasterization_msaa_sample_count = 4;
+ EXPECT_TRUE(CreateHostImpl(msaa_settings, FakeOutputSurface::Create3d(
+ std::move(context_with_msaa))));
host_impl_->SetHasGpuRasterizationTrigger(true);
host_impl_->SetContentIsSuitableForGpuRasterization(false);
EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT,
@@ -10524,11 +10535,12 @@ 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 context_provider_create =
+ base::MakeUnique<TestContextProvider::DeferredCreate>();
+ context_provider_create->capabilities.max_samples = 4;
+ context_provider_create->capabilities.msaa_is_slow = msaa_is_slow;
auto msaa_is_normal_output_surface =
- FakeOutputSurface::Create3d(context_provider);
+ FakeOutputSurface::Create3d(std::move(context_provider_create));
EXPECT_TRUE(
CreateHostImpl(settings, std::move(msaa_is_normal_output_surface)));
}
@@ -10559,19 +10571,19 @@ class MockReclaimResourcesOutputSurface : public FakeOutputSurface {
public:
static std::unique_ptr<MockReclaimResourcesOutputSurface> Create3d() {
return base::WrapUnique(new MockReclaimResourcesOutputSurface(
- TestContextProvider::Create(), TestContextProvider::CreateWorker(),
- false));
+ base::MakeUnique<TestContextProvider::DeferredCreate>(),
+ TestContextProvider::Create(), false));
}
MOCK_METHOD0(ForceReclaimResources, void());
protected:
MockReclaimResourcesOutputSurface(
- scoped_refptr<ContextProvider> context_provider,
+ std::unique_ptr<ContextProvider::DeferredCreate> context_provider_create,
scoped_refptr<ContextProvider> worker_context_provider,
bool delegated_rendering)
- : FakeOutputSurface(context_provider,
- worker_context_provider,
+ : FakeOutputSurface(std::move(context_provider_create),
+ std::move(worker_context_provider),
delegated_rendering) {}
};

Powered by Google App Engine
This is Rietveld 408576698