| 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 #if defined(OS_CHROMEOS) | 77 |
| 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 } | |
| 87 if (UseSurfacesEnabled()) | 78 if (UseSurfacesEnabled()) |
| 88 surface_manager_ = make_scoped_ptr(new cc::SurfaceManager); | 79 surface_manager_ = make_scoped_ptr(new cc::SurfaceManager); |
| 89 } | 80 } |
| 90 | 81 |
| 91 GpuProcessTransportFactory::~GpuProcessTransportFactory() { | 82 GpuProcessTransportFactory::~GpuProcessTransportFactory() { |
| 92 DCHECK(per_compositor_data_.empty()); | 83 DCHECK(per_compositor_data_.empty()); |
| 93 | 84 |
| 94 // Make sure the lost context callback doesn't try to run during destruction. | 85 // Make sure the lost context callback doesn't try to run during destruction. |
| 95 callback_factory_.InvalidateWeakPtrs(); | 86 callback_factory_.InvalidateWeakPtrs(); |
| 96 } | 87 } |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 manager, compositor->surface_id_allocator(), context_provider)); | 229 manager, compositor->surface_id_allocator(), context_provider)); |
| 239 display_client->set_surface_output_surface(output_surface.get()); | 230 display_client->set_surface_output_surface(output_surface.get()); |
| 240 output_surface->set_display_client(display_client.get()); | 231 output_surface->set_display_client(display_client.get()); |
| 241 display_client->display()->Resize(compositor->size()); | 232 display_client->display()->Resize(compositor->size()); |
| 242 data->display_client = display_client.Pass(); | 233 data->display_client = display_client.Pass(); |
| 243 compositor->SetOutputSurface(output_surface.Pass()); | 234 compositor->SetOutputSurface(output_surface.Pass()); |
| 244 return; | 235 return; |
| 245 } | 236 } |
| 246 | 237 |
| 247 if (!context_provider.get()) { | 238 if (!context_provider.get()) { |
| 248 if (compositor_thread_.get()) { | 239 #if defined(OS_CHROMEOS) |
| 249 LOG(FATAL) << "Failed to create UI context, but can't use software" | 240 LOG(FATAL) << "Failed to create UI context, but can't use software" |
| 250 " compositing with browser threaded compositing. Aborting."; | 241 " compositing with browser threaded compositing. Aborting."; |
| 251 } | 242 #endif |
| 252 | 243 |
| 253 scoped_ptr<SoftwareBrowserCompositorOutputSurface> surface( | 244 scoped_ptr<SoftwareBrowserCompositorOutputSurface> surface( |
| 254 new SoftwareBrowserCompositorOutputSurface( | 245 new SoftwareBrowserCompositorOutputSurface( |
| 255 output_surface_proxy_, | 246 output_surface_proxy_, |
| 256 CreateSoftwareOutputDevice(compositor.get()), | 247 CreateSoftwareOutputDevice(compositor.get()), |
| 257 data->surface_id, | 248 data->surface_id, |
| 258 &output_surface_map_, | 249 &output_surface_map_, |
| 259 compositor->vsync_manager())); | 250 compositor->vsync_manager())); |
| 260 compositor->SetOutputSurface(surface.Pass()); | 251 compositor->SetOutputSurface(surface.Pass()); |
| 261 return; | 252 return; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 508 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
| 518 observer_list_, | 509 observer_list_, |
| 519 OnLostResources()); | 510 OnLostResources()); |
| 520 | 511 |
| 521 // Kill things that use the shared context before killing the shared context. | 512 // Kill things that use the shared context before killing the shared context. |
| 522 lost_gl_helper.reset(); | 513 lost_gl_helper.reset(); |
| 523 lost_shared_main_thread_contexts = NULL; | 514 lost_shared_main_thread_contexts = NULL; |
| 524 } | 515 } |
| 525 | 516 |
| 526 } // namespace content | 517 } // namespace content |
| OLD | NEW |