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

Side by Side Diff: content/test/layouttest_support.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
OLDNEW
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 "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"
19 #include "cc/test/test_delegating_output_surface.h"
16 #include "components/scheduler/test/renderer_scheduler_test_support.h" 20 #include "components/scheduler/test/renderer_scheduler_test_support.h"
17 #include "components/test_runner/test_common.h" 21 #include "components/test_runner/test_common.h"
18 #include "components/test_runner/web_frame_test_proxy.h" 22 #include "components/test_runner/web_frame_test_proxy.h"
19 #include "components/test_runner/web_test_proxy.h" 23 #include "components/test_runner/web_test_proxy.h"
20 #include "content/browser/bluetooth/bluetooth_device_chooser_controller.h" 24 #include "content/browser/bluetooth/bluetooth_device_chooser_controller.h"
21 #include "content/browser/renderer_host/render_process_host_impl.h" 25 #include "content/browser/renderer_host/render_process_host_impl.h"
22 #include "content/browser/renderer_host/render_widget_host_impl.h" 26 #include "content/browser/renderer_host/render_widget_host_impl.h"
23 #include "content/common/gpu/client/context_provider_command_buffer.h" 27 #include "content/common/gpu/client/context_provider_command_buffer.h"
24 #include "content/common/site_isolation_policy.h" 28 #include "content/common/site_isolation_policy.h"
25 #include "content/public/common/page_state.h" 29 #include "content/public/common/page_state.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 attributes.alpha_size = -1; 193 attributes.alpha_size = -1;
190 attributes.depth_size = 0; 194 attributes.depth_size = 0;
191 attributes.stencil_size = 0; 195 attributes.stencil_size = 0;
192 attributes.samples = 0; 196 attributes.samples = 0;
193 attributes.sample_buffers = 0; 197 attributes.sample_buffers = 0;
194 attributes.bind_generates_resource = false; 198 attributes.bind_generates_resource = false;
195 attributes.lose_context_when_out_of_memory = true; 199 attributes.lose_context_when_out_of_memory = true;
196 const bool automatic_flushes = false; 200 const bool automatic_flushes = false;
197 const bool support_locking = false; 201 const bool support_locking = false;
198 202
199 scoped_refptr<cc::ContextProvider> display_context_provider( 203 bool flipped_output_surface = false;
200 new ContextProviderCommandBuffer( 204 std::unique_ptr<cc::OutputSurface> display_output_surface(
201 std::move(gpu_channel), gpu::GPU_STREAM_DEFAULT, 205 new cc::PixelTestOutputSurface(
202 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, 206 make_scoped_refptr(new ContextProviderCommandBuffer(
203 GURL( 207 std::move(gpu_channel), gpu::GPU_STREAM_DEFAULT,
204 "chrome://gpu/LayoutTestDependenciesImpl::CreateOutputSurface"), 208 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle,
205 automatic_flushes, support_locking, gpu::SharedMemoryLimits(), 209 GURL("chrome://gpu/"
206 attributes, nullptr, 210 "LayoutTestDependenciesImpl::CreateOutputSurface"),
207 command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_TESTING)); 211 automatic_flushes, support_locking, gpu::SharedMemoryLimits(),
212 attributes, nullptr,
213 command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_TESTING)),
214 nullptr, flipped_output_surface));
215
216 auto* task_runner = deps->GetCompositorImplThreadTaskRunner().get();
217 bool synchronous_compositor = !task_runner;
218 if (!task_runner)
219 task_runner = base::ThreadTaskRunnerHandle::Get().get();
220
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 }
208 230
209 cc::LayerTreeSettings settings = 231 cc::LayerTreeSettings settings =
210 RenderWidgetCompositor::GenerateLayerTreeSettings( 232 RenderWidgetCompositor::GenerateLayerTreeSettings(
211 *base::CommandLine::ForCurrentProcess(), deps, 1.f); 233 *base::CommandLine::ForCurrentProcess(), deps, 1.f);
212 234
213 return base::MakeUnique<cc::PixelTestDelegatingOutputSurface>( 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>(
214 std::move(compositor_context_provider), 244 std::move(compositor_context_provider),
215 std::move(worker_context_provider), std::move(display_context_provider), 245 std::move(worker_context_provider), std::move(display),
216 settings.renderer_settings, deps->GetSharedBitmapManager(), 246 context_shared_with_compositor, allow_force_reclaim_resources);
217 deps->GetGpuMemoryBufferManager(), gfx::Size(), false,
218 !deps->GetCompositorImplThreadTaskRunner());
219 } 247 }
220 }; 248 };
221 249
222 void EnableRendererLayoutTestMode() { 250 void EnableRendererLayoutTestMode() {
223 RenderThreadImpl::current()->set_layout_test_dependencies( 251 RenderThreadImpl::current()->set_layout_test_dependencies(
224 base::MakeUnique<LayoutTestDependenciesImpl>()); 252 base::MakeUnique<LayoutTestDependenciesImpl>());
225 253
226 #if defined(OS_WIN) 254 #if defined(OS_WIN)
227 RegisterSideloadedTypefaces(SkFontMgr_New_DirectWrite()); 255 RegisterSideloadedTypefaces(SkFontMgr_New_DirectWrite());
228 #endif 256 #endif
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 return result; 514 return result;
487 } 515 }
488 516
489 void SchedulerRunIdleTasks(const base::Closure& callback) { 517 void SchedulerRunIdleTasks(const base::Closure& callback) {
490 scheduler::RendererScheduler* scheduler = 518 scheduler::RendererScheduler* scheduler =
491 content::RenderThreadImpl::current()->GetRendererScheduler(); 519 content::RenderThreadImpl::current()->GetRendererScheduler();
492 scheduler::RunIdleTasksForTesting(scheduler, callback); 520 scheduler::RunIdleTasksForTesting(scheduler, callback);
493 } 521 }
494 522
495 } // namespace content 523 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/android/synchronous_compositor_output_surface.cc ('k') | services/ui/surfaces/display_compositor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698