Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1312)

Side by Side Diff: content/browser/compositor/gpu_process_transport_factory.cc

Issue 1317743002: cc: Implement shared worker contexts. (v1) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tear down Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 #endif 238 #endif
239 create_gpu_output_surface = false; 239 create_gpu_output_surface = false;
240 } 240 }
241 241
242 scoped_refptr<ContextProviderCommandBuffer> context_provider; 242 scoped_refptr<ContextProviderCommandBuffer> context_provider;
243 if (create_gpu_output_surface) { 243 if (create_gpu_output_surface) {
244 // Try to reuse existing worker context provider. 244 // Try to reuse existing worker context provider.
245 if (shared_worker_context_provider_) { 245 if (shared_worker_context_provider_) {
246 base::AutoLock lock(*shared_worker_context_provider_->GetLock()); 246 base::AutoLock lock(*shared_worker_context_provider_->GetLock());
247 if (shared_worker_context_provider_->ContextGL() 247 if (shared_worker_context_provider_->ContextGL()
248 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR) 248 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR) {
249 shared_worker_context_provider_->Destroy();
249 shared_worker_context_provider_ = nullptr; 250 shared_worker_context_provider_ = nullptr;
251 }
250 } 252 }
251 scoped_refptr<GpuChannelHost> gpu_channel_host = 253 scoped_refptr<GpuChannelHost> gpu_channel_host =
252 BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); 254 BrowserGpuChannelHostFactory::instance()->GetGpuChannel();
253 if (gpu_channel_host.get()) { 255 if (gpu_channel_host.get()) {
254 context_provider = ContextProviderCommandBuffer::Create( 256 context_provider = ContextProviderCommandBuffer::Create(
255 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host, 257 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host,
256 data->surface_id), 258 data->surface_id),
257 BROWSER_COMPOSITOR_ONSCREEN_CONTEXT); 259 BROWSER_COMPOSITOR_ONSCREEN_CONTEXT);
258 if (context_provider && !context_provider->BindToCurrentThread()) 260 if (context_provider && !context_provider->BindToCurrentThread())
259 context_provider = nullptr; 261 context_provider = nullptr;
260 if (!shared_worker_context_provider_) { 262 if (!shared_worker_context_provider_) {
261 shared_worker_context_provider_ = ContextProviderCommandBuffer::Create( 263 shared_worker_context_provider_ = ContextProviderCommandBuffer::Create(
262 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host, 264 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host,
263 0), 265 0),
264 BROWSER_WORKER_CONTEXT); 266 BROWSER_WORKER_CONTEXT);
265 if (shared_worker_context_provider_ && 267 if (shared_worker_context_provider_ &&
266 !shared_worker_context_provider_->BindToCurrentThread()) 268 !shared_worker_context_provider_->BindToCurrentThread())
267 shared_worker_context_provider_ = nullptr; 269 shared_worker_context_provider_ = nullptr;
270 if (shared_worker_context_provider_)
271 shared_worker_context_provider_->SetupLock();
268 } 272 }
269 } 273 }
270 274
271 bool created_gpu_browser_compositor = 275 bool created_gpu_browser_compositor =
272 !!context_provider && !!shared_worker_context_provider_; 276 !!context_provider && !!shared_worker_context_provider_;
273 277
274 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", 278 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor",
275 created_gpu_browser_compositor); 279 created_gpu_browser_compositor);
276 280
277 if (!created_gpu_browser_compositor) { 281 if (!created_gpu_browser_compositor) {
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, 628 FOR_EACH_OBSERVER(ImageTransportFactoryObserver,
625 observer_list_, 629 observer_list_,
626 OnLostResources()); 630 OnLostResources());
627 631
628 // Kill things that use the shared context before killing the shared context. 632 // Kill things that use the shared context before killing the shared context.
629 lost_gl_helper.reset(); 633 lost_gl_helper.reset();
630 lost_shared_main_thread_contexts = NULL; 634 lost_shared_main_thread_contexts = NULL;
631 } 635 }
632 636
633 } // namespace content 637 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698