Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(505)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 22926024: cc: Control activation from the Scheduler (Closed) Base URL: http://git.chromium.org/chromium/src.git@schedOutputSurface4
Patch Set: kill has_active_tree_ Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // correct. In fact, setting fake thread id's interferes with the real 103 // correct. In fact, setting fake thread id's interferes with the real
104 // thread id's and causes breakage. 104 // thread id's and causes breakage.
105 scoped_ptr<DebugScopedSetImplThread> set_impl_thread; 105 scoped_ptr<DebugScopedSetImplThread> set_impl_thread;
106 if (!layer_tree_host_impl_->proxy()->HasImplThread()) { 106 if (!layer_tree_host_impl_->proxy()->HasImplThread()) {
107 set_impl_thread.reset( 107 set_impl_thread.reset(
108 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy())); 108 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy()));
109 } 109 }
110 110
111 // TODO(enne): This should probably happen post-animate. 111 // TODO(enne): This should probably happen post-animate.
112 if (layer_tree_host_impl_->pending_tree()) { 112 if (layer_tree_host_impl_->pending_tree()) {
113 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); 113 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties();
114 114 layer_tree_host_impl_->ManageTiles();
115 if (layer_tree_host_impl_->pending_tree()) {
116 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties();
117 layer_tree_host_impl_->ManageTiles();
118 }
119 } 115 }
120 116
121 layer_tree_host_impl_->Animate( 117 layer_tree_host_impl_->Animate(
122 layer_tree_host_impl_->CurrentFrameTimeTicks(), 118 layer_tree_host_impl_->CurrentFrameTimeTicks(),
123 layer_tree_host_impl_->CurrentFrameTime()); 119 layer_tree_host_impl_->CurrentFrameTime());
124 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true); 120 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true);
125 bool start_ready_animations = true; 121 bool start_ready_animations = true;
126 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); 122 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
127 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); 123 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
128 } 124 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); 243 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete");
248 244
249 if (settings_.impl_side_painting) { 245 if (settings_.impl_side_painting) {
250 // Impl-side painting needs an update immediately post-commit to have the 246 // Impl-side painting needs an update immediately post-commit to have the
251 // opportunity to create tilings. Other paths can call UpdateDrawProperties 247 // opportunity to create tilings. Other paths can call UpdateDrawProperties
252 // more lazily when needed prior to drawing. 248 // more lazily when needed prior to drawing.
253 pending_tree()->ApplyScrollDeltasSinceBeginFrame(); 249 pending_tree()->ApplyScrollDeltasSinceBeginFrame();
254 pending_tree_->set_needs_update_draw_properties(); 250 pending_tree_->set_needs_update_draw_properties();
255 pending_tree_->UpdateDrawProperties(); 251 pending_tree_->UpdateDrawProperties();
256 // Start working on newly created tiles immediately if needed. 252 // Start working on newly created tiles immediately if needed.
257 ManageTiles(); 253 if (!tile_manager_ || !manage_tiles_needed_)
254 NotifyReadyToActivate();
255 else
256 ManageTiles();
258 } else { 257 } else {
259 active_tree_->set_needs_update_draw_properties(); 258 active_tree_->set_needs_update_draw_properties();
260 } 259 }
261 260
262 client_->SendManagedMemoryStats(); 261 client_->SendManagedMemoryStats();
263 } 262 }
264 263
265 bool LayerTreeHostImpl::CanDraw() const { 264 bool LayerTreeHostImpl::CanDraw() const {
266 // Note: If you are changing this function or any other function that might 265 // Note: If you are changing this function or any other function that might
267 // affect the result of CanDraw, make sure to call 266 // affect the result of CanDraw, make sure to call
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 1018
1020 // If we return true, then we expect DrawLayers() to be called before this 1019 // If we return true, then we expect DrawLayers() to be called before this
1021 // function is called again. 1020 // function is called again.
1022 return true; 1021 return true;
1023 } 1022 }
1024 1023
1025 void LayerTreeHostImpl::EvictTexturesForTesting() { 1024 void LayerTreeHostImpl::EvictTexturesForTesting() {
1026 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0)); 1025 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0));
1027 } 1026 }
1028 1027
1028
1029 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) {
1030 NOTREACHED();
1031 }
1032
1029 void LayerTreeHostImpl::EnforceManagedMemoryPolicy( 1033 void LayerTreeHostImpl::EnforceManagedMemoryPolicy(
1030 const ManagedMemoryPolicy& policy) { 1034 const ManagedMemoryPolicy& policy) {
1031 1035
1032 bool evicted_resources = client_->ReduceContentsTextureMemoryOnImplThread( 1036 bool evicted_resources = client_->ReduceContentsTextureMemoryOnImplThread(
1033 visible_ ? policy.bytes_limit_when_visible 1037 visible_ ? policy.bytes_limit_when_visible
1034 : policy.bytes_limit_when_not_visible, 1038 : policy.bytes_limit_when_not_visible,
1035 ManagedMemoryPolicy::PriorityCutoffToValue( 1039 ManagedMemoryPolicy::PriorityCutoffToValue(
1036 visible_ ? policy.priority_cutoff_when_visible 1040 visible_ ? policy.priority_cutoff_when_visible
1037 : policy.priority_cutoff_when_not_visible)); 1041 : policy.priority_cutoff_when_not_visible));
1038 if (evicted_resources) { 1042 if (evicted_resources) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 1082
1079 void LayerTreeHostImpl::DidInitializeVisibleTile() { 1083 void LayerTreeHostImpl::DidInitializeVisibleTile() {
1080 // TODO(reveman): Determine tiles that changed and only damage 1084 // TODO(reveman): Determine tiles that changed and only damage
1081 // what's necessary. 1085 // what's necessary.
1082 SetFullRootLayerDamage(); 1086 SetFullRootLayerDamage();
1083 if (client_) 1087 if (client_)
1084 client_->DidInitializeVisibleTileOnImplThread(); 1088 client_->DidInitializeVisibleTileOnImplThread();
1085 } 1089 }
1086 1090
1087 void LayerTreeHostImpl::NotifyReadyToActivate() { 1091 void LayerTreeHostImpl::NotifyReadyToActivate() {
1088 if (pending_tree_) { 1092 client_->NotifyReadyToActivate();
1089 need_to_update_visible_tiles_before_draw_ = true;
1090 ActivatePendingTree();
1091 }
1092 } 1093 }
1093 1094
1094 bool LayerTreeHostImpl::ShouldClearRootRenderPass() const { 1095 bool LayerTreeHostImpl::ShouldClearRootRenderPass() const {
1095 return settings_.should_clear_root_render_pass; 1096 return settings_.should_clear_root_render_pass;
1096 } 1097 }
1097 1098
1098 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { 1099 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) {
1099 SetManagedMemoryPolicy(policy, zero_budget_); 1100 SetManagedMemoryPolicy(policy, zero_budget_);
1100 } 1101 }
1101 1102
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 return 0; 1427 return 0;
1427 } 1428 }
1428 1429
1429 void LayerTreeHostImpl::CreatePendingTree() { 1430 void LayerTreeHostImpl::CreatePendingTree() {
1430 CHECK(!pending_tree_); 1431 CHECK(!pending_tree_);
1431 if (recycle_tree_) 1432 if (recycle_tree_)
1432 recycle_tree_.swap(pending_tree_); 1433 recycle_tree_.swap(pending_tree_);
1433 else 1434 else
1434 pending_tree_ = LayerTreeImpl::create(this); 1435 pending_tree_ = LayerTreeImpl::create(this);
1435 client_->OnCanDrawStateChanged(CanDraw()); 1436 client_->OnCanDrawStateChanged(CanDraw());
1436 client_->OnHasPendingTreeStateChanged(pending_tree_);
1437 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree", pending_tree_.get()); 1437 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree", pending_tree_.get());
1438 TRACE_EVENT_ASYNC_STEP0("cc", 1438 TRACE_EVENT_ASYNC_STEP0("cc",
1439 "PendingTree", pending_tree_.get(), "waiting"); 1439 "PendingTree", pending_tree_.get(), "waiting");
1440 } 1440 }
1441 1441
1442 void LayerTreeHostImpl::UpdateVisibleTiles() { 1442 void LayerTreeHostImpl::UpdateVisibleTiles() {
1443 DCHECK(!client_->IsInsideDraw()) << 1443 DCHECK(!client_->IsInsideDraw()) <<
1444 "Updating visible tiles within a draw may trigger " 1444 "Updating visible tiles within a draw may trigger "
1445 "spurious redraws."; 1445 "spurious redraws.";
1446 if (tile_manager_ && tile_manager_->UpdateVisibleTiles()) 1446 if (tile_manager_ && tile_manager_->UpdateVisibleTiles())
1447 DidInitializeVisibleTile(); 1447 DidInitializeVisibleTile();
1448 1448
1449 need_to_update_visible_tiles_before_draw_ = false; 1449 need_to_update_visible_tiles_before_draw_ = false;
1450 } 1450 }
1451 1451
1452 void LayerTreeHostImpl::ActivatePendingTreeIfNeeded() {
1453 DCHECK(pending_tree_);
1454 CHECK(settings_.impl_side_painting);
1455
1456 if (!pending_tree_)
1457 return;
1458
1459 // The tile manager is usually responsible for notifying activation.
1460 // If there is no tile manager, then we need to manually activate.
1461 if (!tile_manager_ || tile_manager_->AreTilesRequiredForActivationReady()) {
1462 ActivatePendingTree();
1463 return;
1464 }
1465
1466 // Manage tiles in case state affecting tile priority has changed.
1467 ManageTiles();
1468
1469 TRACE_EVENT_ASYNC_STEP1(
1470 "cc",
1471 "PendingTree", pending_tree_.get(), "activate",
1472 "state", TracedValue::FromValue(ActivationStateAsValue().release()));
1473 }
1474
1475 void LayerTreeHostImpl::ActivatePendingTree() { 1452 void LayerTreeHostImpl::ActivatePendingTree() {
1476 CHECK(pending_tree_); 1453 CHECK(pending_tree_);
1477 TRACE_EVENT_ASYNC_END0("cc", "PendingTree", pending_tree_.get()); 1454 TRACE_EVENT_ASYNC_END0("cc", "PendingTree", pending_tree_.get());
1478 1455
1456 need_to_update_visible_tiles_before_draw_ = true;
1457
1479 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); 1458 active_tree_->SetRootLayerScrollOffsetDelegate(NULL);
1480 active_tree_->PushPersistedState(pending_tree_.get()); 1459 active_tree_->PushPersistedState(pending_tree_.get());
1481 if (pending_tree_->needs_full_tree_sync()) { 1460 if (pending_tree_->needs_full_tree_sync()) {
1482 active_tree_->SetRootLayer( 1461 active_tree_->SetRootLayer(
1483 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), 1462 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(),
1484 active_tree_->DetachLayerTree(), 1463 active_tree_->DetachLayerTree(),
1485 active_tree_.get())); 1464 active_tree_.get()));
1486 } 1465 }
1487 TreeSynchronizer::PushProperties(pending_tree_->root_layer(), 1466 TreeSynchronizer::PushProperties(pending_tree_->root_layer(),
1488 active_tree_->root_layer()); 1467 active_tree_->root_layer());
(...skipping 13 matching lines...) Expand all
1502 1481
1503 active_tree_->SetRootLayerScrollOffsetDelegate( 1482 active_tree_->SetRootLayerScrollOffsetDelegate(
1504 root_layer_scroll_offset_delegate_); 1483 root_layer_scroll_offset_delegate_);
1505 active_tree_->DidBecomeActive(); 1484 active_tree_->DidBecomeActive();
1506 1485
1507 // Reduce wasted memory now that unlinked resources are guaranteed not 1486 // Reduce wasted memory now that unlinked resources are guaranteed not
1508 // to be used. 1487 // to be used.
1509 client_->ReduceWastedContentsTextureMemoryOnImplThread(); 1488 client_->ReduceWastedContentsTextureMemoryOnImplThread();
1510 1489
1511 client_->OnCanDrawStateChanged(CanDraw()); 1490 client_->OnCanDrawStateChanged(CanDraw());
1512 client_->OnHasPendingTreeStateChanged(pending_tree_);
1513 client_->SetNeedsRedrawOnImplThread(); 1491 client_->SetNeedsRedrawOnImplThread();
1514 client_->RenewTreePriority(); 1492 client_->RenewTreePriority();
1515 1493
1516 if (debug_state_.continuous_painting) { 1494 if (debug_state_.continuous_painting) {
1517 const RenderingStats& stats = 1495 const RenderingStats& stats =
1518 rendering_stats_instrumentation_->GetRenderingStats(); 1496 rendering_stats_instrumentation_->GetRenderingStats();
1519 paint_time_counter_->SavePaintTime( 1497 paint_time_counter_->SavePaintTime(
1520 stats.main_stats.paint_time + stats.main_stats.record_time + 1498 stats.main_stats.paint_time + stats.main_stats.record_time +
1521 stats.impl_stats.rasterize_time_for_now_bins_on_pending_tree); 1499 stats.impl_stats.rasterize_time_for_now_bins_on_pending_tree);
1522 } 1500 }
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
2535 2513
2536 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( 2514 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource(
2537 UIResourceId uid) const { 2515 UIResourceId uid) const {
2538 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); 2516 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid);
2539 if (iter != ui_resource_map_.end()) 2517 if (iter != ui_resource_map_.end())
2540 return iter->second; 2518 return iter->second;
2541 return 0; 2519 return 0;
2542 } 2520 }
2543 2521
2544 } // namespace cc 2522 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698