| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 ui::Compositor::GetCompositorMessageLoop(); | 245 ui::Compositor::GetCompositorMessageLoop(); |
| 245 if (!compositor_thread_task_runner.get()) | 246 if (!compositor_thread_task_runner.get()) |
| 246 compositor_thread_task_runner = base::MessageLoopProxy::current(); | 247 compositor_thread_task_runner = base::MessageLoopProxy::current(); |
| 247 | 248 |
| 248 // Here we know the GpuProcessHost has been set up, because we created a | 249 // Here we know the GpuProcessHost has been set up, because we created a |
| 249 // context. | 250 // context. |
| 250 output_surface_proxy_->ConnectToGpuProcessHost( | 251 output_surface_proxy_->ConnectToGpuProcessHost( |
| 251 compositor_thread_task_runner.get()); | 252 compositor_thread_task_runner.get()); |
| 252 | 253 |
| 253 scoped_ptr<BrowserCompositorOutputSurface> surface( | 254 scoped_ptr<BrowserCompositorOutputSurface> surface( |
| 254 new BrowserCompositorOutputSurface( | 255 new BrowserCompositorOutputSurface(context_provider, |
| 255 context_provider, | 256 data->surface_id, |
| 256 per_compositor_data_[compositor]->surface_id, | 257 &output_surface_map_, |
| 257 &output_surface_map_, | 258 base::MessageLoopProxy::current(), |
| 258 base::MessageLoopProxy::current().get(), | 259 compositor->AsWeakPtr())); |
| 259 compositor->AsWeakPtr())); | |
| 260 if (data->reflector.get()) { | 260 if (data->reflector.get()) { |
| 261 data->reflector->CreateSharedTexture(); | 261 data->reflector->CreateSharedTexture(); |
| 262 data->reflector->AttachToOutputSurface(surface.get()); | 262 data->reflector->AttachToOutputSurface(surface.get()); |
| 263 } | 263 } |
| 264 | 264 |
| 265 return surface.PassAs<cc::OutputSurface>(); | 265 return surface.PassAs<cc::OutputSurface>(); |
| 266 } | 266 } |
| 267 | 267 |
| 268 scoped_refptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( | 268 scoped_refptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( |
| 269 ui::Compositor* source, | 269 ui::Compositor* source, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 300 DCHECK(data); | 300 DCHECK(data); |
| 301 GpuSurfaceTracker::Get()->RemoveSurface(data->surface_id); | 301 GpuSurfaceTracker::Get()->RemoveSurface(data->surface_id); |
| 302 delete data; | 302 delete data; |
| 303 per_compositor_data_.erase(it); | 303 per_compositor_data_.erase(it); |
| 304 if (per_compositor_data_.empty()) | 304 if (per_compositor_data_.empty()) |
| 305 gl_helper_.reset(); | 305 gl_helper_.reset(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 bool GpuProcessTransportFactory::DoesCreateTestContexts() { return false; } | 308 bool GpuProcessTransportFactory::DoesCreateTestContexts() { return false; } |
| 309 | 309 |
| 310 scoped_ptr<SurfaceCapturer> |
| 311 GpuProcessTransportFactory::CreateOutputSurfaceCapturer( |
| 312 ui::Compositor* compositor, |
| 313 SurfaceCapturer::Client* client) { |
| 314 scoped_ptr<SurfaceCapturer> capturer; |
| 315 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor); |
| 316 if (it == per_compositor_data_.end()) |
| 317 return capturer.Pass(); |
| 318 PerCompositorData* data = it->second; |
| 319 DCHECK(data); |
| 320 capturer.reset(new BrowserCompositorOutputSurfaceCapturer( |
| 321 &output_surface_map_, data->surface_id, client)); |
| 322 return capturer.Pass(); |
| 323 } |
| 324 |
| 310 ui::ContextFactory* GpuProcessTransportFactory::AsContextFactory() { | 325 ui::ContextFactory* GpuProcessTransportFactory::AsContextFactory() { |
| 311 return this; | 326 return this; |
| 312 } | 327 } |
| 313 | 328 |
| 329 SurfaceCapturingContextFactory* |
| 330 GpuProcessTransportFactory::AsSurfaceCapturingContextFactory() { |
| 331 return this; |
| 332 } |
| 333 |
| 314 gfx::GLSurfaceHandle GpuProcessTransportFactory::CreateSharedSurfaceHandle() { | 334 gfx::GLSurfaceHandle GpuProcessTransportFactory::CreateSharedSurfaceHandle() { |
| 315 CreateSharedContextLazy(); | 335 CreateSharedContextLazy(); |
| 316 if (!shared_contexts_main_thread_ || | 336 if (!shared_contexts_main_thread_ || |
| 317 !shared_contexts_main_thread_->Context3d()) | 337 !shared_contexts_main_thread_->Context3d()) |
| 318 return gfx::GLSurfaceHandle(); | 338 return gfx::GLSurfaceHandle(); |
| 319 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( | 339 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( |
| 320 gfx::kNullPluginWindow, gfx::TEXTURE_TRANSPORT); | 340 gfx::kNullPluginWindow, gfx::TEXTURE_TRANSPORT); |
| 321 handle.parent_gpu_process_id = | 341 handle.parent_gpu_process_id = |
| 322 shared_contexts_main_thread_->Context3d()->GetGPUProcessID(); | 342 shared_contexts_main_thread_->Context3d()->GetGPUProcessID(); |
| 323 handle.parent_client_id = | 343 handle.parent_client_id = |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 shared_contexts_main_thread_ = NULL; | 521 shared_contexts_main_thread_ = NULL; |
| 502 | 522 |
| 503 scoped_ptr<GLHelper> old_helper(gl_helper_.release()); | 523 scoped_ptr<GLHelper> old_helper(gl_helper_.release()); |
| 504 | 524 |
| 505 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 525 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
| 506 observer_list_, | 526 observer_list_, |
| 507 OnLostResources()); | 527 OnLostResources()); |
| 508 } | 528 } |
| 509 | 529 |
| 510 } // namespace content | 530 } // namespace content |
| OLD | NEW |