| 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 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); | 1013 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); |
| 1014 } else { | 1014 } else { |
| 1015 DCHECK(proxy_->IsImplThread()); | 1015 DCHECK(proxy_->IsImplThread()); |
| 1016 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); | 1016 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); |
| 1017 } | 1017 } |
| 1018 | 1018 |
| 1019 if (needs_commit) | 1019 if (needs_commit) |
| 1020 client_->SetNeedsCommitOnImplThread(); | 1020 client_->SetNeedsCommitOnImplThread(); |
| 1021 } | 1021 } |
| 1022 | 1022 |
| 1023 bool LayerTreeHostImpl::InitializeForGL( |
| 1024 scoped_refptr<ContextProvider> offscreen_context_provider) { |
| 1025 scoped_ptr<OutputSurface> output_surface = CleanupForRendererInitialization(); |
| 1026 bool success = DoInitializeRenderer(output_surface.Pass()); |
| 1027 if (success) { |
| 1028 resource_provider_->set_offscreen_context_provider( |
| 1029 offscreen_context_provider); |
| 1030 client_->DidUpdateCapabilitiesOnImplThread(); |
| 1031 } |
| 1032 return success; |
| 1033 } |
| 1034 |
| 1023 void LayerTreeHostImpl::SetNeedsRedrawRect(gfx::Rect damage_rect) { | 1035 void LayerTreeHostImpl::SetNeedsRedrawRect(gfx::Rect damage_rect) { |
| 1024 client_->SetNeedsRedrawRectOnImplThread(damage_rect); | 1036 client_->SetNeedsRedrawRectOnImplThread(damage_rect); |
| 1025 } | 1037 } |
| 1026 | 1038 |
| 1027 void LayerTreeHostImpl::OnVSyncParametersChanged(base::TimeTicks timebase, | 1039 void LayerTreeHostImpl::OnVSyncParametersChanged(base::TimeTicks timebase, |
| 1028 base::TimeDelta interval) { | 1040 base::TimeDelta interval) { |
| 1029 client_->OnVSyncParametersChanged(timebase, interval); | 1041 client_->OnVSyncParametersChanged(timebase, interval); |
| 1030 } | 1042 } |
| 1031 | 1043 |
| 1032 void LayerTreeHostImpl::DidVSync(base::TimeTicks frame_time) { | 1044 void LayerTreeHostImpl::DidVSync(base::TimeTicks frame_time) { |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 return managed_memory_policy_; | 1384 return managed_memory_policy_; |
| 1373 | 1385 |
| 1374 ManagedMemoryPolicy actual = managed_memory_policy_; | 1386 ManagedMemoryPolicy actual = managed_memory_policy_; |
| 1375 actual.priority_cutoff_when_not_visible = | 1387 actual.priority_cutoff_when_not_visible = |
| 1376 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING; | 1388 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING; |
| 1377 actual.priority_cutoff_when_visible = | 1389 actual.priority_cutoff_when_visible = |
| 1378 ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY; | 1390 ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY; |
| 1379 return actual; | 1391 return actual; |
| 1380 } | 1392 } |
| 1381 | 1393 |
| 1382 bool LayerTreeHostImpl::InitializeRenderer( | 1394 scoped_ptr<OutputSurface> |
| 1383 scoped_ptr<OutputSurface> output_surface) { | 1395 LayerTreeHostImpl::CleanupForRendererInitialization() { |
| 1384 // Since we will create a new resource provider, we cannot continue to use | 1396 // Since we will create a new resource provider, we cannot continue to use |
| 1385 // the old resources (i.e. render_surfaces and texture IDs). Clear them | 1397 // the old resources (i.e. render_surfaces and texture IDs). Clear them |
| 1386 // before we destroy the old resource provider. | 1398 // before we destroy the old resource provider. |
| 1387 if (active_tree_->root_layer()) | 1399 if (active_tree_->root_layer()) |
| 1388 ClearRenderSurfaces(); | 1400 ClearRenderSurfaces(); |
| 1389 if (active_tree_->root_layer()) | 1401 if (active_tree_->root_layer()) |
| 1390 SendDidLoseOutputSurfaceRecursive(active_tree_->root_layer()); | 1402 SendDidLoseOutputSurfaceRecursive(active_tree_->root_layer()); |
| 1391 if (pending_tree_ && pending_tree_->root_layer()) | 1403 if (pending_tree_ && pending_tree_->root_layer()) |
| 1392 SendDidLoseOutputSurfaceRecursive(pending_tree_->root_layer()); | 1404 SendDidLoseOutputSurfaceRecursive(pending_tree_->root_layer()); |
| 1393 if (recycle_tree_ && recycle_tree_->root_layer()) | 1405 if (recycle_tree_ && recycle_tree_->root_layer()) |
| 1394 SendDidLoseOutputSurfaceRecursive(recycle_tree_->root_layer()); | 1406 SendDidLoseOutputSurfaceRecursive(recycle_tree_->root_layer()); |
| 1395 if (resource_provider_) | 1407 if (resource_provider_) |
| 1396 resource_provider_->DidLoseOutputSurface(); | 1408 resource_provider_->DidLoseOutputSurface(); |
| 1397 | 1409 |
| 1398 // Note: order is important here. | 1410 // Note: order is important here. |
| 1399 renderer_.reset(); | 1411 renderer_.reset(); |
| 1400 tile_manager_.reset(); | 1412 tile_manager_.reset(); |
| 1401 resource_provider_.reset(); | 1413 resource_provider_.reset(); |
| 1402 output_surface_.reset(); | 1414 return output_surface_.Pass(); |
| 1415 } |
| 1403 | 1416 |
| 1404 if (!output_surface->BindToClient(this)) | 1417 bool LayerTreeHostImpl::DoInitializeRenderer( |
| 1405 return false; | 1418 scoped_ptr<OutputSurface> output_surface) { |
| 1406 | |
| 1407 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( | 1419 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( |
| 1408 output_surface.get(), settings_.highp_threshold_min); | 1420 output_surface.get(), settings_.highp_threshold_min); |
| 1409 if (!resource_provider) | 1421 if (!resource_provider) |
| 1410 return false; | 1422 return false; |
| 1411 | 1423 |
| 1412 if (settings_.impl_side_painting) { | 1424 if (settings_.impl_side_painting) { |
| 1413 tile_manager_.reset(new TileManager(this, | 1425 tile_manager_.reset(new TileManager(this, |
| 1414 resource_provider.get(), | 1426 resource_provider.get(), |
| 1415 settings_.num_raster_threads, | 1427 settings_.num_raster_threads, |
| 1416 settings_.use_color_estimator, | 1428 settings_.use_color_estimator, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1444 | 1456 |
| 1445 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs | 1457 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs |
| 1446 // to be initialized to get max texture size. | 1458 // to be initialized to get max texture size. |
| 1447 active_tree_->set_needs_update_draw_properties(); | 1459 active_tree_->set_needs_update_draw_properties(); |
| 1448 if (pending_tree_) | 1460 if (pending_tree_) |
| 1449 pending_tree_->set_needs_update_draw_properties(); | 1461 pending_tree_->set_needs_update_draw_properties(); |
| 1450 | 1462 |
| 1451 return true; | 1463 return true; |
| 1452 } | 1464 } |
| 1453 | 1465 |
| 1466 bool LayerTreeHostImpl::InitializeRenderer( |
| 1467 scoped_ptr<OutputSurface> output_surface) { |
| 1468 scoped_ptr<OutputSurface> old_output_surface = |
| 1469 CleanupForRendererInitialization(); |
| 1470 old_output_surface.reset(); |
| 1471 |
| 1472 if (!output_surface->BindToClient(this)) |
| 1473 return false; |
| 1474 |
| 1475 return DoInitializeRenderer(output_surface.Pass()); |
| 1476 } |
| 1477 |
| 1454 void LayerTreeHostImpl::SetViewportSize(gfx::Size device_viewport_size) { | 1478 void LayerTreeHostImpl::SetViewportSize(gfx::Size device_viewport_size) { |
| 1455 if (device_viewport_size == device_viewport_size_) | 1479 if (device_viewport_size == device_viewport_size_) |
| 1456 return; | 1480 return; |
| 1457 | 1481 |
| 1458 if (pending_tree_ && device_viewport_size_ != device_viewport_size) | 1482 if (pending_tree_ && device_viewport_size_ != device_viewport_size) |
| 1459 active_tree_->SetViewportSizeInvalid(); | 1483 active_tree_->SetViewportSizeInvalid(); |
| 1460 | 1484 |
| 1461 device_viewport_size_ = device_viewport_size; | 1485 device_viewport_size_ = device_viewport_size; |
| 1462 | 1486 |
| 1463 UpdateMaxScrollOffset(); | 1487 UpdateMaxScrollOffset(); |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2187 } | 2211 } |
| 2188 | 2212 |
| 2189 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { | 2213 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { |
| 2190 if (debug_state_.continuous_painting != debug_state.continuous_painting) | 2214 if (debug_state_.continuous_painting != debug_state.continuous_painting) |
| 2191 paint_time_counter_->ClearHistory(); | 2215 paint_time_counter_->ClearHistory(); |
| 2192 | 2216 |
| 2193 debug_state_ = debug_state; | 2217 debug_state_ = debug_state; |
| 2194 } | 2218 } |
| 2195 | 2219 |
| 2196 } // namespace cc | 2220 } // namespace cc |
| OLD | NEW |