Chromium Code Reviews| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 #elif defined(USE_X11) | 71 #elif defined(USE_X11) |
| 72 #include "content/browser/compositor/software_output_device_x11.h" | 72 #include "content/browser/compositor/software_output_device_x11.h" |
| 73 #elif defined(OS_MACOSX) | 73 #elif defined(OS_MACOSX) |
| 74 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida tor_mac.h" | 74 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida tor_mac.h" |
| 75 #include "content/browser/compositor/software_output_device_mac.h" | 75 #include "content/browser/compositor/software_output_device_mac.h" |
| 76 #include "ui/base/cocoa/remote_layer_api.h" | 76 #include "ui/base/cocoa/remote_layer_api.h" |
| 77 #elif defined(OS_ANDROID) | 77 #elif defined(OS_ANDROID) |
| 78 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida tor_android.h" | 78 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida tor_android.h" |
| 79 #endif | 79 #endif |
| 80 | 80 |
| 81 #if defined(ENABLE_VULKAN) | |
| 82 #include "cc/output/vulkan_derived_context_provider.h" | |
| 83 #include "cc/output/vulkan_in_process_context_provider.h" | |
| 84 #include "content/browser/compositor/vulkan_browser_compositor_output_surface.h" | |
| 85 #endif | |
| 86 | |
| 81 using cc::ContextProvider; | 87 using cc::ContextProvider; |
| 82 using gpu::gles2::GLES2Interface; | 88 using gpu::gles2::GLES2Interface; |
| 83 | 89 |
| 84 static const int kNumRetriesBeforeSoftwareFallback = 4; | 90 static const int kNumRetriesBeforeSoftwareFallback = 4; |
| 85 | 91 |
| 86 namespace content { | 92 namespace content { |
| 87 | 93 |
| 88 struct GpuProcessTransportFactory::PerCompositorData { | 94 struct GpuProcessTransportFactory::PerCompositorData { |
| 89 int surface_id; | 95 int surface_id; |
| 90 BrowserCompositorOutputSurface* surface; | 96 BrowserCompositorOutputSurface* surface; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 output_surface_map_.Remove(data->surface_id); | 222 output_surface_map_.Remove(data->surface_id); |
| 217 data->surface = nullptr; | 223 data->surface = nullptr; |
| 218 } | 224 } |
| 219 | 225 |
| 220 #if defined(OS_WIN) | 226 #if defined(OS_WIN) |
| 221 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( | 227 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( |
| 222 compositor->widget()); | 228 compositor->widget()); |
| 223 #endif | 229 #endif |
| 224 | 230 |
| 225 bool create_gpu_output_surface = | 231 bool create_gpu_output_surface = |
| 232 #if defined(ENABLE_VULKAN) | |
| 233 !SharedVulkanContextProvider() && | |
| 234 #endif | |
|
piman
2016/04/19 01:36:42
create_gpu_output_surface really means "don't fall
David Yen
2016/04/19 22:20:28
Seems we need to check the switch everytime Shared
| |
| 226 ShouldCreateGpuOutputSurface(compositor.get()); | 235 ShouldCreateGpuOutputSurface(compositor.get()); |
| 227 if (create_gpu_output_surface) { | 236 if (create_gpu_output_surface) { |
| 228 CauseForGpuLaunch cause = | 237 CauseForGpuLaunch cause = |
| 229 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; | 238 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; |
| 230 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( | 239 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( |
| 231 cause, base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, | 240 cause, base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, |
| 232 callback_factory_.GetWeakPtr(), compositor, | 241 callback_factory_.GetWeakPtr(), compositor, |
| 233 create_gpu_output_surface, 0)); | 242 create_gpu_output_surface, 0)); |
| 234 } else { | 243 } else { |
| 235 EstablishedGpuChannel(compositor, create_gpu_output_surface, 0); | 244 EstablishedGpuChannel(compositor, create_gpu_output_surface, 0); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; | 327 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; |
| 319 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( | 328 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( |
| 320 cause, base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, | 329 cause, base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, |
| 321 callback_factory_.GetWeakPtr(), compositor, | 330 callback_factory_.GetWeakPtr(), compositor, |
| 322 create_gpu_output_surface, num_attempts + 1)); | 331 create_gpu_output_surface, num_attempts + 1)); |
| 323 return; | 332 return; |
| 324 } | 333 } |
| 325 } | 334 } |
| 326 | 335 |
| 327 std::unique_ptr<BrowserCompositorOutputSurface> surface; | 336 std::unique_ptr<BrowserCompositorOutputSurface> surface; |
| 328 if (!create_gpu_output_surface) { | 337 #if defined(ENABLE_VULKAN) |
| 338 scoped_refptr<cc::VulkanInProcessContextProvider> vulkan_context_provider = | |
| 339 SharedVulkanContextProvider(); | |
| 340 if (vulkan_context_provider) { | |
| 341 surface = make_scoped_ptr(new VulkanBrowserCompositorOutputSurface( | |
| 342 cc::VulkanDerivedContextProvider::Create(vulkan_context_provider, | |
| 343 compositor.get()->widget()), | |
| 344 compositor->vsync_manager())); | |
| 345 } else | |
| 346 #endif | |
| 347 if (!create_gpu_output_surface) { | |
| 329 surface = base::WrapUnique(new SoftwareBrowserCompositorOutputSurface( | 348 surface = base::WrapUnique(new SoftwareBrowserCompositorOutputSurface( |
| 330 CreateSoftwareOutputDevice(compositor.get()), | 349 CreateSoftwareOutputDevice(compositor.get()), |
| 331 compositor->vsync_manager(), compositor->task_runner().get())); | 350 compositor->vsync_manager(), compositor->task_runner().get())); |
| 332 } else { | 351 } else { |
| 333 DCHECK(context_provider); | 352 DCHECK(context_provider); |
| 334 ContextProvider::Capabilities capabilities = | 353 ContextProvider::Capabilities capabilities = |
| 335 context_provider->ContextCapabilities(); | 354 context_provider->ContextCapabilities(); |
| 336 if (!data->surface_id) { | 355 if (!data->surface_id) { |
| 337 surface = base::WrapUnique(new OffscreenBrowserCompositorOutputSurface( | 356 surface = base::WrapUnique(new OffscreenBrowserCompositorOutputSurface( |
| 338 context_provider, shared_worker_context_provider_, | 357 context_provider, shared_worker_context_provider_, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 383 // SurfaceDisplayOutputSurface set up to draw to the display's surface. | 402 // SurfaceDisplayOutputSurface set up to draw to the display's surface. |
| 384 cc::SurfaceManager* manager = surface_manager_.get(); | 403 cc::SurfaceManager* manager = surface_manager_.get(); |
| 385 std::unique_ptr<cc::OnscreenDisplayClient> display_client( | 404 std::unique_ptr<cc::OnscreenDisplayClient> display_client( |
| 386 new cc::OnscreenDisplayClient( | 405 new cc::OnscreenDisplayClient( |
| 387 std::move(surface), manager, HostSharedBitmapManager::current(), | 406 std::move(surface), manager, HostSharedBitmapManager::current(), |
| 388 BrowserGpuMemoryBufferManager::current(), | 407 BrowserGpuMemoryBufferManager::current(), |
| 389 compositor->GetRendererSettings(), compositor->task_runner(), | 408 compositor->GetRendererSettings(), compositor->task_runner(), |
| 390 compositor->surface_id_allocator()->id_namespace())); | 409 compositor->surface_id_allocator()->id_namespace())); |
| 391 | 410 |
| 392 std::unique_ptr<cc::SurfaceDisplayOutputSurface> output_surface( | 411 std::unique_ptr<cc::SurfaceDisplayOutputSurface> output_surface( |
| 393 new cc::SurfaceDisplayOutputSurface( | 412 #if defined(ENABLE_VULKAN) |
| 394 manager, compositor->surface_id_allocator(), context_provider, | 413 vulkan_context_provider |
| 395 shared_worker_context_provider_)); | 414 ? new cc::SurfaceDisplayOutputSurface( |
| 415 manager, compositor->surface_id_allocator(), | |
| 416 static_cast<scoped_refptr<cc::VulkanContextProvider>>( | |
| 417 vulkan_context_provider)) | |
| 418 : | |
| 419 #endif | |
| 420 new cc::SurfaceDisplayOutputSurface( | |
| 421 manager, compositor->surface_id_allocator(), context_provider, | |
| 422 shared_worker_context_provider_)); | |
| 396 display_client->set_surface_output_surface(output_surface.get()); | 423 display_client->set_surface_output_surface(output_surface.get()); |
| 397 output_surface->set_display_client(display_client.get()); | 424 output_surface->set_display_client(display_client.get()); |
| 398 display_client->display()->Resize(compositor->size()); | 425 display_client->display()->Resize(compositor->size()); |
| 399 data->display_client = std::move(display_client); | 426 data->display_client = std::move(display_client); |
| 400 compositor->SetOutputSurface(std::move(output_surface)); | 427 compositor->SetOutputSurface(std::move(output_surface)); |
| 401 } | 428 } |
| 402 | 429 |
| 403 std::unique_ptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( | 430 std::unique_ptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( |
| 404 ui::Compositor* source_compositor, | 431 ui::Compositor* source_compositor, |
| 405 ui::Layer* target_layer) { | 432 ui::Layer* target_layer) { |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 676 | 703 |
| 677 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 704 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
| 678 observer_list_, | 705 observer_list_, |
| 679 OnLostResources()); | 706 OnLostResources()); |
| 680 | 707 |
| 681 // Kill things that use the shared context before killing the shared context. | 708 // Kill things that use the shared context before killing the shared context. |
| 682 lost_gl_helper.reset(); | 709 lost_gl_helper.reset(); |
| 683 lost_shared_main_thread_contexts = NULL; | 710 lost_shared_main_thread_contexts = NULL; |
| 684 } | 711 } |
| 685 | 712 |
| 713 #if defined(ENABLE_VULKAN) | |
| 714 scoped_refptr<cc::VulkanInProcessContextProvider> | |
| 715 GpuProcessTransportFactory::SharedVulkanContextProvider() { | |
| 716 if (!shared_vulkan_context_provider_initialized_) { | |
| 717 shared_vulkan_context_provider_ = | |
| 718 cc::VulkanInProcessContextProvider::Create(); | |
| 719 if (!shared_vulkan_context_provider_->Initialize()) | |
| 720 shared_vulkan_context_provider_ = nullptr; | |
| 721 | |
| 722 shared_vulkan_context_provider_initialized_ = true; | |
| 723 } | |
| 724 return shared_vulkan_context_provider_; | |
| 725 } | |
| 726 #endif | |
| 727 | |
| 686 } // namespace content | 728 } // namespace content |
| OLD | NEW |