OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1429 actual.priority_cutoff_when_visible = | 1429 actual.priority_cutoff_when_visible = |
1430 ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY; | 1430 ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY; |
1431 return actual; | 1431 return actual; |
1432 } | 1432 } |
1433 | 1433 |
1434 bool LayerTreeHostImpl::InitializeRenderer( | 1434 bool LayerTreeHostImpl::InitializeRenderer( |
1435 scoped_ptr<OutputSurface> output_surface) { | 1435 scoped_ptr<OutputSurface> output_surface) { |
1436 // Since we will create a new resource provider, we cannot continue to use | 1436 // Since we will create a new resource provider, we cannot continue to use |
1437 // the old resources (i.e. render_surfaces and texture IDs). Clear them | 1437 // the old resources (i.e. render_surfaces and texture IDs). Clear them |
1438 // before we destroy the old resource provider. | 1438 // before we destroy the old resource provider. |
1439 DropLayerResources(); | |
1440 | |
1441 // Note: order is important here. | |
1442 renderer_.reset(); | |
1443 tile_manager_.reset(); | |
1444 resource_provider_.reset(); | |
1445 output_surface_.reset(); | |
1446 | |
1447 if (!output_surface->BindToClient(this)) | |
1448 return false; | |
1449 | |
1450 return DoInitializeRenderer(output_surface.Pass(), | |
1451 false /* is_deferred_init */); | |
1452 } | |
1453 | |
1454 void LayerTreeHostImpl::DropLayerResources() { | |
1455 // TODO(boliu): Rename LoseOutputSurface to DrawLayerResources. | |
1439 if (active_tree_->root_layer()) | 1456 if (active_tree_->root_layer()) |
1440 ClearRenderSurfaces(); | 1457 ClearRenderSurfaces(); |
1441 if (active_tree_->root_layer()) | 1458 if (active_tree_->root_layer()) |
1442 SendDidLoseOutputSurfaceRecursive(active_tree_->root_layer()); | 1459 SendDidLoseOutputSurfaceRecursive(active_tree_->root_layer()); |
1443 if (pending_tree_ && pending_tree_->root_layer()) | 1460 if (pending_tree_ && pending_tree_->root_layer()) |
1444 SendDidLoseOutputSurfaceRecursive(pending_tree_->root_layer()); | 1461 SendDidLoseOutputSurfaceRecursive(pending_tree_->root_layer()); |
1445 if (recycle_tree_ && recycle_tree_->root_layer()) | 1462 if (recycle_tree_ && recycle_tree_->root_layer()) |
1446 SendDidLoseOutputSurfaceRecursive(recycle_tree_->root_layer()); | 1463 SendDidLoseOutputSurfaceRecursive(recycle_tree_->root_layer()); |
1447 if (resource_provider_) | 1464 if (resource_provider_) |
1448 resource_provider_->DidLoseOutputSurface(); | 1465 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
| |
1466 } | |
1449 | 1467 |
1450 // Note: order is important here. | 1468 bool LayerTreeHostImpl::DoInitializeRenderer( |
1451 renderer_.reset(); | 1469 scoped_ptr<OutputSurface> output_surface, |
1452 tile_manager_.reset(); | 1470 bool is_deferred_init) { |
1453 resource_provider_.reset(); | 1471 if (output_surface->capabilities().deferred_gl_initialization && |
1454 output_surface_.reset(); | 1472 !is_deferred_init) { |
1455 | |
1456 if (!output_surface->BindToClient(this)) | |
1457 return false; | |
1458 | |
1459 if (output_surface->capabilities().deferred_gl_initialization) { | |
1460 // TODO(joth): Defer creating the Renderer too, until GL is initialized. | 1473 // TODO(joth): Defer creating the Renderer too, until GL is initialized. |
1461 // See http://crbug.com/230197 | 1474 // See http://crbug.com/230197 |
1462 renderer_ = SoftwareRenderer::Create(this, output_surface.get(), NULL); | 1475 renderer_ = SoftwareRenderer::Create(this, output_surface.get(), NULL); |
1463 } else { | 1476 } else { |
1464 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( | 1477 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( |
1465 output_surface.get(), settings_.highp_threshold_min); | 1478 output_surface.get(), settings_.highp_threshold_min); |
1466 if (!resource_provider) | 1479 if (!resource_provider) |
1467 return false; | 1480 return false; |
1468 | 1481 |
1469 if (output_surface->capabilities().has_parent_compositor) { | 1482 if (output_surface->capabilities().has_parent_compositor) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1506 | 1519 |
1507 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs | 1520 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs |
1508 // to be initialized to get max texture size. | 1521 // to be initialized to get max texture size. |
1509 active_tree_->set_needs_update_draw_properties(); | 1522 active_tree_->set_needs_update_draw_properties(); |
1510 if (pending_tree_) | 1523 if (pending_tree_) |
1511 pending_tree_->set_needs_update_draw_properties(); | 1524 pending_tree_->set_needs_update_draw_properties(); |
1512 | 1525 |
1513 return true; | 1526 return true; |
1514 } | 1527 } |
1515 | 1528 |
1529 bool LayerTreeHostImpl::DeferredInitialize( | |
1530 scoped_refptr<ContextProvider> offscreen_context_provider) { | |
1531 DCHECK(output_surface_->capabilities().deferred_gl_initialization); | |
1532 DCHECK(output_surface_->context3d()); | |
1533 | |
1534 DropLayerResources(); | |
1535 bool success = | |
1536 DoInitializeRenderer(output_surface_.Pass(), true /* is_deferred_init */); | |
1537 client_->DidTryInitializeRendererOnImplThread(success, | |
1538 offscreen_context_provider); | |
1539 return success; | |
1540 } | |
1541 | |
1516 void LayerTreeHostImpl::SetViewportSize(gfx::Size device_viewport_size) { | 1542 void LayerTreeHostImpl::SetViewportSize(gfx::Size device_viewport_size) { |
1517 if (device_viewport_size == device_viewport_size_) | 1543 if (device_viewport_size == device_viewport_size_) |
1518 return; | 1544 return; |
1519 | 1545 |
1520 if (pending_tree_ && device_viewport_size_ != device_viewport_size) | 1546 if (pending_tree_ && device_viewport_size_ != device_viewport_size) |
1521 active_tree_->SetViewportSizeInvalid(); | 1547 active_tree_->SetViewportSizeInvalid(); |
1522 | 1548 |
1523 device_viewport_size_ = device_viewport_size; | 1549 device_viewport_size_ = device_viewport_size; |
1524 | 1550 |
1525 UpdateMaxScrollOffset(); | 1551 UpdateMaxScrollOffset(); |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2272 } | 2298 } |
2273 | 2299 |
2274 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { | 2300 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { |
2275 if (debug_state_.continuous_painting != debug_state.continuous_painting) | 2301 if (debug_state_.continuous_painting != debug_state.continuous_painting) |
2276 paint_time_counter_->ClearHistory(); | 2302 paint_time_counter_->ClearHistory(); |
2277 | 2303 |
2278 debug_state_ = debug_state; | 2304 debug_state_ = debug_state; |
2279 } | 2305 } |
2280 | 2306 |
2281 } // namespace cc | 2307 } // namespace cc |
OLD | NEW |