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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 #if defined(OS_WIN) | 287 #if defined(OS_WIN) |
288 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( | 288 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( |
289 compositor->widget()); | 289 compositor->widget()); |
290 #endif | 290 #endif |
291 | 291 |
292 const bool use_vulkan = SharedVulkanContextProvider(); | 292 const bool use_vulkan = SharedVulkanContextProvider(); |
293 | 293 |
294 const bool create_gpu_output_surface = | 294 const bool create_gpu_output_surface = |
295 ShouldCreateGpuOutputSurface(compositor.get()); | 295 ShouldCreateGpuOutputSurface(compositor.get()); |
296 if (create_gpu_output_surface && !use_vulkan) { | 296 if (create_gpu_output_surface && !use_vulkan) { |
297 CauseForGpuLaunch cause = | |
298 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; | |
299 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( | 297 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( |
300 cause, base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, | 298 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, |
301 callback_factory_.GetWeakPtr(), compositor, | 299 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, |
302 create_gpu_output_surface, 0)); | 300 callback_factory_.GetWeakPtr(), compositor, |
301 create_gpu_output_surface, 0)); | |
303 } else { | 302 } else { |
304 EstablishedGpuChannel(compositor, create_gpu_output_surface, 0); | 303 EstablishedGpuChannel(compositor, create_gpu_output_surface, 0); |
305 } | 304 } |
306 } | 305 } |
307 | 306 |
308 void GpuProcessTransportFactory::EstablishedGpuChannel( | 307 void GpuProcessTransportFactory::EstablishedGpuChannel( |
309 base::WeakPtr<ui::Compositor> compositor, | 308 base::WeakPtr<ui::Compositor> compositor, |
310 bool create_gpu_output_surface, | 309 bool create_gpu_output_surface, |
311 int num_attempts) { | 310 int num_attempts) { |
312 if (!compositor) | 311 if (!compositor) |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
402 } | 401 } |
403 | 402 |
404 bool created_gpu_browser_compositor = | 403 bool created_gpu_browser_compositor = |
405 !!context_provider && !!shared_worker_context_provider_; | 404 !!context_provider && !!shared_worker_context_provider_; |
406 | 405 |
407 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", | 406 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", |
408 created_gpu_browser_compositor); | 407 created_gpu_browser_compositor); |
409 | 408 |
410 if (!created_gpu_browser_compositor) { | 409 if (!created_gpu_browser_compositor) { |
411 // Try again. | 410 // Try again. |
412 CauseForGpuLaunch cause = | |
413 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; | |
414 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( | 411 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( |
415 cause, base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, | 412 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, |
danakj
2016/05/04 00:50:50
This could really go either way.. it could be DISP
| |
416 callback_factory_.GetWeakPtr(), compositor, | 413 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, |
417 create_gpu_output_surface, num_attempts + 1)); | 414 callback_factory_.GetWeakPtr(), compositor, |
415 create_gpu_output_surface, num_attempts + 1)); | |
418 return; | 416 return; |
419 } | 417 } |
420 } | 418 } |
421 | 419 |
422 std::unique_ptr<BrowserCompositorOutputSurface> surface; | 420 std::unique_ptr<BrowserCompositorOutputSurface> surface; |
423 #if defined(ENABLE_VULKAN) | 421 #if defined(ENABLE_VULKAN) |
424 std::unique_ptr<VulkanBrowserCompositorOutputSurface> vulkan_surface; | 422 std::unique_ptr<VulkanBrowserCompositorOutputSurface> vulkan_surface; |
425 if (vulkan_context_provider) { | 423 if (vulkan_context_provider) { |
426 vulkan_surface.reset(new VulkanBrowserCompositorOutputSurface( | 424 vulkan_surface.reset(new VulkanBrowserCompositorOutputSurface( |
427 vulkan_context_provider, compositor->vsync_manager(), | 425 vulkan_context_provider, compositor->vsync_manager(), |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
689 } | 687 } |
690 #endif | 688 #endif |
691 | 689 |
692 scoped_refptr<cc::ContextProvider> | 690 scoped_refptr<cc::ContextProvider> |
693 GpuProcessTransportFactory::SharedMainThreadContextProvider() { | 691 GpuProcessTransportFactory::SharedMainThreadContextProvider() { |
694 if (shared_main_thread_contexts_) | 692 if (shared_main_thread_contexts_) |
695 return shared_main_thread_contexts_; | 693 return shared_main_thread_contexts_; |
696 | 694 |
697 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) | 695 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) |
698 return nullptr; | 696 return nullptr; |
699 CauseForGpuLaunch cause = | |
700 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; | |
701 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host( | 697 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host( |
702 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(cause)); | 698 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync( |
699 CAUSE_FOR_GPU_LAUNCH_BROWSER_SHARED_MAIN_THREAD_CONTEXT)); | |
703 if (!gpu_channel_host) | 700 if (!gpu_channel_host) |
704 return nullptr; | 701 return nullptr; |
705 | 702 |
706 // We need a separate context from the compositor's so that skia and gl_helper | 703 // We need a separate context from the compositor's so that skia and gl_helper |
707 // don't step on each other. | 704 // don't step on each other. |
708 shared_main_thread_contexts_ = CreateContextCommon( | 705 shared_main_thread_contexts_ = CreateContextCommon( |
709 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, nullptr, | 706 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, nullptr, |
710 command_buffer_metrics::BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); | 707 command_buffer_metrics::BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); |
711 shared_main_thread_contexts_->SetLostContextCallback(base::Bind( | 708 shared_main_thread_contexts_->SetLostContextCallback(base::Bind( |
712 &GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback, | 709 &GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
784 shared_vulkan_context_provider_ = | 781 shared_vulkan_context_provider_ = |
785 cc::VulkanInProcessContextProvider::Create(); | 782 cc::VulkanInProcessContextProvider::Create(); |
786 } | 783 } |
787 | 784 |
788 shared_vulkan_context_provider_initialized_ = true; | 785 shared_vulkan_context_provider_initialized_ = true; |
789 } | 786 } |
790 return shared_vulkan_context_provider_; | 787 return shared_vulkan_context_provider_; |
791 } | 788 } |
792 | 789 |
793 } // namespace content | 790 } // namespace content |
OLD | NEW |