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

Side by Side Diff: cc/test/layer_tree_pixel_test.cc

Issue 2144393003: cc: Allow TestDelegatingOutputSurface to be used for non-pixel tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « cc/test/layer_tree_pixel_test.h ('k') | cc/test/pixel_test_delegating_output_surface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "cc/base/switches.h" 12 #include "cc/base/switches.h"
13 #include "cc/layers/solid_color_layer.h" 13 #include "cc/layers/solid_color_layer.h"
14 #include "cc/layers/texture_layer.h" 14 #include "cc/layers/texture_layer.h"
15 #include "cc/output/copy_output_request.h" 15 #include "cc/output/copy_output_request.h"
16 #include "cc/output/copy_output_result.h" 16 #include "cc/output/copy_output_result.h"
17 #include "cc/output/direct_renderer.h" 17 #include "cc/output/texture_mailbox_deleter.h"
18 #include "cc/resources/texture_mailbox.h" 18 #include "cc/resources/texture_mailbox.h"
19 #include "cc/scheduler/begin_frame_source.h"
20 #include "cc/scheduler/delay_based_time_source.h"
19 #include "cc/test/paths.h" 21 #include "cc/test/paths.h"
20 #include "cc/test/pixel_comparator.h" 22 #include "cc/test/pixel_comparator.h"
21 #include "cc/test/pixel_test_delegating_output_surface.h"
22 #include "cc/test/pixel_test_output_surface.h" 23 #include "cc/test/pixel_test_output_surface.h"
23 #include "cc/test/pixel_test_software_output_device.h" 24 #include "cc/test/pixel_test_software_output_device.h"
24 #include "cc/test/pixel_test_utils.h" 25 #include "cc/test/pixel_test_utils.h"
26 #include "cc/test/test_delegating_output_surface.h"
25 #include "cc/test/test_in_process_context_provider.h" 27 #include "cc/test/test_in_process_context_provider.h"
26 #include "cc/trees/layer_tree_impl.h" 28 #include "cc/trees/layer_tree_impl.h"
27 #include "gpu/command_buffer/client/gl_in_process_context.h" 29 #include "gpu/command_buffer/client/gl_in_process_context.h"
28 #include "gpu/command_buffer/client/gles2_implementation.h" 30 #include "gpu/command_buffer/client/gles2_implementation.h"
29 31
30 using gpu::gles2::GLES2Interface; 32 using gpu::gles2::GLES2Interface;
31 33
32 namespace cc { 34 namespace cc {
33 35
34 LayerTreePixelTest::LayerTreePixelTest() 36 LayerTreePixelTest::LayerTreePixelTest()
35 : pixel_comparator_(new ExactPixelComparator(true)), 37 : pixel_comparator_(new ExactPixelComparator(true)),
36 test_type_(PIXEL_TEST_GL), 38 test_type_(PIXEL_TEST_GL),
37 pending_texture_mailbox_callbacks_(0) {} 39 pending_texture_mailbox_callbacks_(0) {}
38 40
39 LayerTreePixelTest::~LayerTreePixelTest() {} 41 LayerTreePixelTest::~LayerTreePixelTest() {}
40 42
41 void LayerTreePixelTest::InitializeSettings(LayerTreeSettings* settings) { 43 void LayerTreePixelTest::InitializeSettings(LayerTreeSettings* settings) {
42 // The PixelTestDelegatingOutputSurface will provide a BeginFrameSource. 44 // The PixelTestDelegatingOutputSurface will provide a BeginFrameSource.
43 settings->use_output_surface_begin_frame_source = true; 45 settings->use_output_surface_begin_frame_source = true;
44 } 46 }
45 47
46 std::unique_ptr<OutputSurface> LayerTreePixelTest::CreateOutputSurface() { 48 std::unique_ptr<OutputSurface> LayerTreePixelTest::CreateOutputSurface() {
47 scoped_refptr<TestInProcessContextProvider> compositor; 49 // Always test Webview shenanigans.
48 scoped_refptr<TestInProcessContextProvider> worker; 50 gfx::Size surface_expansion_size(40, 60);
49 scoped_refptr<TestInProcessContextProvider> display; 51
52 scoped_refptr<TestInProcessContextProvider> compositor_context_provider;
53 scoped_refptr<TestInProcessContextProvider> worker_context_provider;
54 scoped_refptr<TestInProcessContextProvider> display_context_provider;
55 std::unique_ptr<PixelTestOutputSurface> display_output_surface;
50 if (test_type_ == PIXEL_TEST_GL) { 56 if (test_type_ == PIXEL_TEST_GL) {
51 compositor = new TestInProcessContextProvider(nullptr); 57 compositor_context_provider = new TestInProcessContextProvider(nullptr);
52 worker = new TestInProcessContextProvider(compositor.get()); 58 worker_context_provider =
53 display = new TestInProcessContextProvider(nullptr); 59 new TestInProcessContextProvider(compositor_context_provider.get());
60 display_context_provider = new TestInProcessContextProvider(nullptr);
61 bool flipped_output_surface = false;
62 display_output_surface = base::MakeUnique<PixelTestOutputSurface>(
63 std::move(display_context_provider), nullptr, flipped_output_surface);
64 } else {
65 std::unique_ptr<PixelTestSoftwareOutputDevice> software_output_device(
66 new PixelTestSoftwareOutputDevice);
67 software_output_device->set_surface_expansion_size(surface_expansion_size);
68 display_output_surface = base::MakeUnique<PixelTestOutputSurface>(
69 std::move(software_output_device));
54 } 70 }
55 const bool allow_force_reclaim_resources = !HasImplThread(); 71 display_output_surface->set_surface_expansion_size(surface_expansion_size);
56 const bool synchronous_composite = 72
57 !layer_tree_host()->settings().single_thread_proxy_scheduler; 73 auto* task_runner = ImplThreadTaskRunner();
58 // Always test Webview shenanigans. 74 CHECK(task_runner);
59 const gfx::Size surface_expansion_size(40, 60); 75
60 std::unique_ptr<PixelTestDelegatingOutputSurface> delegating_output_surface( 76 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source;
61 new PixelTestDelegatingOutputSurface( 77 std::unique_ptr<DisplayScheduler> scheduler;
62 std::move(compositor), std::move(worker), std::move(display), 78 if (layer_tree_host()->settings().single_thread_proxy_scheduler) {
63 RendererSettings(), shared_bitmap_manager(), 79 begin_frame_source.reset(new DelayBasedBeginFrameSource(
64 gpu_memory_buffer_manager(), surface_expansion_size, 80 base::MakeUnique<DelayBasedTimeSource>(task_runner)));
65 allow_force_reclaim_resources, synchronous_composite)); 81 scheduler.reset(new DisplayScheduler(
66 delegating_output_surface->SetEnlargePassTextureAmount( 82 begin_frame_source.get(), task_runner,
67 enlarge_texture_amount_); 83 display_output_surface->capabilities().max_frames_pending));
68 return std::move(delegating_output_surface); 84 }
85
86 std::unique_ptr<Display> display(
87 new Display(shared_bitmap_manager(), gpu_memory_buffer_manager(),
88 RendererSettings(), std::move(begin_frame_source),
89 std::move(display_output_surface), std::move(scheduler),
90 base::MakeUnique<TextureMailboxDeleter>(task_runner)));
91 display->SetEnlargePassTextureAmountForTesting(enlarge_texture_amount_);
92
93 const bool context_shared_with_compositor = false;
94 const bool allow_force_reclaim_resources = true;
95 return base::MakeUnique<TestDelegatingOutputSurface>(
96 std::move(compositor_context_provider),
97 std::move(worker_context_provider), std::move(display),
98 context_shared_with_compositor, allow_force_reclaim_resources);
69 } 99 }
70 100
71 std::unique_ptr<CopyOutputRequest> 101 std::unique_ptr<CopyOutputRequest>
72 LayerTreePixelTest::CreateCopyOutputRequest() { 102 LayerTreePixelTest::CreateCopyOutputRequest() {
73 return CopyOutputRequest::CreateBitmapRequest( 103 return CopyOutputRequest::CreateBitmapRequest(
74 base::Bind(&LayerTreePixelTest::ReadbackResult, base::Unretained(this))); 104 base::Bind(&LayerTreePixelTest::ReadbackResult, base::Unretained(this)));
75 } 105 }
76 106
77 void LayerTreePixelTest::ReadbackResult( 107 void LayerTreePixelTest::ReadbackResult(
78 std::unique_ptr<CopyOutputResult> result) { 108 std::unique_ptr<CopyOutputResult> result) {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 297 }
268 298
269 void LayerTreePixelTest::Finish() { 299 void LayerTreePixelTest::Finish() {
270 std::unique_ptr<gpu::GLInProcessContext> context = 300 std::unique_ptr<gpu::GLInProcessContext> context =
271 CreateTestInProcessContext(); 301 CreateTestInProcessContext();
272 GLES2Interface* gl = context->GetImplementation(); 302 GLES2Interface* gl = context->GetImplementation();
273 gl->Finish(); 303 gl->Finish();
274 } 304 }
275 305
276 } // namespace cc 306 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_pixel_test.h ('k') | cc/test/pixel_test_delegating_output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698