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 "cc/output/compositor_frame.h" | 13 #include "cc/output/compositor_frame.h" |
14 #include "cc/output/output_surface.h" | 14 #include "cc/output/output_surface.h" |
15 #include "content/browser/aura/browser_compositor_output_surface.h" | 15 #include "content/browser/aura/browser_compositor_output_surface.h" |
| 16 #include "content/browser/aura/browser_compositor_output_surface_capturer.h" |
16 #include "content/browser/aura/browser_compositor_output_surface_proxy.h" | 17 #include "content/browser/aura/browser_compositor_output_surface_proxy.h" |
17 #include "content/browser/aura/reflector_impl.h" | 18 #include "content/browser/aura/reflector_impl.h" |
18 #include "content/browser/aura/software_browser_compositor_output_surface.h" | 19 #include "content/browser/aura/software_browser_compositor_output_surface.h" |
19 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 20 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
20 #include "content/browser/gpu/gpu_data_manager_impl.h" | 21 #include "content/browser/gpu/gpu_data_manager_impl.h" |
21 #include "content/browser/gpu/gpu_surface_tracker.h" | 22 #include "content/browser/gpu/gpu_surface_tracker.h" |
22 #include "content/browser/renderer_host/render_widget_host_impl.h" | 23 #include "content/browser/renderer_host/render_widget_host_impl.h" |
23 #include "content/common/gpu/client/context_provider_command_buffer.h" | 24 #include "content/common/gpu/client/context_provider_command_buffer.h" |
24 #include "content/common/gpu/client/gl_helper.h" | 25 #include "content/common/gpu/client/gl_helper.h" |
25 #include "content/common/gpu/client/gpu_channel_host.h" | 26 #include "content/common/gpu/client/gpu_channel_host.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 compositor_thread_task_runner = base::MessageLoopProxy::current(); | 244 compositor_thread_task_runner = base::MessageLoopProxy::current(); |
244 | 245 |
245 // Here we know the GpuProcessHost has been set up, because we created a | 246 // Here we know the GpuProcessHost has been set up, because we created a |
246 // context. | 247 // context. |
247 output_surface_proxy_->ConnectToGpuProcessHost( | 248 output_surface_proxy_->ConnectToGpuProcessHost( |
248 compositor_thread_task_runner.get()); | 249 compositor_thread_task_runner.get()); |
249 | 250 |
250 scoped_ptr<BrowserCompositorOutputSurface> surface( | 251 scoped_ptr<BrowserCompositorOutputSurface> surface( |
251 new BrowserCompositorOutputSurface( | 252 new BrowserCompositorOutputSurface( |
252 context.PassAs<WebKit::WebGraphicsContext3D>(), | 253 context.PassAs<WebKit::WebGraphicsContext3D>(), |
253 per_compositor_data_[compositor]->surface_id, | 254 data->surface_id, |
254 &output_surface_map_, | 255 &output_surface_map_, |
255 base::MessageLoopProxy::current().get(), | 256 base::MessageLoopProxy::current(), |
256 compositor->AsWeakPtr())); | 257 compositor->AsWeakPtr())); |
257 if (data->reflector.get()) { | 258 if (data->reflector.get()) { |
258 data->reflector->CreateSharedTexture(); | 259 data->reflector->CreateSharedTexture(); |
259 data->reflector->AttachToOutputSurface(surface.get()); | 260 data->reflector->AttachToOutputSurface(surface.get()); |
260 } | 261 } |
261 | 262 |
262 return surface.PassAs<cc::OutputSurface>(); | 263 return surface.PassAs<cc::OutputSurface>(); |
263 } | 264 } |
264 | 265 |
265 scoped_refptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( | 266 scoped_refptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 DCHECK(data); | 298 DCHECK(data); |
298 GpuSurfaceTracker::Get()->RemoveSurface(data->surface_id); | 299 GpuSurfaceTracker::Get()->RemoveSurface(data->surface_id); |
299 delete data; | 300 delete data; |
300 per_compositor_data_.erase(it); | 301 per_compositor_data_.erase(it); |
301 if (per_compositor_data_.empty()) | 302 if (per_compositor_data_.empty()) |
302 gl_helper_.reset(); | 303 gl_helper_.reset(); |
303 } | 304 } |
304 | 305 |
305 bool GpuProcessTransportFactory::DoesCreateTestContexts() { return false; } | 306 bool GpuProcessTransportFactory::DoesCreateTestContexts() { return false; } |
306 | 307 |
| 308 scoped_ptr<SurfaceCapturer> |
| 309 GpuProcessTransportFactory::CreateOutputSurfaceCapturer( |
| 310 ui::Compositor* compositor, |
| 311 SurfaceCapturer::Client* client) { |
| 312 scoped_ptr<SurfaceCapturer> capturer; |
| 313 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor); |
| 314 if (it == per_compositor_data_.end()) |
| 315 return capturer.Pass(); |
| 316 PerCompositorData* data = it->second; |
| 317 DCHECK(data); |
| 318 capturer.reset(new BrowserCompositorOutputSurfaceCapturer( |
| 319 &output_surface_map_, data->surface_id, client)); |
| 320 return capturer.Pass(); |
| 321 } |
| 322 |
307 ui::ContextFactory* GpuProcessTransportFactory::AsContextFactory() { | 323 ui::ContextFactory* GpuProcessTransportFactory::AsContextFactory() { |
308 return this; | 324 return this; |
309 } | 325 } |
310 | 326 |
| 327 SurfaceCapturingContextFactory* |
| 328 GpuProcessTransportFactory::AsSurfaceCapturingContextFactory() { |
| 329 return this; |
| 330 } |
| 331 |
311 gfx::GLSurfaceHandle GpuProcessTransportFactory::CreateSharedSurfaceHandle() { | 332 gfx::GLSurfaceHandle GpuProcessTransportFactory::CreateSharedSurfaceHandle() { |
312 CreateSharedContextLazy(); | 333 CreateSharedContextLazy(); |
313 if (!shared_contexts_main_thread_ || | 334 if (!shared_contexts_main_thread_ || |
314 !shared_contexts_main_thread_->Context3d()) | 335 !shared_contexts_main_thread_->Context3d()) |
315 return gfx::GLSurfaceHandle(); | 336 return gfx::GLSurfaceHandle(); |
316 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( | 337 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( |
317 gfx::kNullPluginWindow, gfx::TEXTURE_TRANSPORT); | 338 gfx::kNullPluginWindow, gfx::TEXTURE_TRANSPORT); |
318 handle.parent_gpu_process_id = | 339 handle.parent_gpu_process_id = |
319 shared_contexts_main_thread_->Context3d()->GetGPUProcessID(); | 340 shared_contexts_main_thread_->Context3d()->GetGPUProcessID(); |
320 handle.parent_client_id = | 341 handle.parent_client_id = |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 shared_contexts_main_thread_ = NULL; | 523 shared_contexts_main_thread_ = NULL; |
503 | 524 |
504 scoped_ptr<GLHelper> old_helper(gl_helper_.release()); | 525 scoped_ptr<GLHelper> old_helper(gl_helper_.release()); |
505 | 526 |
506 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 527 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
507 observer_list_, | 528 observer_list_, |
508 OnLostResources()); | 529 OnLostResources()); |
509 } | 530 } |
510 | 531 |
511 } // namespace content | 532 } // namespace content |
OLD | NEW |