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/test/pixel_test_delegating_output_surface.h" |
15 #include "components/scheduler/test/renderer_scheduler_test_support.h" | 16 #include "components/scheduler/test/renderer_scheduler_test_support.h" |
16 #include "components/test_runner/test_common.h" | 17 #include "components/test_runner/test_common.h" |
17 #include "components/test_runner/web_frame_test_proxy.h" | 18 #include "components/test_runner/web_frame_test_proxy.h" |
18 #include "components/test_runner/web_test_proxy.h" | 19 #include "components/test_runner/web_test_proxy.h" |
19 #include "content/browser/bluetooth/bluetooth_adapter_factory_wrapper.h" | 20 #include "content/browser/bluetooth/bluetooth_adapter_factory_wrapper.h" |
20 #include "content/browser/renderer_host/render_process_host_impl.h" | 21 #include "content/browser/renderer_host/render_process_host_impl.h" |
21 #include "content/browser/renderer_host/render_widget_host_impl.h" | 22 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 23 #include "content/common/gpu/client/context_provider_command_buffer.h" |
22 #include "content/common/site_isolation_policy.h" | 24 #include "content/common/site_isolation_policy.h" |
23 #include "content/public/common/page_state.h" | 25 #include "content/public/common/page_state.h" |
24 #include "content/public/renderer/renderer_gamepad_provider.h" | 26 #include "content/public/renderer/renderer_gamepad_provider.h" |
25 #include "content/renderer/fetchers/manifest_fetcher.h" | 27 #include "content/renderer/fetchers/manifest_fetcher.h" |
| 28 #include "content/renderer/gpu/render_widget_compositor.h" |
26 #include "content/renderer/history_entry.h" | 29 #include "content/renderer/history_entry.h" |
27 #include "content/renderer/history_serialization.h" | 30 #include "content/renderer/history_serialization.h" |
28 #include "content/renderer/layout_test_dependencies.h" | 31 #include "content/renderer/layout_test_dependencies.h" |
29 #include "content/renderer/render_frame_impl.h" | 32 #include "content/renderer/render_frame_impl.h" |
30 #include "content/renderer/render_thread_impl.h" | 33 #include "content/renderer/render_thread_impl.h" |
31 #include "content/renderer/render_view_impl.h" | 34 #include "content/renderer/render_view_impl.h" |
32 #include "content/renderer/renderer_blink_platform_impl.h" | 35 #include "content/renderer/renderer_blink_platform_impl.h" |
33 #include "content/shell/common/shell_switches.h" | 36 #include "content/shell/common/shell_switches.h" |
34 #include "content/test/mailbox_output_surface.h" | 37 #include "content/test/mailbox_output_surface.h" |
35 #include "device/bluetooth/bluetooth_adapter.h" | 38 #include "device/bluetooth/bluetooth_adapter.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 RendererBlinkPlatformImpl::SetMockDeviceMotionDataForTesting(data); | 173 RendererBlinkPlatformImpl::SetMockDeviceMotionDataForTesting(data); |
171 } | 174 } |
172 | 175 |
173 void SetMockDeviceOrientationData(const WebDeviceOrientationData& data) { | 176 void SetMockDeviceOrientationData(const WebDeviceOrientationData& data) { |
174 RendererBlinkPlatformImpl::SetMockDeviceOrientationDataForTesting(data); | 177 RendererBlinkPlatformImpl::SetMockDeviceOrientationDataForTesting(data); |
175 } | 178 } |
176 | 179 |
177 class LayoutTestDependenciesImpl : public LayoutTestDependencies { | 180 class LayoutTestDependenciesImpl : public LayoutTestDependencies { |
178 public: | 181 public: |
179 std::unique_ptr<cc::OutputSurface> CreateOutputSurface( | 182 std::unique_ptr<cc::OutputSurface> CreateOutputSurface( |
180 uint32_t output_surface_id, | 183 scoped_refptr<gpu::GpuChannelHost> gpu_channel, |
181 scoped_refptr<cc::ContextProvider> context_provider, | 184 scoped_refptr<cc::ContextProvider> compositor_context_provider, |
182 scoped_refptr<cc::ContextProvider> worker_context_provider) override { | 185 scoped_refptr<cc::ContextProvider> worker_context_provider, |
183 return base::MakeUnique<MailboxOutputSurface>( | 186 CompositorDependencies* deps) override { |
184 output_surface_id, std::move(context_provider), | 187 // This is for an offscreen context for the compositor. So the default |
185 std::move(worker_context_provider)); | 188 // framebuffer doesn't need alpha, depth, stencil, antialiasing. |
| 189 gpu::gles2::ContextCreationAttribHelper attributes; |
| 190 attributes.alpha_size = -1; |
| 191 attributes.depth_size = 0; |
| 192 attributes.stencil_size = 0; |
| 193 attributes.samples = 0; |
| 194 attributes.sample_buffers = 0; |
| 195 attributes.bind_generates_resource = false; |
| 196 attributes.lose_context_when_out_of_memory = true; |
| 197 const bool automatic_flushes = false; |
| 198 const bool support_locking = false; |
| 199 |
| 200 scoped_refptr<cc::ContextProvider> display_context_provider( |
| 201 new ContextProviderCommandBuffer( |
| 202 std::move(gpu_channel), gpu::GPU_STREAM_DEFAULT, |
| 203 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, |
| 204 GURL( |
| 205 "chrome://gpu/LayoutTestDependenciesImpl::CreateOutputSurface"), |
| 206 gl::PreferIntegratedGpu, automatic_flushes, support_locking, |
| 207 gpu::SharedMemoryLimits(), attributes, nullptr, |
| 208 command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_TESTING)); |
| 209 |
| 210 cc::LayerTreeSettings settings = |
| 211 RenderWidgetCompositor::GenerateLayerTreeSettings( |
| 212 *base::CommandLine::ForCurrentProcess(), deps, 1.f); |
| 213 |
| 214 return base::MakeUnique<cc::PixelTestDelegatingOutputSurface>( |
| 215 std::move(compositor_context_provider), |
| 216 std::move(worker_context_provider), std::move(display_context_provider), |
| 217 settings.renderer_settings, deps->GetSharedBitmapManager(), |
| 218 deps->GetGpuMemoryBufferManager(), gfx::Size(), false, |
| 219 !deps->GetCompositorImplThreadTaskRunner()); |
186 } | 220 } |
187 }; | 221 }; |
188 | 222 |
189 void EnableRendererLayoutTestMode() { | 223 void EnableRendererLayoutTestMode() { |
190 RenderThreadImpl::current()->set_layout_test_dependencies( | 224 RenderThreadImpl::current()->set_layout_test_dependencies( |
191 base::MakeUnique<LayoutTestDependenciesImpl>()); | 225 base::MakeUnique<LayoutTestDependenciesImpl>()); |
192 | 226 |
193 #if defined(OS_WIN) | 227 #if defined(OS_WIN) |
194 RegisterSideloadedTypefaces(SkFontMgr_New_DirectWrite()); | 228 RegisterSideloadedTypefaces(SkFontMgr_New_DirectWrite()); |
195 #endif | 229 #endif |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 return result; | 487 return result; |
454 } | 488 } |
455 | 489 |
456 void SchedulerRunIdleTasks(const base::Closure& callback) { | 490 void SchedulerRunIdleTasks(const base::Closure& callback) { |
457 scheduler::RendererScheduler* scheduler = | 491 scheduler::RendererScheduler* scheduler = |
458 content::RenderThreadImpl::current()->GetRendererScheduler(); | 492 content::RenderThreadImpl::current()->GetRendererScheduler(); |
459 scheduler::RunIdleTasksForTesting(scheduler, callback); | 493 scheduler::RunIdleTasksForTesting(scheduler, callback); |
460 } | 494 } |
461 | 495 |
462 } // namespace content | 496 } // namespace content |
OLD | NEW |