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

Side by Side Diff: content/browser/compositor/gpu_process_transport_factory.cc

Issue 999173004: cc: Move worker threads to content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment and webview fix Created 5 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/compositor/gpu_process_transport_factory.h" 5 #include "content/browser/compositor/gpu_process_transport_factory.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/profiler/scoped_tracker.h" 14 #include "base/profiler/scoped_tracker.h"
15 #include "base/threading/simple_thread.h"
15 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
16 #include "cc/output/compositor_frame.h" 17 #include "cc/output/compositor_frame.h"
17 #include "cc/output/output_surface.h" 18 #include "cc/output/output_surface.h"
19 #include "cc/resources/task_graph_runner.h"
18 #include "cc/surfaces/onscreen_display_client.h" 20 #include "cc/surfaces/onscreen_display_client.h"
19 #include "cc/surfaces/surface_display_output_surface.h" 21 #include "cc/surfaces/surface_display_output_surface.h"
20 #include "cc/surfaces/surface_manager.h" 22 #include "cc/surfaces/surface_manager.h"
21 #include "content/browser/compositor/browser_compositor_output_surface.h" 23 #include "content/browser/compositor/browser_compositor_output_surface.h"
22 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" 24 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h"
23 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s urface.h" 25 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s urface.h"
24 #include "content/browser/compositor/reflector_impl.h" 26 #include "content/browser/compositor/reflector_impl.h"
25 #include "content/browser/compositor/software_browser_compositor_output_surface. h" 27 #include "content/browser/compositor/software_browser_compositor_output_surface. h"
26 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" 28 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
27 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" 29 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
(...skipping 30 matching lines...) Expand all
58 #elif defined(OS_MACOSX) 60 #elif defined(OS_MACOSX)
59 #include "content/browser/compositor/software_output_device_mac.h" 61 #include "content/browser/compositor/software_output_device_mac.h"
60 #endif 62 #endif
61 63
62 using cc::ContextProvider; 64 using cc::ContextProvider;
63 using gpu::gles2::GLES2Interface; 65 using gpu::gles2::GLES2Interface;
64 66
65 static const int kNumRetriesBeforeSoftwareFallback = 4; 67 static const int kNumRetriesBeforeSoftwareFallback = 4;
66 68
67 namespace content { 69 namespace content {
70 namespace {
71
72 class RasterThread : public base::SimpleThread {
73 public:
74 RasterThread(cc::TaskGraphRunner* task_graph_runner)
75 : base::SimpleThread("UICompositorWorker"),
76 task_graph_runner_(task_graph_runner) {}
77
78 // Overridden from base::SimpleThread:
79 void Run() override { task_graph_runner_->Run(); }
80
81 private:
82 cc::TaskGraphRunner* task_graph_runner_;
83
84 DISALLOW_COPY_AND_ASSIGN(RasterThread);
85 };
86
87 } // namespace
68 88
69 struct GpuProcessTransportFactory::PerCompositorData { 89 struct GpuProcessTransportFactory::PerCompositorData {
70 int surface_id; 90 int surface_id;
71 BrowserCompositorOutputSurface* surface; 91 BrowserCompositorOutputSurface* surface;
72 ReflectorImpl* reflector; 92 ReflectorImpl* reflector;
73 scoped_ptr<cc::OnscreenDisplayClient> display_client; 93 scoped_ptr<cc::OnscreenDisplayClient> display_client;
74 94
75 PerCompositorData() : surface_id(0), surface(nullptr), reflector(nullptr) {} 95 PerCompositorData() : surface_id(0), surface(nullptr), reflector(nullptr) {}
76 }; 96 };
77 97
78 GpuProcessTransportFactory::GpuProcessTransportFactory() 98 GpuProcessTransportFactory::GpuProcessTransportFactory()
79 : next_surface_id_namespace_(1u), 99 : next_surface_id_namespace_(1u),
100 task_graph_runner_(new cc::TaskGraphRunner),
80 callback_factory_(this) { 101 callback_factory_(this) {
81 if (UseSurfacesEnabled()) 102 if (UseSurfacesEnabled())
82 surface_manager_ = make_scoped_ptr(new cc::SurfaceManager); 103 surface_manager_ = make_scoped_ptr(new cc::SurfaceManager);
104
105 if (ui::IsUIImplSidePaintingEnabled()) {
106 raster_thread_.reset(new RasterThread(task_graph_runner_.get()));
107 raster_thread_->Start();
108 }
83 } 109 }
84 110
85 GpuProcessTransportFactory::~GpuProcessTransportFactory() { 111 GpuProcessTransportFactory::~GpuProcessTransportFactory() {
86 DCHECK(per_compositor_data_.empty()); 112 DCHECK(per_compositor_data_.empty());
87 113
88 // Make sure the lost context callback doesn't try to run during destruction. 114 // Make sure the lost context callback doesn't try to run during destruction.
89 callback_factory_.InvalidateWeakPtrs(); 115 callback_factory_.InvalidateWeakPtrs();
116
117 task_graph_runner_->Shutdown();
118 if (raster_thread_)
119 raster_thread_->Join();
90 } 120 }
91 121
92 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> 122 scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
93 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext() { 123 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext() {
94 CauseForGpuLaunch cause = 124 CauseForGpuLaunch cause =
95 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; 125 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
96 scoped_refptr<GpuChannelHost> gpu_channel_host( 126 scoped_refptr<GpuChannelHost> gpu_channel_host(
97 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(cause)); 127 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(cause));
98 return CreateContextCommon(gpu_channel_host, 0); 128 return CreateContextCommon(gpu_channel_host, 0);
99 } 129 }
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 394
365 cc::SharedBitmapManager* GpuProcessTransportFactory::GetSharedBitmapManager() { 395 cc::SharedBitmapManager* GpuProcessTransportFactory::GetSharedBitmapManager() {
366 return HostSharedBitmapManager::current(); 396 return HostSharedBitmapManager::current();
367 } 397 }
368 398
369 gpu::GpuMemoryBufferManager* 399 gpu::GpuMemoryBufferManager*
370 GpuProcessTransportFactory::GetGpuMemoryBufferManager() { 400 GpuProcessTransportFactory::GetGpuMemoryBufferManager() {
371 return BrowserGpuMemoryBufferManager::current(); 401 return BrowserGpuMemoryBufferManager::current();
372 } 402 }
373 403
404 cc::TaskGraphRunner* GpuProcessTransportFactory::GetTaskGraphRunner() {
405 return task_graph_runner_.get();
406 }
407
374 ui::ContextFactory* GpuProcessTransportFactory::GetContextFactory() { 408 ui::ContextFactory* GpuProcessTransportFactory::GetContextFactory() {
375 return this; 409 return this;
376 } 410 }
377 411
378 gfx::GLSurfaceHandle GpuProcessTransportFactory::GetSharedSurfaceHandle() { 412 gfx::GLSurfaceHandle GpuProcessTransportFactory::GetSharedSurfaceHandle() {
379 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( 413 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle(
380 gfx::kNullPluginWindow, gfx::NULL_TRANSPORT); 414 gfx::kNullPluginWindow, gfx::NULL_TRANSPORT);
381 handle.parent_client_id = 415 handle.parent_client_id =
382 BrowserGpuChannelHostFactory::instance()->GetGpuChannelId(); 416 BrowserGpuChannelHostFactory::instance()->GetGpuChannelId();
383 return handle; 417 return handle;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, 586 FOR_EACH_OBSERVER(ImageTransportFactoryObserver,
553 observer_list_, 587 observer_list_,
554 OnLostResources()); 588 OnLostResources());
555 589
556 // Kill things that use the shared context before killing the shared context. 590 // Kill things that use the shared context before killing the shared context.
557 lost_gl_helper.reset(); 591 lost_gl_helper.reset();
558 lost_shared_main_thread_contexts = NULL; 592 lost_shared_main_thread_contexts = NULL;
559 } 593 }
560 594
561 } // namespace content 595 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698