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/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/threading/thread.h" | 14 #include "base/threading/thread.h" |
15 #include "cc/output/compositor_frame.h" | 15 #include "cc/output/compositor_frame.h" |
16 #include "cc/output/output_surface.h" | 16 #include "cc/output/output_surface.h" |
17 #include "cc/surfaces/surface_manager.h" | 17 #include "cc/surfaces/surface_manager.h" |
18 #include "content/browser/compositor/browser_compositor_output_surface.h" | 18 #include "content/browser/compositor/browser_compositor_output_surface.h" |
19 #include "content/browser/compositor/browser_compositor_output_surface_proxy.h" | 19 #include "content/browser/compositor/browser_compositor_output_surface_proxy.h" |
20 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" | 20 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" |
21 #include "content/browser/compositor/onscreen_display_client.h" | 21 #include "content/browser/compositor/onscreen_display_client.h" |
22 #include "content/browser/compositor/reflector_impl.h" | 22 #include "content/browser/compositor/reflector_impl.h" |
23 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" | 23 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" |
24 #include "content/browser/compositor/surface_display_output_surface.h" | 24 #include "content/browser/compositor/surface_display_output_surface.h" |
25 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 25 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 26 #include "content/browser/gpu/compositor_util.h" |
26 #include "content/browser/gpu/gpu_data_manager_impl.h" | 27 #include "content/browser/gpu/gpu_data_manager_impl.h" |
27 #include "content/browser/gpu/gpu_surface_tracker.h" | 28 #include "content/browser/gpu/gpu_surface_tracker.h" |
28 #include "content/browser/renderer_host/render_widget_host_impl.h" | 29 #include "content/browser/renderer_host/render_widget_host_impl.h" |
29 #include "content/common/gpu/client/context_provider_command_buffer.h" | 30 #include "content/common/gpu/client/context_provider_command_buffer.h" |
30 #include "content/common/gpu/client/gl_helper.h" | 31 #include "content/common/gpu/client/gl_helper.h" |
31 #include "content/common/gpu/client/gpu_channel_host.h" | 32 #include "content/common/gpu/client/gpu_channel_host.h" |
32 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 33 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
33 #include "content/common/gpu/gpu_process_launch_causes.h" | 34 #include "content/common/gpu/gpu_process_launch_causes.h" |
34 #include "content/common/host_shared_bitmap_manager.h" | 35 #include "content/common/host_shared_bitmap_manager.h" |
35 #include "content/public/common/content_switches.h" | 36 #include "content/public/common/content_switches.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 #if defined(OS_CHROMEOS) | 75 #if defined(OS_CHROMEOS) |
75 bool use_thread = !base::CommandLine::ForCurrentProcess()->HasSwitch( | 76 bool use_thread = !base::CommandLine::ForCurrentProcess()->HasSwitch( |
76 switches::kUIDisableThreadedCompositing); | 77 switches::kUIDisableThreadedCompositing); |
77 #else | 78 #else |
78 bool use_thread = false; | 79 bool use_thread = false; |
79 #endif | 80 #endif |
80 if (use_thread) { | 81 if (use_thread) { |
81 compositor_thread_.reset(new base::Thread("Browser Compositor")); | 82 compositor_thread_.reset(new base::Thread("Browser Compositor")); |
82 compositor_thread_->Start(); | 83 compositor_thread_->Start(); |
83 } | 84 } |
84 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 85 if (UseSurfacesEnabled()) |
85 switches::kUseSurfaces)) { | |
86 surface_manager_ = make_scoped_ptr(new cc::SurfaceManager); | 86 surface_manager_ = make_scoped_ptr(new cc::SurfaceManager); |
87 } | |
88 } | 87 } |
89 | 88 |
90 GpuProcessTransportFactory::~GpuProcessTransportFactory() { | 89 GpuProcessTransportFactory::~GpuProcessTransportFactory() { |
91 DCHECK(per_compositor_data_.empty()); | 90 DCHECK(per_compositor_data_.empty()); |
92 | 91 |
93 // Make sure the lost context callback doesn't try to run during destruction. | 92 // Make sure the lost context callback doesn't try to run during destruction. |
94 callback_factory_.InvalidateWeakPtrs(); | 93 callback_factory_.InvalidateWeakPtrs(); |
95 } | 94 } |
96 | 95 |
97 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 96 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 GetCompositorMessageLoop(); | 166 GetCompositorMessageLoop(); |
168 if (!compositor_thread_task_runner.get()) | 167 if (!compositor_thread_task_runner.get()) |
169 compositor_thread_task_runner = base::MessageLoopProxy::current(); | 168 compositor_thread_task_runner = base::MessageLoopProxy::current(); |
170 | 169 |
171 // Here we know the GpuProcessHost has been set up, because we created a | 170 // Here we know the GpuProcessHost has been set up, because we created a |
172 // context. | 171 // context. |
173 output_surface_proxy_->ConnectToGpuProcessHost( | 172 output_surface_proxy_->ConnectToGpuProcessHost( |
174 compositor_thread_task_runner.get()); | 173 compositor_thread_task_runner.get()); |
175 } | 174 } |
176 | 175 |
177 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 176 if (UseSurfacesEnabled()) { |
178 switches::kUseSurfaces)) { | |
179 // 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 |
180 // render directly to this widget. We need to make an OnscreenDisplayClient | 178 // render directly to this widget. We need to make an OnscreenDisplayClient |
181 // associated with this context, then return a SurfaceDisplayOutputSurface | 179 // associated with this context, then return a SurfaceDisplayOutputSurface |
182 // set up to draw to the display's surface. | 180 // set up to draw to the display's surface. |
183 cc::SurfaceManager* manager = surface_manager_.get(); | 181 cc::SurfaceManager* manager = surface_manager_.get(); |
184 scoped_ptr<cc::OutputSurface> display_surface; | 182 scoped_ptr<cc::OutputSurface> display_surface; |
185 if (!context_provider.get()) { | 183 if (!context_provider.get()) { |
186 display_surface = | 184 display_surface = |
187 make_scoped_ptr(new SoftwareBrowserCompositorOutputSurface( | 185 make_scoped_ptr(new SoftwareBrowserCompositorOutputSurface( |
188 output_surface_proxy_, | 186 output_surface_proxy_, |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 458 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
461 observer_list_, | 459 observer_list_, |
462 OnLostResources()); | 460 OnLostResources()); |
463 | 461 |
464 // Kill things that use the shared context before killing the shared context. | 462 // Kill things that use the shared context before killing the shared context. |
465 lost_gl_helper.reset(); | 463 lost_gl_helper.reset(); |
466 lost_shared_main_thread_contexts = NULL; | 464 lost_shared_main_thread_contexts = NULL; |
467 } | 465 } |
468 | 466 |
469 } // namespace content | 467 } // namespace content |
OLD | NEW |