OLD | NEW |
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/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
15 #include "base/threading/simple_thread.h" | 15 #include "base/threading/simple_thread.h" |
16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
17 #include "cc/base/histograms.h" | 17 #include "cc/base/histograms.h" |
18 #include "cc/output/compositor_frame.h" | 18 #include "cc/output/compositor_frame.h" |
19 #include "cc/output/output_surface.h" | 19 #include "cc/output/output_surface.h" |
| 20 #include "cc/raster/single_thread_task_graph_runner.h" |
20 #include "cc/raster/task_graph_runner.h" | 21 #include "cc/raster/task_graph_runner.h" |
21 #include "cc/surfaces/onscreen_display_client.h" | 22 #include "cc/surfaces/onscreen_display_client.h" |
22 #include "cc/surfaces/surface_display_output_surface.h" | 23 #include "cc/surfaces/surface_display_output_surface.h" |
23 #include "cc/surfaces/surface_manager.h" | 24 #include "cc/surfaces/surface_manager.h" |
24 #include "content/browser/compositor/browser_compositor_output_surface.h" | 25 #include "content/browser/compositor/browser_compositor_output_surface.h" |
25 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor.h" | 26 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor.h" |
26 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" | 27 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" |
27 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" | 28 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" |
28 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" | 29 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" |
29 #include "content/browser/compositor/reflector_impl.h" | 30 #include "content/browser/compositor/reflector_impl.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 #include "content/browser/compositor/software_output_device_mac.h" | 69 #include "content/browser/compositor/software_output_device_mac.h" |
69 #include "ui/base/cocoa/remote_layer_api.h" | 70 #include "ui/base/cocoa/remote_layer_api.h" |
70 #endif | 71 #endif |
71 | 72 |
72 using cc::ContextProvider; | 73 using cc::ContextProvider; |
73 using gpu::gles2::GLES2Interface; | 74 using gpu::gles2::GLES2Interface; |
74 | 75 |
75 static const int kNumRetriesBeforeSoftwareFallback = 4; | 76 static const int kNumRetriesBeforeSoftwareFallback = 4; |
76 | 77 |
77 namespace content { | 78 namespace content { |
78 namespace { | |
79 | |
80 class RasterThread : public base::SimpleThread { | |
81 public: | |
82 RasterThread(cc::TaskGraphRunner* task_graph_runner) | |
83 : base::SimpleThread("CompositorTileWorker1"), | |
84 task_graph_runner_(task_graph_runner) {} | |
85 | |
86 // Overridden from base::SimpleThread: | |
87 void Run() override { task_graph_runner_->Run(); } | |
88 | |
89 private: | |
90 cc::TaskGraphRunner* task_graph_runner_; | |
91 | |
92 DISALLOW_COPY_AND_ASSIGN(RasterThread); | |
93 }; | |
94 | |
95 } // namespace | |
96 | 79 |
97 struct GpuProcessTransportFactory::PerCompositorData { | 80 struct GpuProcessTransportFactory::PerCompositorData { |
98 int surface_id; | 81 int surface_id; |
99 BrowserCompositorOutputSurface* surface; | 82 BrowserCompositorOutputSurface* surface; |
100 ReflectorImpl* reflector; | 83 ReflectorImpl* reflector; |
101 scoped_ptr<cc::OnscreenDisplayClient> display_client; | 84 scoped_ptr<cc::OnscreenDisplayClient> display_client; |
102 | 85 |
103 PerCompositorData() : surface_id(0), surface(nullptr), reflector(nullptr) {} | 86 PerCompositorData() : surface_id(0), surface(nullptr), reflector(nullptr) {} |
104 }; | 87 }; |
105 | 88 |
106 GpuProcessTransportFactory::GpuProcessTransportFactory() | 89 GpuProcessTransportFactory::GpuProcessTransportFactory() |
107 : next_surface_id_namespace_(1u), | 90 : next_surface_id_namespace_(1u), |
108 task_graph_runner_(new cc::TaskGraphRunner), | 91 task_graph_runner_(new cc::SingleThreadTaskGraphRunner), |
109 callback_factory_(this) { | 92 callback_factory_(this) { |
110 ui::Layer::InitializeUILayerSettings(); | 93 ui::Layer::InitializeUILayerSettings(); |
111 cc::SetClientNameForMetrics("Browser"); | 94 cc::SetClientNameForMetrics("Browser"); |
112 | 95 |
113 if (UseSurfacesEnabled()) | 96 if (UseSurfacesEnabled()) |
114 surface_manager_ = make_scoped_ptr(new cc::SurfaceManager); | 97 surface_manager_ = make_scoped_ptr(new cc::SurfaceManager); |
115 | 98 |
116 raster_thread_.reset(new RasterThread(task_graph_runner_.get())); | 99 task_graph_runner_->Start("CompositorTileWorker1"); |
117 raster_thread_->Start(); | |
118 #if defined(OS_WIN) | 100 #if defined(OS_WIN) |
119 software_backing_.reset(new OutputDeviceBacking); | 101 software_backing_.reset(new OutputDeviceBacking); |
120 #endif | 102 #endif |
121 } | 103 } |
122 | 104 |
123 GpuProcessTransportFactory::~GpuProcessTransportFactory() { | 105 GpuProcessTransportFactory::~GpuProcessTransportFactory() { |
124 DCHECK(per_compositor_data_.empty()); | 106 DCHECK(per_compositor_data_.empty()); |
125 | 107 |
126 // Make sure the lost context callback doesn't try to run during destruction. | 108 // Make sure the lost context callback doesn't try to run during destruction. |
127 callback_factory_.InvalidateWeakPtrs(); | 109 callback_factory_.InvalidateWeakPtrs(); |
128 | 110 |
129 task_graph_runner_->Shutdown(); | 111 task_graph_runner_->Shutdown(); |
130 if (raster_thread_) | |
131 raster_thread_->Join(); | |
132 } | 112 } |
133 | 113 |
134 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 114 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
135 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext() { | 115 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext() { |
136 CauseForGpuLaunch cause = | 116 CauseForGpuLaunch cause = |
137 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; | 117 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; |
138 scoped_refptr<GpuChannelHost> gpu_channel_host( | 118 scoped_refptr<GpuChannelHost> gpu_channel_host( |
139 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(cause)); | 119 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(cause)); |
140 return CreateContextCommon(gpu_channel_host, 0); | 120 return CreateContextCommon(gpu_channel_host, 0); |
141 } | 121 } |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 627 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
648 observer_list_, | 628 observer_list_, |
649 OnLostResources()); | 629 OnLostResources()); |
650 | 630 |
651 // Kill things that use the shared context before killing the shared context. | 631 // Kill things that use the shared context before killing the shared context. |
652 lost_gl_helper.reset(); | 632 lost_gl_helper.reset(); |
653 lost_shared_main_thread_contexts = NULL; | 633 lost_shared_main_thread_contexts = NULL; |
654 } | 634 } |
655 | 635 |
656 } // namespace content | 636 } // namespace content |
OLD | NEW |