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 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 | 1455 |
1456 // Note: order is important here. | 1456 // Note: order is important here. |
1457 renderer_.reset(); | 1457 renderer_.reset(); |
1458 tile_manager_.reset(); | 1458 tile_manager_.reset(); |
1459 resource_provider_.reset(); | 1459 resource_provider_.reset(); |
1460 output_surface_.reset(); | 1460 output_surface_.reset(); |
1461 | 1461 |
1462 if (!output_surface->BindToClient(this)) | 1462 if (!output_surface->BindToClient(this)) |
1463 return false; | 1463 return false; |
1464 | 1464 |
1465 if (output_surface->capabilities().deferred_gl_initialization) { | 1465 return DoInitializeRenderer(output_surface.Pass(), |
| 1466 false /* is_deferred_init */); |
| 1467 } |
| 1468 |
| 1469 bool LayerTreeHostImpl::DoInitializeRenderer( |
| 1470 scoped_ptr<OutputSurface> output_surface, |
| 1471 bool is_deferred_init) { |
| 1472 if (output_surface->capabilities().deferred_gl_initialization && |
| 1473 !is_deferred_init) { |
1466 // TODO(joth): Defer creating the Renderer too, until GL is initialized. | 1474 // TODO(joth): Defer creating the Renderer too, until GL is initialized. |
1467 // See http://crbug.com/230197 | 1475 // See http://crbug.com/230197 |
1468 renderer_ = SoftwareRenderer::Create(this, output_surface.get(), NULL); | 1476 renderer_ = SoftwareRenderer::Create(this, output_surface.get(), NULL); |
1469 } else { | 1477 } else { |
1470 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( | 1478 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( |
1471 output_surface.get(), settings_.highp_threshold_min); | 1479 output_surface.get(), settings_.highp_threshold_min); |
1472 if (!resource_provider) | 1480 if (!resource_provider) |
1473 return false; | 1481 return false; |
1474 | 1482 |
1475 if (output_surface->capabilities().has_parent_compositor) { | 1483 if (output_surface->capabilities().has_parent_compositor) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 | 1520 |
1513 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs | 1521 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs |
1514 // to be initialized to get max texture size. | 1522 // to be initialized to get max texture size. |
1515 active_tree_->set_needs_update_draw_properties(); | 1523 active_tree_->set_needs_update_draw_properties(); |
1516 if (pending_tree_) | 1524 if (pending_tree_) |
1517 pending_tree_->set_needs_update_draw_properties(); | 1525 pending_tree_->set_needs_update_draw_properties(); |
1518 | 1526 |
1519 return true; | 1527 return true; |
1520 } | 1528 } |
1521 | 1529 |
| 1530 bool LayerTreeHostImpl::DeferredInitialize( |
| 1531 scoped_refptr<ContextProvider> offscreen_context_provider) { |
| 1532 DCHECK(output_surface_->capabilities().deferred_gl_initialization); |
| 1533 DCHECK(output_surface_->context3d()); |
| 1534 |
| 1535 // TODO(boliu): This is temporary until proper resource clean up is possible |
| 1536 // without resetting |tile_manager_| or |resource_provider_|. |
| 1537 DCHECK(!resource_provider_); |
| 1538 |
| 1539 bool success = |
| 1540 DoInitializeRenderer(output_surface_.Pass(), true /* is_deferred_init */); |
| 1541 client_->DidTryInitializeRendererOnImplThread(success, |
| 1542 offscreen_context_provider); |
| 1543 return success; |
| 1544 } |
| 1545 |
1522 void LayerTreeHostImpl::SetViewportSize(gfx::Size device_viewport_size) { | 1546 void LayerTreeHostImpl::SetViewportSize(gfx::Size device_viewport_size) { |
1523 if (device_viewport_size == device_viewport_size_) | 1547 if (device_viewport_size == device_viewport_size_) |
1524 return; | 1548 return; |
1525 | 1549 |
1526 if (pending_tree_ && device_viewport_size_ != device_viewport_size) | 1550 if (pending_tree_ && device_viewport_size_ != device_viewport_size) |
1527 active_tree_->SetViewportSizeInvalid(); | 1551 active_tree_->SetViewportSizeInvalid(); |
1528 | 1552 |
1529 device_viewport_size_ = device_viewport_size; | 1553 device_viewport_size_ = device_viewport_size; |
1530 | 1554 |
1531 UpdateMaxScrollOffset(); | 1555 UpdateMaxScrollOffset(); |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2267 } | 2291 } |
2268 | 2292 |
2269 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { | 2293 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { |
2270 if (debug_state_.continuous_painting != debug_state.continuous_painting) | 2294 if (debug_state_.continuous_painting != debug_state.continuous_painting) |
2271 paint_time_counter_->ClearHistory(); | 2295 paint_time_counter_->ClearHistory(); |
2272 | 2296 |
2273 debug_state_ = debug_state; | 2297 debug_state_ = debug_state; |
2274 } | 2298 } |
2275 | 2299 |
2276 } // namespace cc | 2300 } // namespace cc |
OLD | NEW |