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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 GpuProcessTransportFactory::SharedMainThreadContextProvider() { | 497 GpuProcessTransportFactory::SharedMainThreadContextProvider() { |
498 if (shared_main_thread_contexts_.get()) | 498 if (shared_main_thread_contexts_.get()) |
499 return shared_main_thread_contexts_; | 499 return shared_main_thread_contexts_; |
500 | 500 |
501 // In threaded compositing mode, we have to create our own context for the | 501 // In threaded compositing mode, we have to create our own context for the |
502 // main thread since the compositor's context will be bound to the | 502 // main thread since the compositor's context will be bound to the |
503 // compositor thread. When not in threaded mode, we still need a separate | 503 // compositor thread. When not in threaded mode, we still need a separate |
504 // context so that skia and gl_helper don't step on each other. | 504 // context so that skia and gl_helper don't step on each other. |
505 shared_main_thread_contexts_ = ContextProviderCommandBuffer::Create( | 505 shared_main_thread_contexts_ = ContextProviderCommandBuffer::Create( |
506 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext(), | 506 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext(), |
507 "Offscreen-MainThread"); | 507 BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); |
508 | 508 |
509 if (shared_main_thread_contexts_.get()) { | 509 if (shared_main_thread_contexts_.get()) { |
510 shared_main_thread_contexts_->SetLostContextCallback( | 510 shared_main_thread_contexts_->SetLostContextCallback( |
511 base::Bind(&GpuProcessTransportFactory:: | 511 base::Bind(&GpuProcessTransportFactory:: |
512 OnLostMainThreadSharedContextInsideCallback, | 512 OnLostMainThreadSharedContextInsideCallback, |
513 callback_factory_.GetWeakPtr())); | 513 callback_factory_.GetWeakPtr())); |
514 if (!shared_main_thread_contexts_->BindToCurrentThread()) | 514 if (!shared_main_thread_contexts_->BindToCurrentThread()) |
515 shared_main_thread_contexts_ = NULL; | 515 shared_main_thread_contexts_ = NULL; |
516 } | 516 } |
517 return shared_main_thread_contexts_; | 517 return shared_main_thread_contexts_; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 589 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
590 observer_list_, | 590 observer_list_, |
591 OnLostResources()); | 591 OnLostResources()); |
592 | 592 |
593 // Kill things that use the shared context before killing the shared context. | 593 // Kill things that use the shared context before killing the shared context. |
594 lost_gl_helper.reset(); | 594 lost_gl_helper.reset(); |
595 lost_shared_main_thread_contexts = NULL; | 595 lost_shared_main_thread_contexts = NULL; |
596 } | 596 } |
597 | 597 |
598 } // namespace content | 598 } // namespace content |
OLD | NEW |