| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/context_provider_factory_impl_android.h" | 5 #include "content/browser/renderer_host/context_provider_factory_impl_android.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 13 #include "cc/output/context_provider.h" | 13 #include "cc/output/context_provider.h" |
| 14 #include "cc/output/vulkan_in_process_context_provider.h" | 14 #include "cc/output/vulkan_in_process_context_provider.h" |
| 15 #include "cc/surfaces/surface_manager.h" | 15 #include "cc/surfaces/surface_manager.h" |
| 16 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 16 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
| 17 #include "content/browser/gpu/compositor_util.h" | 17 #include "content/browser/gpu/compositor_util.h" |
| 18 #include "content/common/host_shared_bitmap_manager.h" | 18 #include "content/common/host_shared_bitmap_manager.h" |
| 19 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
| 20 #include "gpu/command_buffer/client/gles2_interface.h" | 20 #include "gpu/command_buffer/client/gles2_interface.h" |
| 21 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 21 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
| 22 #include "gpu/ipc/client/gpu_channel_host.h" | 22 #include "gpu/ipc/client/gpu_channel_host.h" |
| 23 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" | 23 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 // The client_id used here should not conflict with the client_id generated |
| 30 // from RenderWidgetHostImpl. |
| 31 constexpr uint32_t kDefaultClientId = 0u; |
| 32 |
| 29 ui::command_buffer_metrics::ContextType ToCommandBufferContextType( | 33 ui::command_buffer_metrics::ContextType ToCommandBufferContextType( |
| 30 ui::ContextProviderFactory::ContextType context_type) { | 34 ui::ContextProviderFactory::ContextType context_type) { |
| 31 switch (context_type) { | 35 switch (context_type) { |
| 32 case ui::ContextProviderFactory::ContextType:: | 36 case ui::ContextProviderFactory::ContextType:: |
| 33 BLIMP_RENDER_COMPOSITOR_CONTEXT: | 37 BLIMP_RENDER_COMPOSITOR_CONTEXT: |
| 34 return ui::command_buffer_metrics::BLIMP_RENDER_COMPOSITOR_CONTEXT; | 38 return ui::command_buffer_metrics::BLIMP_RENDER_COMPOSITOR_CONTEXT; |
| 35 case ui::ContextProviderFactory::ContextType::BLIMP_RENDER_WORKER_CONTEXT: | 39 case ui::ContextProviderFactory::ContextType::BLIMP_RENDER_WORKER_CONTEXT: |
| 36 return ui::command_buffer_metrics::BLIMP_RENDER_WORKER_CONTEXT; | 40 return ui::command_buffer_metrics::BLIMP_RENDER_WORKER_CONTEXT; |
| 37 } | 41 } |
| 38 NOTREACHED(); | 42 NOTREACHED(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 59 // static | 63 // static |
| 60 ContextProviderFactoryImpl* ContextProviderFactoryImpl::GetInstance() { | 64 ContextProviderFactoryImpl* ContextProviderFactoryImpl::GetInstance() { |
| 61 return instance; | 65 return instance; |
| 62 } | 66 } |
| 63 | 67 |
| 64 ContextProviderFactoryImpl::ContextProviderFactoryImpl( | 68 ContextProviderFactoryImpl::ContextProviderFactoryImpl( |
| 65 gpu::GpuChannelEstablishFactory* gpu_channel_factory) | 69 gpu::GpuChannelEstablishFactory* gpu_channel_factory) |
| 66 : gpu_channel_factory_(gpu_channel_factory), | 70 : gpu_channel_factory_(gpu_channel_factory), |
| 67 in_handle_pending_requests_(false), | 71 in_handle_pending_requests_(false), |
| 68 in_shutdown_(false), | 72 in_shutdown_(false), |
| 69 next_sink_id_(1u), | 73 frame_sink_id_allocator_(kDefaultClientId), |
| 70 weak_factory_(this) { | 74 weak_factory_(this) { |
| 71 DCHECK(gpu_channel_factory_); | 75 DCHECK(gpu_channel_factory_); |
| 72 } | 76 } |
| 73 | 77 |
| 74 ContextProviderFactoryImpl::~ContextProviderFactoryImpl() { | 78 ContextProviderFactoryImpl::~ContextProviderFactoryImpl() { |
| 75 in_shutdown_ = true; | 79 in_shutdown_ = true; |
| 76 if (!gpu_channel_requests_.empty()) | 80 if (!gpu_channel_requests_.empty()) |
| 77 HandlePendingRequests(nullptr, | 81 HandlePendingRequests(nullptr, |
| 78 GpuChannelHostResult::FAILURE_FACTORY_SHUTDOWN); | 82 GpuChannelHostResult::FAILURE_FACTORY_SHUTDOWN); |
| 79 } | 83 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 } | 133 } |
| 130 | 134 |
| 131 cc::SurfaceManager* ContextProviderFactoryImpl::GetSurfaceManager() { | 135 cc::SurfaceManager* ContextProviderFactoryImpl::GetSurfaceManager() { |
| 132 if (!surface_manager_) | 136 if (!surface_manager_) |
| 133 surface_manager_ = base::WrapUnique(new cc::SurfaceManager); | 137 surface_manager_ = base::WrapUnique(new cc::SurfaceManager); |
| 134 | 138 |
| 135 return surface_manager_.get(); | 139 return surface_manager_.get(); |
| 136 } | 140 } |
| 137 | 141 |
| 138 cc::FrameSinkId ContextProviderFactoryImpl::AllocateFrameSinkId() { | 142 cc::FrameSinkId ContextProviderFactoryImpl::AllocateFrameSinkId() { |
| 139 // The FrameSinkId generated here must be unique with | 143 return frame_sink_id_allocator_.NextFrameSinkId(); |
| 140 // RenderWidgetHostViewAndroid's | |
| 141 // FrameSinkId allocation. | |
| 142 // TODO(crbug.com/685777): Centralize allocation in one place for easier | |
| 143 // maintenance. | |
| 144 return cc::FrameSinkId(0 /* client_id */, next_sink_id_++); | |
| 145 } | 144 } |
| 146 | 145 |
| 147 gpu::GpuMemoryBufferManager* | 146 gpu::GpuMemoryBufferManager* |
| 148 ContextProviderFactoryImpl::GetGpuMemoryBufferManager() { | 147 ContextProviderFactoryImpl::GetGpuMemoryBufferManager() { |
| 149 return BrowserGpuMemoryBufferManager::current(); | 148 return BrowserGpuMemoryBufferManager::current(); |
| 150 } | 149 } |
| 151 | 150 |
| 152 scoped_refptr<cc::ContextProvider> | 151 scoped_refptr<cc::ContextProvider> |
| 153 ContextProviderFactoryImpl::CreateContextProviderInternal( | 152 ContextProviderFactoryImpl::CreateContextProviderInternal( |
| 154 ui::command_buffer_metrics::ContextType context_type, | 153 ui::command_buffer_metrics::ContextType context_type, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 nullptr, | 237 nullptr, |
| 239 GpuChannelHostResult::FAILURE_GPU_PROCESS_INITIALIZATION_FAILED); | 238 GpuChannelHostResult::FAILURE_GPU_PROCESS_INITIALIZATION_FAILED); |
| 240 } | 239 } |
| 241 } | 240 } |
| 242 | 241 |
| 243 void ContextProviderFactoryImpl::OnGpuChannelTimeout() { | 242 void ContextProviderFactoryImpl::OnGpuChannelTimeout() { |
| 244 LOG(FATAL) << "Timed out waiting for GPU channel."; | 243 LOG(FATAL) << "Timed out waiting for GPU channel."; |
| 245 } | 244 } |
| 246 | 245 |
| 247 } // namespace content | 246 } // namespace content |
| OLD | NEW |