| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } | 249 } |
| 250 | 250 |
| 251 scoped_refptr<ContextProviderCommandBuffer> context_provider; | 251 scoped_refptr<ContextProviderCommandBuffer> context_provider; |
| 252 if (create_gpu_output_surface) { | 252 if (create_gpu_output_surface) { |
| 253 scoped_refptr<GpuChannelHost> gpu_channel_host = | 253 scoped_refptr<GpuChannelHost> gpu_channel_host = |
| 254 BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); | 254 BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); |
| 255 if (gpu_channel_host.get()) { | 255 if (gpu_channel_host.get()) { |
| 256 context_provider = ContextProviderCommandBuffer::Create( | 256 context_provider = ContextProviderCommandBuffer::Create( |
| 257 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host, | 257 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host, |
| 258 data->surface_id), | 258 data->surface_id), |
| 259 "Compositor"); | 259 BROWSER_COMPOSITOR_ONSCREEN_CONTEXT); |
| 260 if (context_provider && !context_provider->BindToCurrentThread()) | 260 if (context_provider && !context_provider->BindToCurrentThread()) |
| 261 context_provider = nullptr; | 261 context_provider = nullptr; |
| 262 } | 262 } |
| 263 | 263 |
| 264 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", | 264 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", |
| 265 !!context_provider.get()); | 265 !!context_provider.get()); |
| 266 | 266 |
| 267 if (!context_provider) { | 267 if (!context_provider) { |
| 268 // Try again. | 268 // Try again. |
| 269 CauseForGpuLaunch cause = | 269 CauseForGpuLaunch cause = |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 GpuProcessTransportFactory::SharedMainThreadContextProvider() { | 496 GpuProcessTransportFactory::SharedMainThreadContextProvider() { |
| 497 if (shared_main_thread_contexts_.get()) | 497 if (shared_main_thread_contexts_.get()) |
| 498 return shared_main_thread_contexts_; | 498 return shared_main_thread_contexts_; |
| 499 | 499 |
| 500 // In threaded compositing mode, we have to create our own context for the | 500 // In threaded compositing mode, we have to create our own context for the |
| 501 // main thread since the compositor's context will be bound to the | 501 // main thread since the compositor's context will be bound to the |
| 502 // compositor thread. When not in threaded mode, we still need a separate | 502 // compositor thread. When not in threaded mode, we still need a separate |
| 503 // context so that skia and gl_helper don't step on each other. | 503 // context so that skia and gl_helper don't step on each other. |
| 504 shared_main_thread_contexts_ = ContextProviderCommandBuffer::Create( | 504 shared_main_thread_contexts_ = ContextProviderCommandBuffer::Create( |
| 505 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext(), | 505 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext(), |
| 506 "Offscreen-MainThread"); | 506 BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); |
| 507 | 507 |
| 508 if (shared_main_thread_contexts_.get()) { | 508 if (shared_main_thread_contexts_.get()) { |
| 509 shared_main_thread_contexts_->SetLostContextCallback( | 509 shared_main_thread_contexts_->SetLostContextCallback( |
| 510 base::Bind(&GpuProcessTransportFactory:: | 510 base::Bind(&GpuProcessTransportFactory:: |
| 511 OnLostMainThreadSharedContextInsideCallback, | 511 OnLostMainThreadSharedContextInsideCallback, |
| 512 callback_factory_.GetWeakPtr())); | 512 callback_factory_.GetWeakPtr())); |
| 513 if (!shared_main_thread_contexts_->BindToCurrentThread()) | 513 if (!shared_main_thread_contexts_->BindToCurrentThread()) |
| 514 shared_main_thread_contexts_ = NULL; | 514 shared_main_thread_contexts_ = NULL; |
| 515 } | 515 } |
| 516 return shared_main_thread_contexts_; | 516 return shared_main_thread_contexts_; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 588 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
| 589 observer_list_, | 589 observer_list_, |
| 590 OnLostResources()); | 590 OnLostResources()); |
| 591 | 591 |
| 592 // Kill things that use the shared context before killing the shared context. | 592 // Kill things that use the shared context before killing the shared context. |
| 593 lost_gl_helper.reset(); | 593 lost_gl_helper.reset(); |
| 594 lost_shared_main_thread_contexts = NULL; | 594 lost_shared_main_thread_contexts = NULL; |
| 595 } | 595 } |
| 596 | 596 |
| 597 } // namespace content | 597 } // namespace content |
| OLD | NEW |