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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 int surface_id; | 67 int surface_id; |
68 scoped_refptr<ReflectorImpl> reflector; | 68 scoped_refptr<ReflectorImpl> reflector; |
69 scoped_ptr<OnscreenDisplayClient> display_client; | 69 scoped_ptr<OnscreenDisplayClient> display_client; |
70 }; | 70 }; |
71 | 71 |
72 GpuProcessTransportFactory::GpuProcessTransportFactory() | 72 GpuProcessTransportFactory::GpuProcessTransportFactory() |
73 : next_surface_id_namespace_(1u), | 73 : next_surface_id_namespace_(1u), |
74 callback_factory_(this) { | 74 callback_factory_(this) { |
75 output_surface_proxy_ = new BrowserCompositorOutputSurfaceProxy( | 75 output_surface_proxy_ = new BrowserCompositorOutputSurfaceProxy( |
76 &output_surface_map_); | 76 &output_surface_map_); |
77 | 77 #if defined(OS_CHROMEOS) |
| 78 bool use_thread = !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 79 switches::kUIDisableThreadedCompositing); |
| 80 #else |
| 81 bool use_thread = false; |
| 82 #endif |
| 83 if (use_thread) { |
| 84 compositor_thread_.reset(new base::Thread("Browser Compositor")); |
| 85 compositor_thread_->Start(); |
| 86 } |
78 if (UseSurfacesEnabled()) | 87 if (UseSurfacesEnabled()) |
79 surface_manager_ = make_scoped_ptr(new cc::SurfaceManager); | 88 surface_manager_ = make_scoped_ptr(new cc::SurfaceManager); |
80 } | 89 } |
81 | 90 |
82 GpuProcessTransportFactory::~GpuProcessTransportFactory() { | 91 GpuProcessTransportFactory::~GpuProcessTransportFactory() { |
83 DCHECK(per_compositor_data_.empty()); | 92 DCHECK(per_compositor_data_.empty()); |
84 | 93 |
85 // Make sure the lost context callback doesn't try to run during destruction. | 94 // Make sure the lost context callback doesn't try to run during destruction. |
86 callback_factory_.InvalidateWeakPtrs(); | 95 callback_factory_.InvalidateWeakPtrs(); |
87 } | 96 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 output_surface->set_display_client(display_client.get()); | 240 output_surface->set_display_client(display_client.get()); |
232 display_client->display()->Resize(compositor->size()); | 241 display_client->display()->Resize(compositor->size()); |
233 data->display_client = display_client.Pass(); | 242 data->display_client = display_client.Pass(); |
234 compositor->SetOutputSurface(output_surface.Pass()); | 243 compositor->SetOutputSurface(output_surface.Pass()); |
235 return; | 244 return; |
236 } | 245 } |
237 | 246 |
238 if (!context_provider.get()) { | 247 if (!context_provider.get()) { |
239 if (compositor_thread_.get()) { | 248 if (compositor_thread_.get()) { |
240 LOG(FATAL) << "Failed to create UI context, but can't use software" | 249 LOG(FATAL) << "Failed to create UI context, but can't use software" |
241 " compositing with browser threaded compositing. Aborting."; | 250 " compositing with browser threaded compositing. Aborting."; |
242 } | 251 } |
243 | 252 |
244 scoped_ptr<SoftwareBrowserCompositorOutputSurface> surface( | 253 scoped_ptr<SoftwareBrowserCompositorOutputSurface> surface( |
245 new SoftwareBrowserCompositorOutputSurface( | 254 new SoftwareBrowserCompositorOutputSurface( |
246 output_surface_proxy_, | 255 output_surface_proxy_, |
247 CreateSoftwareOutputDevice(compositor.get()), | 256 CreateSoftwareOutputDevice(compositor.get()), |
248 data->surface_id, | 257 data->surface_id, |
249 &output_surface_map_, | 258 &output_surface_map_, |
250 compositor->vsync_manager())); | 259 compositor->vsync_manager())); |
251 compositor->SetOutputSurface(surface.Pass()); | 260 compositor->SetOutputSurface(surface.Pass()); |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 537 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
529 observer_list_, | 538 observer_list_, |
530 OnLostResources()); | 539 OnLostResources()); |
531 | 540 |
532 // Kill things that use the shared context before killing the shared context. | 541 // Kill things that use the shared context before killing the shared context. |
533 lost_gl_helper.reset(); | 542 lost_gl_helper.reset(); |
534 lost_shared_main_thread_contexts = NULL; | 543 lost_shared_main_thread_contexts = NULL; |
535 } | 544 } |
536 | 545 |
537 } // namespace content | 546 } // namespace content |
OLD | NEW |