Index: cc/trees/layer_tree_host_impl.cc |
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc |
index ef2b53dcc00a6cb2bbbf6d8d38bfd3307cfa55c8..eb936989803eafbf6a60b20d646ffcac76ebe0df 100644 |
--- a/cc/trees/layer_tree_host_impl.cc |
+++ b/cc/trees/layer_tree_host_impl.cc |
@@ -1436,6 +1436,23 @@ bool LayerTreeHostImpl::InitializeRenderer( |
// Since we will create a new resource provider, we cannot continue to use |
// the old resources (i.e. render_surfaces and texture IDs). Clear them |
// before we destroy the old resource provider. |
+ DropLayerResources(); |
+ |
+ // Note: order is important here. |
+ renderer_.reset(); |
+ tile_manager_.reset(); |
+ resource_provider_.reset(); |
+ output_surface_.reset(); |
+ |
+ if (!output_surface->BindToClient(this)) |
+ return false; |
+ |
+ return DoInitializeRenderer(output_surface.Pass(), |
+ false /* is_deferred_init */); |
+} |
+ |
+void LayerTreeHostImpl::DropLayerResources() { |
+ // TODO(boliu): Rename LoseOutputSurface to DrawLayerResources. |
if (active_tree_->root_layer()) |
ClearRenderSurfaces(); |
if (active_tree_->root_layer()) |
@@ -1446,17 +1463,13 @@ bool LayerTreeHostImpl::InitializeRenderer( |
SendDidLoseOutputSurfaceRecursive(recycle_tree_->root_layer()); |
if (resource_provider_) |
resource_provider_->DidLoseOutputSurface(); |
piman
2013/06/05 00:39:37
You don't want to do that in the re-initialization
boliu
2013/06/05 01:01:54
Actually this needs more work as I remembered Dana
|
+} |
- // Note: order is important here. |
- renderer_.reset(); |
- tile_manager_.reset(); |
- resource_provider_.reset(); |
- output_surface_.reset(); |
- |
- if (!output_surface->BindToClient(this)) |
- return false; |
- |
- if (output_surface->capabilities().deferred_gl_initialization) { |
+bool LayerTreeHostImpl::DoInitializeRenderer( |
+ scoped_ptr<OutputSurface> output_surface, |
+ bool is_deferred_init) { |
+ if (output_surface->capabilities().deferred_gl_initialization && |
+ !is_deferred_init) { |
// TODO(joth): Defer creating the Renderer too, until GL is initialized. |
// See http://crbug.com/230197 |
renderer_ = SoftwareRenderer::Create(this, output_surface.get(), NULL); |
@@ -1513,6 +1526,19 @@ bool LayerTreeHostImpl::InitializeRenderer( |
return true; |
} |
+bool LayerTreeHostImpl::DeferredInitialize( |
+ scoped_refptr<ContextProvider> offscreen_context_provider) { |
+ DCHECK(output_surface_->capabilities().deferred_gl_initialization); |
+ DCHECK(output_surface_->context3d()); |
+ |
+ DropLayerResources(); |
+ bool success = |
+ DoInitializeRenderer(output_surface_.Pass(), true /* is_deferred_init */); |
+ client_->DidTryInitializeRendererOnImplThread(success, |
+ offscreen_context_provider); |
+ return success; |
+} |
+ |
void LayerTreeHostImpl::SetViewportSize(gfx::Size device_viewport_size) { |
if (device_viewport_size == device_viewport_size_) |
return; |