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

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

Issue 25367003: aura: Attach lost context callback to the shared main thread context (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add test Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/aura/image_transport_factory_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/aura/gpu_process_transport_factory.h" 5 #include "content/browser/aura/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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 // loss for this context through the lost context callback. If the context 400 // loss for this context through the lost context callback. If the context
401 // is lost, we want to leave this ContextProvider available until the lost 401 // is lost, we want to leave this ContextProvider available until the lost
402 // context notification is sent to the ImageTransportFactoryObserver clients. 402 // context notification is sent to the ImageTransportFactoryObserver clients.
403 if (offscreen_compositor_contexts_.get()) 403 if (offscreen_compositor_contexts_.get())
404 return offscreen_compositor_contexts_; 404 return offscreen_compositor_contexts_;
405 405
406 offscreen_compositor_contexts_ = ContextProviderCommandBuffer::Create( 406 offscreen_compositor_contexts_ = ContextProviderCommandBuffer::Create(
407 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext(), 407 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext(),
408 "Compositor-Offscreen"); 408 "Compositor-Offscreen");
409 409
410 if (!offscreen_compositor_contexts_.get())
411 return NULL;
412
413 if (!ui::Compositor::WasInitializedWithThread()) {
414 offscreen_compositor_contexts_->SetLostContextCallback(base::Bind(
415 &GpuProcessTransportFactory::
416 OnLostMainThreadSharedContextInsideCallback,
417 callback_factory_.GetWeakPtr()));
418 }
419
420 return offscreen_compositor_contexts_; 410 return offscreen_compositor_contexts_;
421 } 411 }
422 412
423 scoped_refptr<cc::ContextProvider> 413 scoped_refptr<cc::ContextProvider>
424 GpuProcessTransportFactory::SharedMainThreadContextProvider() { 414 GpuProcessTransportFactory::SharedMainThreadContextProvider() {
425 if (shared_main_thread_contexts_.get()) 415 if (shared_main_thread_contexts_.get())
426 return shared_main_thread_contexts_; 416 return shared_main_thread_contexts_;
427 417
428 if (ui::Compositor::WasInitializedWithThread()) { 418 if (ui::Compositor::WasInitializedWithThread()) {
429 // In threaded compositing mode, we have to create our own context for the 419 // In threaded compositing mode, we have to create our own context for the
430 // main thread since the compositor's context will be bound to the 420 // main thread since the compositor's context will be bound to the
431 // compositor thread. 421 // compositor thread.
432 shared_main_thread_contexts_ = ContextProviderCommandBuffer::Create( 422 shared_main_thread_contexts_ = ContextProviderCommandBuffer::Create(
433 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext(), 423 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext(),
434 "Offscreen-MainThread"); 424 "Offscreen-MainThread");
435 } else { 425 } else {
436 // In single threaded compositing mode, we can just reuse the compositor's 426 // In single threaded compositing mode, we can just reuse the compositor's
437 // shared context. 427 // shared context.
438 shared_main_thread_contexts_ = 428 shared_main_thread_contexts_ =
439 static_cast<ContextProviderCommandBuffer*>( 429 static_cast<ContextProviderCommandBuffer*>(
440 OffscreenCompositorContextProvider().get()); 430 OffscreenCompositorContextProvider().get());
441 } 431 }
442 432
443 if (shared_main_thread_contexts_ && 433 if (shared_main_thread_contexts_) {
444 !shared_main_thread_contexts_->BindToCurrentThread()) 434 shared_main_thread_contexts_->SetLostContextCallback(
445 shared_main_thread_contexts_ = NULL; 435 base::Bind(&GpuProcessTransportFactory::
436 OnLostMainThreadSharedContextInsideCallback,
437 callback_factory_.GetWeakPtr()));
438 if (!shared_main_thread_contexts_->BindToCurrentThread())
439 shared_main_thread_contexts_ = NULL;
440 }
446 return shared_main_thread_contexts_; 441 return shared_main_thread_contexts_;
447 } 442 }
448 443
449 void GpuProcessTransportFactory::OnLostContext(ui::Compositor* compositor) { 444 void GpuProcessTransportFactory::OnLostContext(ui::Compositor* compositor) {
450 LOG(ERROR) << "Lost UI compositor context."; 445 LOG(ERROR) << "Lost UI compositor context.";
451 PerCompositorData* data = per_compositor_data_[compositor]; 446 PerCompositorData* data = per_compositor_data_[compositor];
452 DCHECK(data); 447 DCHECK(data);
453 448
454 // Prevent callbacks from other contexts in the same share group from 449 // Prevent callbacks from other contexts in the same share group from
455 // calling us again. 450 // calling us again.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 observer_list_, 531 observer_list_,
537 OnLostResources()); 532 OnLostResources());
538 533
539 // Kill things that use the shared context before killing the shared context. 534 // Kill things that use the shared context before killing the shared context.
540 lost_gl_helper.reset(); 535 lost_gl_helper.reset();
541 lost_offscreen_compositor_contexts = NULL; 536 lost_offscreen_compositor_contexts = NULL;
542 lost_shared_main_thread_contexts = NULL; 537 lost_shared_main_thread_contexts = NULL;
543 } 538 }
544 539
545 } // namespace content 540 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/aura/image_transport_factory_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698