OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer_host/compositor_impl_android.h" | 5 #include "content/browser/renderer_host/compositor_impl_android.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 #include <android/native_window_jni.h> | 8 #include <android/native_window_jni.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <unordered_set> | 10 #include <unordered_set> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 #include "content/browser/renderer_host/render_widget_host_impl.h" | 54 #include "content/browser/renderer_host/render_widget_host_impl.h" |
55 #include "content/common/host_shared_bitmap_manager.h" | 55 #include "content/common/host_shared_bitmap_manager.h" |
56 #include "content/public/browser/android/compositor.h" | 56 #include "content/public/browser/android/compositor.h" |
57 #include "content/public/browser/android/compositor_client.h" | 57 #include "content/public/browser/android/compositor_client.h" |
58 #include "content/public/common/content_switches.h" | 58 #include "content/public/common/content_switches.h" |
59 #include "gpu/command_buffer/client/context_support.h" | 59 #include "gpu/command_buffer/client/context_support.h" |
60 #include "gpu/command_buffer/client/gles2_interface.h" | 60 #include "gpu/command_buffer/client/gles2_interface.h" |
61 #include "gpu/ipc/client/command_buffer_proxy_impl.h" | 61 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
62 #include "gpu/ipc/client/gpu_channel_host.h" | 62 #include "gpu/ipc/client/gpu_channel_host.h" |
63 #include "gpu/ipc/common/gpu_surface_tracker.h" | 63 #include "gpu/ipc/common/gpu_surface_tracker.h" |
| 64 #include "gpu/vulkan/features.h" |
64 #include "gpu/vulkan/vulkan_surface.h" | 65 #include "gpu/vulkan/vulkan_surface.h" |
65 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" | 66 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" |
66 #include "third_party/khronos/GLES2/gl2.h" | 67 #include "third_party/khronos/GLES2/gl2.h" |
67 #include "third_party/khronos/GLES2/gl2ext.h" | 68 #include "third_party/khronos/GLES2/gl2ext.h" |
68 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 69 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
69 #include "ui/android/window_android.h" | 70 #include "ui/android/window_android.h" |
70 #include "ui/display/display.h" | 71 #include "ui/display/display.h" |
71 #include "ui/display/screen.h" | 72 #include "ui/display/screen.h" |
72 #include "ui/gfx/swap_result.h" | 73 #include "ui/gfx/swap_result.h" |
73 | 74 |
(...skipping 18 matching lines...) Expand all Loading... |
92 ~SingleThreadTaskGraphRunner() override { Shutdown(); } | 93 ~SingleThreadTaskGraphRunner() override { Shutdown(); } |
93 }; | 94 }; |
94 | 95 |
95 struct CompositorDependencies { | 96 struct CompositorDependencies { |
96 CompositorDependencies() : frame_sink_id_allocator(kDefaultClientId) {} | 97 CompositorDependencies() : frame_sink_id_allocator(kDefaultClientId) {} |
97 | 98 |
98 SingleThreadTaskGraphRunner task_graph_runner; | 99 SingleThreadTaskGraphRunner task_graph_runner; |
99 cc::SurfaceManager surface_manager; | 100 cc::SurfaceManager surface_manager; |
100 cc::FrameSinkIdAllocator frame_sink_id_allocator; | 101 cc::FrameSinkIdAllocator frame_sink_id_allocator; |
101 | 102 |
102 #if defined(ENABLE_VULKAN) | 103 #if BUILDFLAG(ENABLE_VULKAN) |
103 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider; | 104 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider; |
104 #endif | 105 #endif |
105 }; | 106 }; |
106 | 107 |
107 base::LazyInstance<CompositorDependencies>::DestructorAtExit | 108 base::LazyInstance<CompositorDependencies>::DestructorAtExit |
108 g_compositor_dependencies = LAZY_INSTANCE_INITIALIZER; | 109 g_compositor_dependencies = LAZY_INSTANCE_INITIALIZER; |
109 | 110 |
110 const unsigned int kMaxDisplaySwapBuffers = 1U; | 111 const unsigned int kMaxDisplaySwapBuffers = 1U; |
111 | 112 |
112 #if defined(ENABLE_VULKAN) | 113 #if BUILDFLAG(ENABLE_VULKAN) |
113 scoped_refptr<cc::VulkanContextProvider> GetSharedVulkanContextProvider() { | 114 scoped_refptr<cc::VulkanContextProvider> GetSharedVulkanContextProvider() { |
114 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 115 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
115 switches::kEnableVulkan)) { | 116 switches::kEnableVulkan)) { |
116 scoped_refptr<cc::VulkanContextProvider> context_provider = | 117 scoped_refptr<cc::VulkanContextProvider> context_provider = |
117 g_compositor_dependencies.Get().vulkan_context_provider; | 118 g_compositor_dependencies.Get().vulkan_context_provider; |
118 if (!*context_provider) | 119 if (!*context_provider) |
119 *context_provider = cc::VulkanInProcessContextProvider::Create(); | 120 *context_provider = cc::VulkanInProcessContextProvider::Create(); |
120 return *context_provider; | 121 return *context_provider; |
121 } | 122 } |
122 return nullptr; | 123 return nullptr; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 swap_buffers_callback_.Run(); | 298 swap_buffers_callback_.Run(); |
298 } | 299 } |
299 | 300 |
300 private: | 301 private: |
301 cc::OutputSurfaceClient* client_ = nullptr; | 302 cc::OutputSurfaceClient* client_ = nullptr; |
302 base::Closure swap_buffers_callback_; | 303 base::Closure swap_buffers_callback_; |
303 std::unique_ptr<cc::OverlayCandidateValidator> overlay_candidate_validator_; | 304 std::unique_ptr<cc::OverlayCandidateValidator> overlay_candidate_validator_; |
304 base::WeakPtrFactory<AndroidOutputSurface> weak_ptr_factory_; | 305 base::WeakPtrFactory<AndroidOutputSurface> weak_ptr_factory_; |
305 }; | 306 }; |
306 | 307 |
307 #if defined(ENABLE_VULKAN) | 308 #if BUILDFLAG(ENABLE_VULKAN) |
308 class VulkanOutputSurface : public cc::OutputSurface { | 309 class VulkanOutputSurface : public cc::OutputSurface { |
309 public: | 310 public: |
310 explicit VulkanOutputSurface( | 311 explicit VulkanOutputSurface( |
311 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, | 312 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, |
312 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 313 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
313 : OutputSurface(std::move(vulkan_context_provider)), | 314 : OutputSurface(std::move(vulkan_context_provider)), |
314 task_runner_(std::move(task_runner)), | 315 task_runner_(std::move(task_runner)), |
315 weak_ptr_factory_(this) {} | 316 weak_ptr_factory_(this) {} |
316 | 317 |
317 ~VulkanOutputSurface() override { Destroy(); } | 318 ~VulkanOutputSurface() override { Destroy(); } |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 NOTREACHED(); | 621 NOTREACHED(); |
621 } | 622 } |
622 | 623 |
623 void CompositorImpl::HandlePendingCompositorFrameSinkRequest() { | 624 void CompositorImpl::HandlePendingCompositorFrameSinkRequest() { |
624 DCHECK(compositor_frame_sink_request_pending_); | 625 DCHECK(compositor_frame_sink_request_pending_); |
625 | 626 |
626 // We might have been made invisible now. | 627 // We might have been made invisible now. |
627 if (!host_->IsVisible()) | 628 if (!host_->IsVisible()) |
628 return; | 629 return; |
629 | 630 |
630 #if defined(ENABLE_VULKAN) | 631 #if BUILDFLAG(ENABLE_VULKAN) |
631 CreateVulkanOutputSurface() | 632 CreateVulkanOutputSurface() |
632 if (display_) | 633 if (display_) |
633 return; | 634 return; |
634 #endif | 635 #endif |
635 | 636 |
636 #if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) || \ | 637 #if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) || \ |
637 defined(SYZYASAN) || defined(CYGPROFILE_INSTRUMENTATION) | 638 defined(SYZYASAN) || defined(CYGPROFILE_INSTRUMENTATION) |
638 const int64_t kGpuChannelTimeoutInSeconds = 40; | 639 const int64_t kGpuChannelTimeoutInSeconds = 40; |
639 #else | 640 #else |
640 // The GPU watchdog timeout is 15 seconds (1.5x the kGpuTimeout value due to | 641 // The GPU watchdog timeout is 15 seconds (1.5x the kGpuTimeout value due to |
(...skipping 10 matching lines...) Expand all Loading... |
651 | 652 |
652 DCHECK(surface_handle_ != gpu::kNullSurfaceHandle); | 653 DCHECK(surface_handle_ != gpu::kNullSurfaceHandle); |
653 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(base::Bind( | 654 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(base::Bind( |
654 &CompositorImpl::OnGpuChannelEstablished, weak_factory_.GetWeakPtr())); | 655 &CompositorImpl::OnGpuChannelEstablished, weak_factory_.GetWeakPtr())); |
655 } | 656 } |
656 | 657 |
657 void CompositorImpl::OnGpuChannelTimeout() { | 658 void CompositorImpl::OnGpuChannelTimeout() { |
658 LOG(FATAL) << "Timed out waiting for GPU channel."; | 659 LOG(FATAL) << "Timed out waiting for GPU channel."; |
659 } | 660 } |
660 | 661 |
661 #if defined(ENABLE_VULKAN) | 662 #if BUILDFLAG(ENABLE_VULKAN) |
662 void CompositorImpl::CreateVulkanOutputSurface() { | 663 void CompositorImpl::CreateVulkanOutputSurface() { |
663 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 664 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
664 switches::kEnableVulkan)) | 665 switches::kEnableVulkan)) |
665 return; | 666 return; |
666 | 667 |
667 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = | 668 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = |
668 GetSharedVulkanContextProvider(); | 669 GetSharedVulkanContextProvider(); |
669 if (!vulkan_context_provider) | 670 if (!vulkan_context_provider) |
670 return; | 671 return; |
671 | 672 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 } | 855 } |
855 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, | 856 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, |
856 frame_sink_id); | 857 frame_sink_id); |
857 } | 858 } |
858 | 859 |
859 bool CompositorImpl::HavePendingReadbacks() { | 860 bool CompositorImpl::HavePendingReadbacks() { |
860 return !readback_layer_tree_->children().empty(); | 861 return !readback_layer_tree_->children().empty(); |
861 } | 862 } |
862 | 863 |
863 } // namespace content | 864 } // namespace content |
OLD | NEW |