| 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; | |
| 248 if (shared_worker_context_provider_) { | 247 if (shared_worker_context_provider_) { |
| 249 // Note: If context is lost, we delete reference after releasing the lock. | |
| 250 base::AutoLock lock(*shared_worker_context_provider_->GetLock()); | 248 base::AutoLock lock(*shared_worker_context_provider_->GetLock()); |
| 251 if (shared_worker_context_provider_->ContextGL() | 249 if (shared_worker_context_provider_->ContextGL() |
| 252 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { | 250 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR) |
| 253 shared_worker_context_provider_lost = true; | 251 shared_worker_context_provider_ = nullptr; |
| 254 } | |
| 255 } | 252 } |
| 256 scoped_refptr<GpuChannelHost> gpu_channel_host = | 253 scoped_refptr<GpuChannelHost> gpu_channel_host = |
| 257 BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); | 254 BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); |
| 258 if (gpu_channel_host.get()) { | 255 if (gpu_channel_host.get()) { |
| 259 context_provider = ContextProviderCommandBuffer::Create( | 256 context_provider = ContextProviderCommandBuffer::Create( |
| 260 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host, | 257 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host, |
| 261 data->surface_id), | 258 data->surface_id), |
| 262 BROWSER_COMPOSITOR_ONSCREEN_CONTEXT); | 259 BROWSER_COMPOSITOR_ONSCREEN_CONTEXT); |
| 263 if (context_provider && !context_provider->BindToCurrentThread()) | 260 if (context_provider && !context_provider->BindToCurrentThread()) |
| 264 context_provider = nullptr; | 261 context_provider = nullptr; |
| 265 if (!shared_worker_context_provider_ || | 262 if (!shared_worker_context_provider_) { |
| 266 shared_worker_context_provider_lost) { | |
| 267 shared_worker_context_provider_ = ContextProviderCommandBuffer::Create( | 263 shared_worker_context_provider_ = ContextProviderCommandBuffer::Create( |
| 268 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host, | 264 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host, |
| 269 0), | 265 0), |
| 270 BROWSER_WORKER_CONTEXT); | 266 BROWSER_WORKER_CONTEXT); |
| 271 if (shared_worker_context_provider_ && | 267 if (shared_worker_context_provider_ && |
| 272 !shared_worker_context_provider_->BindToCurrentThread()) | 268 !shared_worker_context_provider_->BindToCurrentThread()) |
| 273 shared_worker_context_provider_ = nullptr; | 269 shared_worker_context_provider_ = nullptr; |
| 274 if (shared_worker_context_provider_) | |
| 275 shared_worker_context_provider_->SetupLock(); | |
| 276 } | 270 } |
| 277 } | 271 } |
| 278 | 272 |
| 279 bool created_gpu_browser_compositor = | 273 bool created_gpu_browser_compositor = |
| 280 !!context_provider && !!shared_worker_context_provider_; | 274 !!context_provider && !!shared_worker_context_provider_; |
| 281 | 275 |
| 282 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", | 276 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", |
| 283 created_gpu_browser_compositor); | 277 created_gpu_browser_compositor); |
| 284 | 278 |
| 285 if (!created_gpu_browser_compositor) { | 279 if (!created_gpu_browser_compositor) { |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 626 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
| 633 observer_list_, | 627 observer_list_, |
| 634 OnLostResources()); | 628 OnLostResources()); |
| 635 | 629 |
| 636 // Kill things that use the shared context before killing the shared context. | 630 // Kill things that use the shared context before killing the shared context. |
| 637 lost_gl_helper.reset(); | 631 lost_gl_helper.reset(); |
| 638 lost_shared_main_thread_contexts = NULL; | 632 lost_shared_main_thread_contexts = NULL; |
| 639 } | 633 } |
| 640 | 634 |
| 641 } // namespace content | 635 } // namespace content |
| OLD | NEW |