| 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" | 15 #include "cc/scheduler/begin_frame_source.h" |
| 17 #include "cc/scheduler/delay_based_time_source.h" | 16 #include "cc/scheduler/delay_based_time_source.h" |
| 18 #include "cc/test/pixel_test_output_surface.h" | 17 #include "cc/test/pixel_test_output_surface.h" |
| 19 #include "cc/test/test_delegating_output_surface.h" | 18 #include "cc/test/test_delegating_output_surface.h" |
| 20 #include "components/scheduler/test/renderer_scheduler_test_support.h" | 19 #include "components/scheduler/test/renderer_scheduler_test_support.h" |
| 21 #include "components/test_runner/test_common.h" | 20 #include "components/test_runner/test_common.h" |
| 22 #include "components/test_runner/web_frame_test_proxy.h" | 21 #include "components/test_runner/web_frame_test_proxy.h" |
| 23 #include "components/test_runner/web_test_proxy.h" | 22 #include "components/test_runner/web_test_proxy.h" |
| 24 #include "content/browser/bluetooth/bluetooth_device_chooser_controller.h" | 23 #include "content/browser/bluetooth/bluetooth_device_chooser_controller.h" |
| 25 #include "content/browser/renderer_host/render_process_host_impl.h" | 24 #include "content/browser/renderer_host/render_process_host_impl.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 std::move(gpu_channel), gpu::GPU_STREAM_DEFAULT, | 206 std::move(gpu_channel), gpu::GPU_STREAM_DEFAULT, |
| 208 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, | 207 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, |
| 209 GURL("chrome://gpu/" | 208 GURL("chrome://gpu/" |
| 210 "LayoutTestDependenciesImpl::CreateOutputSurface"), | 209 "LayoutTestDependenciesImpl::CreateOutputSurface"), |
| 211 automatic_flushes, support_locking, gpu::SharedMemoryLimits(), | 210 automatic_flushes, support_locking, gpu::SharedMemoryLimits(), |
| 212 attributes, nullptr, | 211 attributes, nullptr, |
| 213 command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_TESTING)), | 212 command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_TESTING)), |
| 214 nullptr, flipped_output_surface)); | 213 nullptr, flipped_output_surface)); |
| 215 | 214 |
| 216 auto* task_runner = deps->GetCompositorImplThreadTaskRunner().get(); | 215 auto* task_runner = deps->GetCompositorImplThreadTaskRunner().get(); |
| 217 bool synchronous_compositor = !task_runner; | 216 bool synchronous_composite = !task_runner; |
| 218 if (!task_runner) | 217 if (!task_runner) |
| 219 task_runner = base::ThreadTaskRunnerHandle::Get().get(); | 218 task_runner = base::ThreadTaskRunnerHandle::Get().get(); |
| 220 | 219 |
| 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 = | 220 cc::LayerTreeSettings settings = |
| 232 RenderWidgetCompositor::GenerateLayerTreeSettings( | 221 RenderWidgetCompositor::GenerateLayerTreeSettings( |
| 233 *base::CommandLine::ForCurrentProcess(), deps, 1.f); | 222 *base::CommandLine::ForCurrentProcess(), deps, 1.f); |
| 234 | 223 |
| 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>( | 224 return base::MakeUnique<cc::TestDelegatingOutputSurface>( |
| 244 std::move(compositor_context_provider), | 225 std::move(compositor_context_provider), |
| 245 std::move(worker_context_provider), std::move(display), | 226 std::move(worker_context_provider), std::move(display_output_surface), |
| 246 context_shared_with_compositor, allow_force_reclaim_resources); | 227 deps->GetSharedBitmapManager(), deps->GetGpuMemoryBufferManager(), |
| 228 settings.renderer_settings, task_runner, synchronous_composite); |
| 247 } | 229 } |
| 248 }; | 230 }; |
| 249 | 231 |
| 250 void EnableRendererLayoutTestMode() { | 232 void EnableRendererLayoutTestMode() { |
| 251 RenderThreadImpl::current()->set_layout_test_dependencies( | 233 RenderThreadImpl::current()->set_layout_test_dependencies( |
| 252 base::MakeUnique<LayoutTestDependenciesImpl>()); | 234 base::MakeUnique<LayoutTestDependenciesImpl>()); |
| 253 | 235 |
| 254 #if defined(OS_WIN) | 236 #if defined(OS_WIN) |
| 255 RegisterSideloadedTypefaces(SkFontMgr_New_DirectWrite()); | 237 RegisterSideloadedTypefaces(SkFontMgr_New_DirectWrite()); |
| 256 #endif | 238 #endif |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 return result; | 496 return result; |
| 515 } | 497 } |
| 516 | 498 |
| 517 void SchedulerRunIdleTasks(const base::Closure& callback) { | 499 void SchedulerRunIdleTasks(const base::Closure& callback) { |
| 518 scheduler::RendererScheduler* scheduler = | 500 scheduler::RendererScheduler* scheduler = |
| 519 content::RenderThreadImpl::current()->GetRendererScheduler(); | 501 content::RenderThreadImpl::current()->GetRendererScheduler(); |
| 520 scheduler::RunIdleTasksForTesting(scheduler, callback); | 502 scheduler::RunIdleTasksForTesting(scheduler, callback); |
| 521 } | 503 } |
| 522 | 504 |
| 523 } // namespace content | 505 } // namespace content |
| OLD | NEW |