| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/test/layer_tree_pixel_test.h" | 5 #include "cc/test/layer_tree_pixel_test.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 namespace cc { | 31 namespace cc { |
| 32 | 32 |
| 33 LayerTreePixelTest::LayerTreePixelTest() | 33 LayerTreePixelTest::LayerTreePixelTest() |
| 34 : pixel_comparator_(new ExactPixelComparator(true)), | 34 : pixel_comparator_(new ExactPixelComparator(true)), |
| 35 test_type_(PIXEL_TEST_GL), | 35 test_type_(PIXEL_TEST_GL), |
| 36 pending_texture_mailbox_callbacks_(0) {} | 36 pending_texture_mailbox_callbacks_(0) {} |
| 37 | 37 |
| 38 LayerTreePixelTest::~LayerTreePixelTest() {} | 38 LayerTreePixelTest::~LayerTreePixelTest() {} |
| 39 | 39 |
| 40 std::unique_ptr<TestDelegatingOutputSurface> | 40 void LayerTreePixelTest::InitializeSettings(LayerTreeSettings* settings) { |
| 41 LayerTreePixelTest::CreateDelegatingOutputSurface( | 41 // The PixelTestDelegatingOutputSurface will provide a BeginFrameSource. |
| 42 scoped_refptr<ContextProvider>, | 42 settings->use_output_surface_begin_frame_source = true; |
| 43 scoped_refptr<ContextProvider>) { | 43 } |
| 44 |
| 45 std::unique_ptr<OutputSurface> LayerTreePixelTest::CreateOutputSurface() { |
| 46 // Always test Webview shenanigans. |
| 47 gfx::Size surface_expansion_size(40, 60); |
| 48 |
| 44 scoped_refptr<TestInProcessContextProvider> compositor_context_provider; | 49 scoped_refptr<TestInProcessContextProvider> compositor_context_provider; |
| 45 scoped_refptr<TestInProcessContextProvider> worker_context_provider; | 50 scoped_refptr<TestInProcessContextProvider> worker_context_provider; |
| 51 scoped_refptr<TestInProcessContextProvider> display_context_provider; |
| 52 std::unique_ptr<PixelTestOutputSurface> display_output_surface; |
| 46 if (test_type_ == PIXEL_TEST_GL) { | 53 if (test_type_ == PIXEL_TEST_GL) { |
| 47 compositor_context_provider = new TestInProcessContextProvider(nullptr); | 54 compositor_context_provider = new TestInProcessContextProvider(nullptr); |
| 48 worker_context_provider = | 55 worker_context_provider = |
| 49 new TestInProcessContextProvider(compositor_context_provider.get()); | 56 new TestInProcessContextProvider(compositor_context_provider.get()); |
| 50 } | 57 display_context_provider = new TestInProcessContextProvider(nullptr); |
| 51 bool synchronous_composite = | |
| 52 !HasImplThread() && | |
| 53 !layer_tree_host()->settings().single_thread_proxy_scheduler; | |
| 54 // Allow resource reclaiming for partial raster tests to get back | |
| 55 // resources from the Display. | |
| 56 bool force_disable_reclaim_resources = false; | |
| 57 auto delegating_output_surface = | |
| 58 base::MakeUnique<TestDelegatingOutputSurface>( | |
| 59 compositor_context_provider, std::move(worker_context_provider), | |
| 60 CreateDisplayOutputSurface(compositor_context_provider), | |
| 61 shared_bitmap_manager(), gpu_memory_buffer_manager(), | |
| 62 RendererSettings(), ImplThreadTaskRunner(), synchronous_composite, | |
| 63 force_disable_reclaim_resources); | |
| 64 delegating_output_surface->display()->SetEnlargePassTextureAmountForTesting( | |
| 65 enlarge_texture_amount_); | |
| 66 return delegating_output_surface; | |
| 67 } | |
| 68 | |
| 69 std::unique_ptr<OutputSurface> LayerTreePixelTest::CreateDisplayOutputSurface( | |
| 70 scoped_refptr<ContextProvider> compositor_context_provider) { | |
| 71 // Always test Webview shenanigans. | |
| 72 gfx::Size surface_expansion_size(40, 60); | |
| 73 | |
| 74 std::unique_ptr<PixelTestOutputSurface> display_output_surface; | |
| 75 if (test_type_ == PIXEL_TEST_GL) { | |
| 76 bool flipped_output_surface = false; | 58 bool flipped_output_surface = false; |
| 77 display_output_surface = base::MakeUnique<PixelTestOutputSurface>( | 59 display_output_surface = base::MakeUnique<PixelTestOutputSurface>( |
| 78 // Pixel tests use a separate context for the Display to more closely | 60 std::move(display_context_provider), nullptr, flipped_output_surface); |
| 79 // mimic texture transport from the renderer process to the Display | |
| 80 // compositor. | |
| 81 make_scoped_refptr(new TestInProcessContextProvider(nullptr)), nullptr, | |
| 82 flipped_output_surface); | |
| 83 } else { | 61 } else { |
| 84 std::unique_ptr<PixelTestSoftwareOutputDevice> software_output_device( | 62 std::unique_ptr<PixelTestSoftwareOutputDevice> software_output_device( |
| 85 new PixelTestSoftwareOutputDevice); | 63 new PixelTestSoftwareOutputDevice); |
| 86 software_output_device->set_surface_expansion_size(surface_expansion_size); | 64 software_output_device->set_surface_expansion_size(surface_expansion_size); |
| 87 display_output_surface = base::MakeUnique<PixelTestOutputSurface>( | 65 display_output_surface = base::MakeUnique<PixelTestOutputSurface>( |
| 88 std::move(software_output_device)); | 66 std::move(software_output_device)); |
| 89 } | 67 } |
| 90 display_output_surface->set_surface_expansion_size(surface_expansion_size); | 68 display_output_surface->set_surface_expansion_size(surface_expansion_size); |
| 91 return std::move(display_output_surface); | 69 |
| 70 auto* task_runner = ImplThreadTaskRunner(); |
| 71 bool synchronous_composite = |
| 72 !HasImplThread() && |
| 73 !layer_tree_host()->settings().single_thread_proxy_scheduler; |
| 74 auto delegating_output_surface = |
| 75 base::MakeUnique<TestDelegatingOutputSurface>( |
| 76 std::move(compositor_context_provider), |
| 77 std::move(worker_context_provider), std::move(display_output_surface), |
| 78 shared_bitmap_manager(), gpu_memory_buffer_manager(), |
| 79 RendererSettings(), task_runner, synchronous_composite); |
| 80 delegating_output_surface->display()->SetEnlargePassTextureAmountForTesting( |
| 81 enlarge_texture_amount_); |
| 82 return std::move(delegating_output_surface); |
| 92 } | 83 } |
| 93 | 84 |
| 94 std::unique_ptr<CopyOutputRequest> | 85 std::unique_ptr<CopyOutputRequest> |
| 95 LayerTreePixelTest::CreateCopyOutputRequest() { | 86 LayerTreePixelTest::CreateCopyOutputRequest() { |
| 96 return CopyOutputRequest::CreateBitmapRequest( | 87 return CopyOutputRequest::CreateBitmapRequest( |
| 97 base::Bind(&LayerTreePixelTest::ReadbackResult, base::Unretained(this))); | 88 base::Bind(&LayerTreePixelTest::ReadbackResult, base::Unretained(this))); |
| 98 } | 89 } |
| 99 | 90 |
| 100 void LayerTreePixelTest::ReadbackResult( | 91 void LayerTreePixelTest::ReadbackResult( |
| 101 std::unique_ptr<CopyOutputResult> result) { | 92 std::unique_ptr<CopyOutputResult> result) { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 } | 281 } |
| 291 | 282 |
| 292 void LayerTreePixelTest::Finish() { | 283 void LayerTreePixelTest::Finish() { |
| 293 std::unique_ptr<gpu::GLInProcessContext> context = | 284 std::unique_ptr<gpu::GLInProcessContext> context = |
| 294 CreateTestInProcessContext(); | 285 CreateTestInProcessContext(); |
| 295 GLES2Interface* gl = context->GetImplementation(); | 286 GLES2Interface* gl = context->GetImplementation(); |
| 296 gl->Finish(); | 287 gl->Finish(); |
| 297 } | 288 } |
| 298 | 289 |
| 299 } // namespace cc | 290 } // namespace cc |
| OLD | NEW |