OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/public/test/layouttest_support.h" | 5 #include "content/public/test/layouttest_support.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "cc/output/texture_mailbox_deleter.h" | |
16 #include "cc/scheduler/begin_frame_source.h" | |
17 #include "cc/scheduler/delay_based_time_source.h" | |
18 #include "cc/test/pixel_test_output_surface.h" | 15 #include "cc/test/pixel_test_output_surface.h" |
19 #include "cc/test/test_delegating_output_surface.h" | 16 #include "cc/test/test_delegating_output_surface.h" |
20 #include "components/scheduler/test/renderer_scheduler_test_support.h" | 17 #include "components/scheduler/test/renderer_scheduler_test_support.h" |
21 #include "components/test_runner/test_common.h" | 18 #include "components/test_runner/test_common.h" |
22 #include "components/test_runner/web_frame_test_proxy.h" | 19 #include "components/test_runner/web_frame_test_proxy.h" |
23 #include "components/test_runner/web_test_proxy.h" | 20 #include "components/test_runner/web_test_proxy.h" |
24 #include "content/browser/bluetooth/bluetooth_device_chooser_controller.h" | 21 #include "content/browser/bluetooth/bluetooth_device_chooser_controller.h" |
25 #include "content/browser/renderer_host/render_process_host_impl.h" | 22 #include "content/browser/renderer_host/render_process_host_impl.h" |
26 #include "content/browser/renderer_host/render_widget_host_impl.h" | 23 #include "content/browser/renderer_host/render_widget_host_impl.h" |
27 #include "content/common/gpu/client/context_provider_command_buffer.h" | 24 #include "content/common/gpu/client/context_provider_command_buffer.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 std::move(gpu_channel), gpu::GPU_STREAM_DEFAULT, | 204 std::move(gpu_channel), gpu::GPU_STREAM_DEFAULT, |
208 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, | 205 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, |
209 GURL("chrome://gpu/" | 206 GURL("chrome://gpu/" |
210 "LayoutTestDependenciesImpl::CreateOutputSurface"), | 207 "LayoutTestDependenciesImpl::CreateOutputSurface"), |
211 automatic_flushes, support_locking, gpu::SharedMemoryLimits(), | 208 automatic_flushes, support_locking, gpu::SharedMemoryLimits(), |
212 attributes, nullptr, | 209 attributes, nullptr, |
213 command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_TESTING)), | 210 command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_TESTING)), |
214 nullptr, flipped_output_surface)); | 211 nullptr, flipped_output_surface)); |
215 | 212 |
216 auto* task_runner = deps->GetCompositorImplThreadTaskRunner().get(); | 213 auto* task_runner = deps->GetCompositorImplThreadTaskRunner().get(); |
217 bool synchronous_compositor = !task_runner; | 214 bool synchronous_composite = !task_runner; |
218 if (!task_runner) | 215 if (!task_runner) |
219 task_runner = base::ThreadTaskRunnerHandle::Get().get(); | 216 task_runner = base::ThreadTaskRunnerHandle::Get().get(); |
220 | 217 |
221 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source; | |
222 std::unique_ptr<cc::DisplayScheduler> scheduler; | |
223 if (!synchronous_compositor) { | |
224 begin_frame_source.reset(new cc::DelayBasedBeginFrameSource( | |
225 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner))); | |
226 scheduler.reset(new cc::DisplayScheduler( | |
227 begin_frame_source.get(), task_runner, | |
228 display_output_surface->capabilities().max_frames_pending)); | |
229 } | |
230 | |
231 cc::LayerTreeSettings settings = | 218 cc::LayerTreeSettings settings = |
232 RenderWidgetCompositor::GenerateLayerTreeSettings( | 219 RenderWidgetCompositor::GenerateLayerTreeSettings( |
233 *base::CommandLine::ForCurrentProcess(), deps, 1.f); | 220 *base::CommandLine::ForCurrentProcess(), deps, 1.f); |
234 | 221 |
235 std::unique_ptr<cc::Display> display(new cc::Display( | |
236 deps->GetSharedBitmapManager(), deps->GetGpuMemoryBufferManager(), | |
237 settings.renderer_settings, std::move(begin_frame_source), | |
238 std::move(display_output_surface), std::move(scheduler), | |
239 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner))); | |
240 | |
241 const bool context_shared_with_compositor = false; | |
242 const bool allow_force_reclaim_resources = false; | |
243 return base::MakeUnique<cc::TestDelegatingOutputSurface>( | 222 return base::MakeUnique<cc::TestDelegatingOutputSurface>( |
244 std::move(compositor_context_provider), | 223 std::move(compositor_context_provider), |
245 std::move(worker_context_provider), std::move(display), | 224 std::move(worker_context_provider), std::move(display_output_surface), |
246 context_shared_with_compositor, allow_force_reclaim_resources); | 225 deps->GetSharedBitmapManager(), deps->GetGpuMemoryBufferManager(), |
| 226 settings.renderer_settings, task_runner, synchronous_composite); |
247 } | 227 } |
248 }; | 228 }; |
249 | 229 |
250 void EnableRendererLayoutTestMode() { | 230 void EnableRendererLayoutTestMode() { |
251 RenderThreadImpl::current()->set_layout_test_dependencies( | 231 RenderThreadImpl::current()->set_layout_test_dependencies( |
252 base::MakeUnique<LayoutTestDependenciesImpl>()); | 232 base::MakeUnique<LayoutTestDependenciesImpl>()); |
253 | 233 |
254 #if defined(OS_WIN) | 234 #if defined(OS_WIN) |
255 RegisterSideloadedTypefaces(SkFontMgr_New_DirectWrite()); | 235 RegisterSideloadedTypefaces(SkFontMgr_New_DirectWrite()); |
256 #endif | 236 #endif |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 return result; | 494 return result; |
515 } | 495 } |
516 | 496 |
517 void SchedulerRunIdleTasks(const base::Closure& callback) { | 497 void SchedulerRunIdleTasks(const base::Closure& callback) { |
518 scheduler::RendererScheduler* scheduler = | 498 scheduler::RendererScheduler* scheduler = |
519 content::RenderThreadImpl::current()->GetRendererScheduler(); | 499 content::RenderThreadImpl::current()->GetRendererScheduler(); |
520 scheduler::RunIdleTasksForTesting(scheduler, callback); | 500 scheduler::RunIdleTasksForTesting(scheduler, callback); |
521 } | 501 } |
522 | 502 |
523 } // namespace content | 503 } // namespace content |
OLD | NEW |