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