Index: content/browser/renderer_host/compositor_impl_android.cc |
diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc |
index 2a168a89c55a45ce1cd0d9bd8ee1b7a8f0df146d..396fa2de4ca5bbc7360e80723e2de4d80f49ab86 100644 |
--- a/content/browser/renderer_host/compositor_impl_android.cc |
+++ b/content/browser/renderer_host/compositor_impl_android.cc |
@@ -238,7 +238,8 @@ CompositorImpl::CompositorImpl(CompositorClient* client, |
window_(NULL), |
surface_id_(0), |
client_(client), |
- root_window_(root_window) { |
+ root_window_(root_window), |
+ weak_factory_(this) { |
DCHECK(client); |
DCHECK(root_window); |
ImageTransportFactoryAndroid::AddObserver(this); |
@@ -253,10 +254,26 @@ CompositorImpl::~CompositorImpl() { |
} |
void CompositorImpl::Composite() { |
+ BrowserGpuChannelHostFactory* factory = |
+ BrowserGpuChannelHostFactory::instance(); |
+ if (!factory->GetGpuChannel() || factory->GetGpuChannel()->IsLost()) { |
danakj
2014/04/14 13:14:46
Is the assumption that SingleThread compositor won
no sievers
2014/04/14 18:50:45
Yes, I changed it in r241897 to guarantee that beh
danakj
2014/04/14 19:30:01
With STP Scheduler, this method goes away entirely
no sievers
2014/04/14 19:40:34
Hmm, would I have to SetDeferCommits() also to mak
danakj
2014/04/14 20:29:35
Ya, I think you would to prevent races where the G
|
+ CauseForGpuLaunch cause = |
+ CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; |
+ factory->EstablishGpuChannel( |
+ cause, |
+ base::Bind(&CompositorImpl::OnGpuChannelEstablished, |
+ weak_factory_.GetWeakPtr())); |
+ return; |
+ } |
+ |
if (host_) |
host_->Composite(gfx::FrameTime::Now()); |
} |
+void CompositorImpl::OnGpuChannelEstablished() { |
+ ScheduleComposite(); |
+} |
+ |
void CompositorImpl::SetRootLayer(scoped_refptr<cc::Layer> root_layer) { |
root_layer_->RemoveAllChildren(); |
root_layer_->AddChild(root_layer); |
@@ -429,16 +446,10 @@ void CompositorImpl::DeleteUIResource(cc::UIResourceId resource_id) { |
static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
CreateGpuProcessViewContext( |
+ const scoped_refptr<GpuChannelHost>& gpu_channel_host, |
const blink::WebGraphicsContext3D::Attributes attributes, |
int surface_id) { |
- BrowserGpuChannelHostFactory* factory = |
- BrowserGpuChannelHostFactory::instance(); |
- CauseForGpuLaunch cause = |
- CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; |
- scoped_refptr<GpuChannelHost> gpu_channel_host( |
- factory->EstablishGpuChannelSync(cause)); |
- if (!gpu_channel_host) |
- return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
+ DCHECK(gpu_channel_host); |
GURL url("chrome://gpu/Compositor::createContext3D"); |
static const size_t kBytesPerPixel = 4; |
@@ -474,9 +485,15 @@ scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface( |
DCHECK(window_); |
DCHECK(surface_id_); |
- scoped_refptr<ContextProviderCommandBuffer> context_provider = |
- ContextProviderCommandBuffer::Create( |
- CreateGpuProcessViewContext(attrs, surface_id_), "BrowserCompositor"); |
+ scoped_refptr<ContextProviderCommandBuffer> context_provider; |
+ BrowserGpuChannelHostFactory* factory = |
+ BrowserGpuChannelHostFactory::instance(); |
+ scoped_refptr<GpuChannelHost> gpu_channel_host = factory->GetGpuChannel(); |
+ if (gpu_channel_host && !gpu_channel_host->IsLost()) { |
danakj
2014/04/14 13:14:46
Say we were to remove the compositor retry-CreateO
no sievers
2014/04/14 18:50:45
Does it really change anything though from how it
danakj
2014/04/14 19:30:01
Ok, I think I want to make it so this method can n
|
+ context_provider = ContextProviderCommandBuffer::Create( |
+ CreateGpuProcessViewContext(gpu_channel_host, attrs, surface_id_), |
+ "BrowserCompositor"); |
+ } |
if (!context_provider.get()) { |
LOG(ERROR) << "Failed to create 3D context for compositor."; |
return scoped_ptr<cc::OutputSurface>(); |