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