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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 #if defined(OS_CHROMEOS) | 237 #if defined(OS_CHROMEOS) |
238 LOG(FATAL) << "Unable to create a UI graphics context, and cannot use " | 238 LOG(FATAL) << "Unable to create a UI graphics context, and cannot use " |
239 << "software compositing on ChromeOS."; | 239 << "software compositing on ChromeOS."; |
240 #endif | 240 #endif |
241 create_gpu_output_surface = false; | 241 create_gpu_output_surface = false; |
242 } | 242 } |
243 | 243 |
244 scoped_refptr<ContextProviderCommandBuffer> context_provider; | 244 scoped_refptr<ContextProviderCommandBuffer> context_provider; |
245 if (create_gpu_output_surface) { | 245 if (create_gpu_output_surface) { |
246 // Try to reuse existing worker context provider. | 246 // Try to reuse existing worker context provider. |
| 247 bool shared_worker_context_provider_lost = false; |
247 if (shared_worker_context_provider_) { | 248 if (shared_worker_context_provider_) { |
248 base::AutoLock lock(*shared_worker_context_provider_->GetLock()); | 249 base::AutoLock lock(*shared_worker_context_provider_->GetLock()); |
249 if (shared_worker_context_provider_->ContextGL() | 250 if (shared_worker_context_provider_->ContextGL() |
250 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR) | 251 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { |
251 shared_worker_context_provider_ = nullptr; | 252 shared_worker_context_provider_lost = true; |
| 253 } |
252 } | 254 } |
253 scoped_refptr<GpuChannelHost> gpu_channel_host = | 255 scoped_refptr<GpuChannelHost> gpu_channel_host = |
254 BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); | 256 BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); |
255 if (gpu_channel_host.get()) { | 257 if (gpu_channel_host.get()) { |
256 context_provider = ContextProviderCommandBuffer::Create( | 258 context_provider = ContextProviderCommandBuffer::Create( |
257 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host, | 259 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host, |
258 data->surface_id), | 260 data->surface_id), |
259 BROWSER_COMPOSITOR_ONSCREEN_CONTEXT); | 261 BROWSER_COMPOSITOR_ONSCREEN_CONTEXT); |
260 if (context_provider && !context_provider->BindToCurrentThread()) | 262 if (context_provider && !context_provider->BindToCurrentThread()) |
261 context_provider = nullptr; | 263 context_provider = nullptr; |
262 if (!shared_worker_context_provider_) { | 264 if (!shared_worker_context_provider_ || |
| 265 shared_worker_context_provider_lost) { |
263 shared_worker_context_provider_ = ContextProviderCommandBuffer::Create( | 266 shared_worker_context_provider_ = ContextProviderCommandBuffer::Create( |
264 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host, | 267 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host, |
265 0), | 268 0), |
266 BROWSER_WORKER_CONTEXT); | 269 BROWSER_WORKER_CONTEXT); |
267 if (shared_worker_context_provider_ && | 270 if (shared_worker_context_provider_ && |
268 !shared_worker_context_provider_->BindToCurrentThread()) | 271 !shared_worker_context_provider_->BindToCurrentThread()) |
269 shared_worker_context_provider_ = nullptr; | 272 shared_worker_context_provider_ = nullptr; |
| 273 if (shared_worker_context_provider_) |
| 274 shared_worker_context_provider_->SetupLock(); |
270 } | 275 } |
271 } | 276 } |
272 | 277 |
273 bool created_gpu_browser_compositor = | 278 bool created_gpu_browser_compositor = |
274 !!context_provider && !!shared_worker_context_provider_; | 279 !!context_provider && !!shared_worker_context_provider_; |
275 | 280 |
276 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", | 281 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", |
277 created_gpu_browser_compositor); | 282 created_gpu_browser_compositor); |
278 | 283 |
279 if (!created_gpu_browser_compositor) { | 284 if (!created_gpu_browser_compositor) { |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 631 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
627 observer_list_, | 632 observer_list_, |
628 OnLostResources()); | 633 OnLostResources()); |
629 | 634 |
630 // Kill things that use the shared context before killing the shared context. | 635 // Kill things that use the shared context before killing the shared context. |
631 lost_gl_helper.reset(); | 636 lost_gl_helper.reset(); |
632 lost_shared_main_thread_contexts = NULL; | 637 lost_shared_main_thread_contexts = NULL; |
633 } | 638 } |
634 | 639 |
635 } // namespace content | 640 } // namespace content |
OLD | NEW |