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" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // static | 59 // static |
60 ContextProviderFactoryImpl* ContextProviderFactoryImpl::GetInstance() { | 60 ContextProviderFactoryImpl* ContextProviderFactoryImpl::GetInstance() { |
61 return instance; | 61 return instance; |
62 } | 62 } |
63 | 63 |
64 ContextProviderFactoryImpl::ContextProviderFactoryImpl( | 64 ContextProviderFactoryImpl::ContextProviderFactoryImpl( |
65 gpu::GpuChannelEstablishFactory* gpu_channel_factory) | 65 gpu::GpuChannelEstablishFactory* gpu_channel_factory) |
66 : gpu_channel_factory_(gpu_channel_factory), | 66 : gpu_channel_factory_(gpu_channel_factory), |
67 in_handle_pending_requests_(false), | 67 in_handle_pending_requests_(false), |
68 in_shutdown_(false), | 68 in_shutdown_(false), |
69 next_sink_id_(1u), | |
70 weak_factory_(this) { | 69 weak_factory_(this) { |
71 DCHECK(gpu_channel_factory_); | 70 DCHECK(gpu_channel_factory_); |
72 } | 71 } |
73 | 72 |
74 ContextProviderFactoryImpl::~ContextProviderFactoryImpl() { | 73 ContextProviderFactoryImpl::~ContextProviderFactoryImpl() { |
75 in_shutdown_ = true; | 74 in_shutdown_ = true; |
76 if (!gpu_channel_requests_.empty()) | 75 if (!gpu_channel_requests_.empty()) |
77 HandlePendingRequests(nullptr, | 76 HandlePendingRequests(nullptr, |
78 GpuChannelHostResult::FAILURE_FACTORY_SHUTDOWN); | 77 GpuChannelHostResult::FAILURE_FACTORY_SHUTDOWN); |
79 } | 78 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 128 } |
130 | 129 |
131 cc::SurfaceManager* ContextProviderFactoryImpl::GetSurfaceManager() { | 130 cc::SurfaceManager* ContextProviderFactoryImpl::GetSurfaceManager() { |
132 if (!surface_manager_) | 131 if (!surface_manager_) |
133 surface_manager_ = base::WrapUnique(new cc::SurfaceManager); | 132 surface_manager_ = base::WrapUnique(new cc::SurfaceManager); |
134 | 133 |
135 return surface_manager_.get(); | 134 return surface_manager_.get(); |
136 } | 135 } |
137 | 136 |
138 cc::FrameSinkId ContextProviderFactoryImpl::AllocateFrameSinkId() { | 137 cc::FrameSinkId ContextProviderFactoryImpl::AllocateFrameSinkId() { |
139 // The FrameSinkId generated here must be unique with | 138 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 } | 139 } |
146 | 140 |
147 gpu::GpuMemoryBufferManager* | 141 gpu::GpuMemoryBufferManager* |
148 ContextProviderFactoryImpl::GetGpuMemoryBufferManager() { | 142 ContextProviderFactoryImpl::GetGpuMemoryBufferManager() { |
149 return BrowserGpuMemoryBufferManager::current(); | 143 return BrowserGpuMemoryBufferManager::current(); |
150 } | 144 } |
151 | 145 |
152 scoped_refptr<cc::ContextProvider> | 146 scoped_refptr<cc::ContextProvider> |
153 ContextProviderFactoryImpl::CreateContextProviderInternal( | 147 ContextProviderFactoryImpl::CreateContextProviderInternal( |
154 ui::command_buffer_metrics::ContextType context_type, | 148 ui::command_buffer_metrics::ContextType context_type, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 nullptr, | 232 nullptr, |
239 GpuChannelHostResult::FAILURE_GPU_PROCESS_INITIALIZATION_FAILED); | 233 GpuChannelHostResult::FAILURE_GPU_PROCESS_INITIALIZATION_FAILED); |
240 } | 234 } |
241 } | 235 } |
242 | 236 |
243 void ContextProviderFactoryImpl::OnGpuChannelTimeout() { | 237 void ContextProviderFactoryImpl::OnGpuChannelTimeout() { |
244 LOG(FATAL) << "Timed out waiting for GPU channel."; | 238 LOG(FATAL) << "Timed out waiting for GPU channel."; |
245 } | 239 } |
246 | 240 |
247 } // namespace content | 241 } // namespace content |
OLD | NEW |