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" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 scoped_refptr<ContextProviderCommandBuffer> context_provider; | 153 scoped_refptr<ContextProviderCommandBuffer> context_provider; |
154 | 154 |
155 if (!create_software_renderer) { | 155 if (!create_software_renderer) { |
156 context_provider = ContextProviderCommandBuffer::Create( | 156 context_provider = ContextProviderCommandBuffer::Create( |
157 GpuProcessTransportFactory::CreateContextCommon(data->surface_id), | 157 GpuProcessTransportFactory::CreateContextCommon(data->surface_id), |
158 "Compositor"); | 158 "Compositor"); |
159 } | 159 } |
160 | 160 |
161 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", !!context_provider); | 161 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", !!context_provider); |
162 | 162 |
| 163 if (context_provider) { |
| 164 scoped_refptr<base::SingleThreadTaskRunner> compositor_thread_task_runner = |
| 165 GetCompositorMessageLoop(); |
| 166 if (!compositor_thread_task_runner.get()) |
| 167 compositor_thread_task_runner = base::MessageLoopProxy::current(); |
| 168 |
| 169 // Here we know the GpuProcessHost has been set up, because we created a |
| 170 // context. |
| 171 output_surface_proxy_->ConnectToGpuProcessHost( |
| 172 compositor_thread_task_runner.get()); |
| 173 } |
| 174 |
163 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 175 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
164 switches::kUseSurfaces)) { | 176 switches::kUseSurfaces)) { |
165 // This gets a bit confusing. Here we have a ContextProvider configured to | 177 // This gets a bit confusing. Here we have a ContextProvider configured to |
166 // render directly to this widget. We need to make an OnscreenDisplayClient | 178 // render directly to this widget. We need to make an OnscreenDisplayClient |
167 // associated with this context, then return a SurfaceDisplayOutputSurface | 179 // associated with this context, then return a SurfaceDisplayOutputSurface |
168 // set up to draw to the display's surface. | 180 // set up to draw to the display's surface. |
169 cc::SurfaceManager* manager = surface_manager_.get(); | 181 cc::SurfaceManager* manager = surface_manager_.get(); |
170 scoped_ptr<cc::OutputSurface> software_surface; | 182 scoped_ptr<cc::OutputSurface> software_surface; |
171 if (!context_provider) { | 183 if (!context_provider) { |
172 software_surface = | 184 software_surface = |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 scoped_ptr<SoftwareBrowserCompositorOutputSurface> surface( | 218 scoped_ptr<SoftwareBrowserCompositorOutputSurface> surface( |
207 new SoftwareBrowserCompositorOutputSurface( | 219 new SoftwareBrowserCompositorOutputSurface( |
208 output_surface_proxy_, | 220 output_surface_proxy_, |
209 CreateSoftwareOutputDevice(compositor), | 221 CreateSoftwareOutputDevice(compositor), |
210 per_compositor_data_[compositor]->surface_id, | 222 per_compositor_data_[compositor]->surface_id, |
211 &output_surface_map_, | 223 &output_surface_map_, |
212 compositor->vsync_manager())); | 224 compositor->vsync_manager())); |
213 return surface.PassAs<cc::OutputSurface>(); | 225 return surface.PassAs<cc::OutputSurface>(); |
214 } | 226 } |
215 | 227 |
216 scoped_refptr<base::SingleThreadTaskRunner> compositor_thread_task_runner = | |
217 GetCompositorMessageLoop(); | |
218 if (!compositor_thread_task_runner.get()) | |
219 compositor_thread_task_runner = base::MessageLoopProxy::current(); | |
220 | |
221 // Here we know the GpuProcessHost has been set up, because we created a | |
222 // context. | |
223 output_surface_proxy_->ConnectToGpuProcessHost( | |
224 compositor_thread_task_runner.get()); | |
225 | |
226 scoped_ptr<BrowserCompositorOutputSurface> surface( | 228 scoped_ptr<BrowserCompositorOutputSurface> surface( |
227 new GpuBrowserCompositorOutputSurface( | 229 new GpuBrowserCompositorOutputSurface( |
228 context_provider, | 230 context_provider, |
229 per_compositor_data_[compositor]->surface_id, | 231 per_compositor_data_[compositor]->surface_id, |
230 &output_surface_map_, | 232 &output_surface_map_, |
231 compositor->vsync_manager(), | 233 compositor->vsync_manager(), |
232 CreateOverlayCandidateValidator(compositor->widget()))); | 234 CreateOverlayCandidateValidator(compositor->widget()))); |
233 if (data->reflector.get()) | 235 if (data->reflector.get()) |
234 data->reflector->ReattachToOutputSurfaceFromMainThread(surface.get()); | 236 data->reflector->ReattachToOutputSurfaceFromMainThread(surface.get()); |
235 | 237 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 443 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
442 observer_list_, | 444 observer_list_, |
443 OnLostResources()); | 445 OnLostResources()); |
444 | 446 |
445 // Kill things that use the shared context before killing the shared context. | 447 // Kill things that use the shared context before killing the shared context. |
446 lost_gl_helper.reset(); | 448 lost_gl_helper.reset(); |
447 lost_shared_main_thread_contexts = NULL; | 449 lost_shared_main_thread_contexts = NULL; |
448 } | 450 } |
449 | 451 |
450 } // namespace content | 452 } // namespace content |
OLD | NEW |