| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/aura/gpu_process_transport_factory.h" | 5 #include "content/browser/aura/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 "cc/output/compositor_frame.h" | 14 #include "cc/output/compositor_frame.h" |
| 15 #include "cc/output/output_surface.h" | 15 #include "cc/output/output_surface.h" |
| 16 #include "content/browser/aura/browser_compositor_output_surface.h" | 16 #include "content/browser/aura/browser_compositor_output_surface.h" |
| 17 #include "content/browser/aura/browser_compositor_output_surface_proxy.h" | 17 #include "content/browser/aura/browser_compositor_output_surface_proxy.h" |
| 18 #include "content/browser/aura/gpu_browser_compositor_output_surface.h" |
| 18 #include "content/browser/aura/reflector_impl.h" | 19 #include "content/browser/aura/reflector_impl.h" |
| 19 #include "content/browser/aura/software_browser_compositor_output_surface.h" | 20 #include "content/browser/aura/software_browser_compositor_output_surface.h" |
| 20 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 21 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 21 #include "content/browser/gpu/gpu_data_manager_impl.h" | 22 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 22 #include "content/browser/gpu/gpu_surface_tracker.h" | 23 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 23 #include "content/browser/renderer_host/render_widget_host_impl.h" | 24 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 24 #include "content/common/gpu/client/context_provider_command_buffer.h" | 25 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 25 #include "content/common/gpu/client/gl_helper.h" | 26 #include "content/common/gpu/client/gl_helper.h" |
| 26 #include "content/common/gpu/client/gpu_channel_host.h" | 27 #include "content/common/gpu/client/gpu_channel_host.h" |
| 27 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 28 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 } | 196 } |
| 196 | 197 |
| 197 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", !!context_provider); | 198 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", !!context_provider); |
| 198 | 199 |
| 199 if (!context_provider.get()) { | 200 if (!context_provider.get()) { |
| 200 if (ui::Compositor::WasInitializedWithThread()) { | 201 if (ui::Compositor::WasInitializedWithThread()) { |
| 201 LOG(FATAL) << "Failed to create UI context, but can't use software" | 202 LOG(FATAL) << "Failed to create UI context, but can't use software" |
| 202 " compositing with browser threaded compositing. Aborting."; | 203 " compositing with browser threaded compositing. Aborting."; |
| 203 } | 204 } |
| 204 | 205 |
| 205 scoped_ptr<SoftwareBrowserCompositorOutputSurface> surface = | 206 scoped_ptr<SoftwareBrowserCompositorOutputSurface> surface( |
| 206 SoftwareBrowserCompositorOutputSurface::Create( | 207 new SoftwareBrowserCompositorOutputSurface( |
| 207 CreateSoftwareOutputDevice(compositor)); | 208 output_surface_proxy_, |
| 209 CreateSoftwareOutputDevice(compositor), |
| 210 per_compositor_data_[compositor]->surface_id, |
| 211 &output_surface_map_, |
| 212 base::MessageLoopProxy::current().get(), |
| 213 compositor->AsWeakPtr())); |
| 208 return surface.PassAs<cc::OutputSurface>(); | 214 return surface.PassAs<cc::OutputSurface>(); |
| 209 } | 215 } |
| 210 | 216 |
| 211 scoped_refptr<base::SingleThreadTaskRunner> compositor_thread_task_runner = | 217 scoped_refptr<base::SingleThreadTaskRunner> compositor_thread_task_runner = |
| 212 ui::Compositor::GetCompositorMessageLoop(); | 218 ui::Compositor::GetCompositorMessageLoop(); |
| 213 if (!compositor_thread_task_runner.get()) | 219 if (!compositor_thread_task_runner.get()) |
| 214 compositor_thread_task_runner = base::MessageLoopProxy::current(); | 220 compositor_thread_task_runner = base::MessageLoopProxy::current(); |
| 215 | 221 |
| 216 // Here we know the GpuProcessHost has been set up, because we created a | 222 // Here we know the GpuProcessHost has been set up, because we created a |
| 217 // context. | 223 // context. |
| 218 output_surface_proxy_->ConnectToGpuProcessHost( | 224 output_surface_proxy_->ConnectToGpuProcessHost( |
| 219 compositor_thread_task_runner.get()); | 225 compositor_thread_task_runner.get()); |
| 220 | 226 |
| 221 scoped_ptr<BrowserCompositorOutputSurface> surface( | 227 scoped_ptr<BrowserCompositorOutputSurface> surface( |
| 222 new BrowserCompositorOutputSurface( | 228 new GpuBrowserCompositorOutputSurface( |
| 223 context_provider, | 229 context_provider, |
| 224 per_compositor_data_[compositor]->surface_id, | 230 per_compositor_data_[compositor]->surface_id, |
| 225 &output_surface_map_, | 231 &output_surface_map_, |
| 226 base::MessageLoopProxy::current().get(), | 232 base::MessageLoopProxy::current().get(), |
| 227 compositor->AsWeakPtr())); | 233 compositor->AsWeakPtr())); |
| 228 if (data->reflector.get()) { | 234 if (data->reflector.get()) { |
| 229 data->reflector->CreateSharedTexture(); | 235 data->reflector->CreateSharedTexture(); |
| 230 data->reflector->AttachToOutputSurface(surface.get()); | 236 data->reflector->AttachToOutputSurface(surface.get()); |
| 231 } | 237 } |
| 232 | 238 |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 observer_list_, | 493 observer_list_, |
| 488 OnLostResources()); | 494 OnLostResources()); |
| 489 | 495 |
| 490 // Kill things that use the shared context before killing the shared context. | 496 // Kill things that use the shared context before killing the shared context. |
| 491 lost_gl_helper.reset(); | 497 lost_gl_helper.reset(); |
| 492 lost_offscreen_compositor_contexts = NULL; | 498 lost_offscreen_compositor_contexts = NULL; |
| 493 lost_shared_main_thread_contexts = NULL; | 499 lost_shared_main_thread_contexts = NULL; |
| 494 } | 500 } |
| 495 | 501 |
| 496 } // namespace content | 502 } // namespace content |
| OLD | NEW |