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

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: git cl format 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) {
1029 NOTREACHED();
1030 }
1031
1029 void LayerTreeHostImpl::EnforceManagedMemoryPolicy( 1032 void LayerTreeHostImpl::EnforceManagedMemoryPolicy(
1030 const ManagedMemoryPolicy& policy) { 1033 const ManagedMemoryPolicy& policy) {
1031 1034
1032 bool evicted_resources = client_->ReduceContentsTextureMemoryOnImplThread( 1035 bool evicted_resources = client_->ReduceContentsTextureMemoryOnImplThread(
1033 visible_ ? policy.bytes_limit_when_visible 1036 visible_ ? policy.bytes_limit_when_visible
1034 : policy.bytes_limit_when_not_visible, 1037 : policy.bytes_limit_when_not_visible,
1035 ManagedMemoryPolicy::PriorityCutoffToValue( 1038 ManagedMemoryPolicy::PriorityCutoffToValue(
1036 visible_ ? policy.priority_cutoff_when_visible 1039 visible_ ? policy.priority_cutoff_when_visible
1037 : policy.priority_cutoff_when_not_visible)); 1040 : policy.priority_cutoff_when_not_visible));
1038 if (evicted_resources) { 1041 if (evicted_resources) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 1081
1079 void LayerTreeHostImpl::DidInitializeVisibleTile() { 1082 void LayerTreeHostImpl::DidInitializeVisibleTile() {
1080 // TODO(reveman): Determine tiles that changed and only damage 1083 // TODO(reveman): Determine tiles that changed and only damage
1081 // what's necessary. 1084 // what's necessary.
1082 SetFullRootLayerDamage(); 1085 SetFullRootLayerDamage();
1083 if (client_) 1086 if (client_)
1084 client_->DidInitializeVisibleTileOnImplThread(); 1087 client_->DidInitializeVisibleTileOnImplThread();
1085 } 1088 }
1086 1089
1087 void LayerTreeHostImpl::NotifyReadyToActivate() { 1090 void LayerTreeHostImpl::NotifyReadyToActivate() {
1088 if (pending_tree_) { 1091 client_->NotifyReadyToActivate();
1089 need_to_update_visible_tiles_before_draw_ = true;
1090 ActivatePendingTree();
1091 }
1092 } 1092 }
1093 1093
1094 bool LayerTreeHostImpl::ShouldClearRootRenderPass() const { 1094 bool LayerTreeHostImpl::ShouldClearRootRenderPass() const {
1095 return settings_.should_clear_root_render_pass; 1095 return settings_.should_clear_root_render_pass;
1096 } 1096 }
1097 1097
1098 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { 1098 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) {
1099 SetManagedMemoryPolicy(policy, zero_budget_); 1099 SetManagedMemoryPolicy(policy, zero_budget_);
1100 } 1100 }
1101 1101
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 return 0; 1426 return 0;
1427 } 1427 }
1428 1428
1429 void LayerTreeHostImpl::CreatePendingTree() { 1429 void LayerTreeHostImpl::CreatePendingTree() {
1430 CHECK(!pending_tree_); 1430 CHECK(!pending_tree_);
1431 if (recycle_tree_) 1431 if (recycle_tree_)
1432 recycle_tree_.swap(pending_tree_); 1432 recycle_tree_.swap(pending_tree_);
1433 else 1433 else
1434 pending_tree_ = LayerTreeImpl::create(this); 1434 pending_tree_ = LayerTreeImpl::create(this);
1435 client_->OnCanDrawStateChanged(CanDraw()); 1435 client_->OnCanDrawStateChanged(CanDraw());
1436 client_->OnHasPendingTreeStateChanged(pending_tree_);
1437 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree", pending_tree_.get()); 1436 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree", pending_tree_.get());
1438 TRACE_EVENT_ASYNC_STEP0("cc", 1437 TRACE_EVENT_ASYNC_STEP0("cc",
1439 "PendingTree", pending_tree_.get(), "waiting"); 1438 "PendingTree", pending_tree_.get(), "waiting");
1440 } 1439 }
1441 1440
1442 void LayerTreeHostImpl::UpdateVisibleTiles() { 1441 void LayerTreeHostImpl::UpdateVisibleTiles() {
1443 DCHECK(!client_->IsInsideDraw()) << 1442 DCHECK(!client_->IsInsideDraw()) <<
1444 "Updating visible tiles within a draw may trigger " 1443 "Updating visible tiles within a draw may trigger "
1445 "spurious redraws."; 1444 "spurious redraws.";
1446 if (tile_manager_ && tile_manager_->UpdateVisibleTiles()) 1445 if (tile_manager_ && tile_manager_->UpdateVisibleTiles())
1447 DidInitializeVisibleTile(); 1446 DidInitializeVisibleTile();
1448 1447
1449 need_to_update_visible_tiles_before_draw_ = false; 1448 need_to_update_visible_tiles_before_draw_ = false;
1450 } 1449 }
1451 1450
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() { 1451 void LayerTreeHostImpl::ActivatePendingTree() {
1476 CHECK(pending_tree_); 1452 CHECK(pending_tree_);
1477 TRACE_EVENT_ASYNC_END0("cc", "PendingTree", pending_tree_.get()); 1453 TRACE_EVENT_ASYNC_END0("cc", "PendingTree", pending_tree_.get());
1478 1454
1455 need_to_update_visible_tiles_before_draw_ = true;
1456
1479 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); 1457 active_tree_->SetRootLayerScrollOffsetDelegate(NULL);
1480 active_tree_->PushPersistedState(pending_tree_.get()); 1458 active_tree_->PushPersistedState(pending_tree_.get());
1481 if (pending_tree_->needs_full_tree_sync()) { 1459 if (pending_tree_->needs_full_tree_sync()) {
1482 active_tree_->SetRootLayer( 1460 active_tree_->SetRootLayer(
1483 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), 1461 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(),
1484 active_tree_->DetachLayerTree(), 1462 active_tree_->DetachLayerTree(),
1485 active_tree_.get())); 1463 active_tree_.get()));
1486 } 1464 }
1487 TreeSynchronizer::PushProperties(pending_tree_->root_layer(), 1465 TreeSynchronizer::PushProperties(pending_tree_->root_layer(),
1488 active_tree_->root_layer()); 1466 active_tree_->root_layer());
(...skipping 13 matching lines...) Expand all
1502 1480
1503 active_tree_->SetRootLayerScrollOffsetDelegate( 1481 active_tree_->SetRootLayerScrollOffsetDelegate(
1504 root_layer_scroll_offset_delegate_); 1482 root_layer_scroll_offset_delegate_);
1505 active_tree_->DidBecomeActive(); 1483 active_tree_->DidBecomeActive();
1506 1484
1507 // Reduce wasted memory now that unlinked resources are guaranteed not 1485 // Reduce wasted memory now that unlinked resources are guaranteed not
1508 // to be used. 1486 // to be used.
1509 client_->ReduceWastedContentsTextureMemoryOnImplThread(); 1487 client_->ReduceWastedContentsTextureMemoryOnImplThread();
1510 1488
1511 client_->OnCanDrawStateChanged(CanDraw()); 1489 client_->OnCanDrawStateChanged(CanDraw());
1512 client_->OnHasPendingTreeStateChanged(pending_tree_);
1513 client_->SetNeedsRedrawOnImplThread(); 1490 client_->SetNeedsRedrawOnImplThread();
1514 client_->RenewTreePriority(); 1491 client_->RenewTreePriority();
1515 1492
1516 if (debug_state_.continuous_painting) { 1493 if (debug_state_.continuous_painting) {
1517 const RenderingStats& stats = 1494 const RenderingStats& stats =
1518 rendering_stats_instrumentation_->GetRenderingStats(); 1495 rendering_stats_instrumentation_->GetRenderingStats();
1519 paint_time_counter_->SavePaintTime( 1496 paint_time_counter_->SavePaintTime(
1520 stats.main_stats.paint_time + stats.main_stats.record_time + 1497 stats.main_stats.paint_time + stats.main_stats.record_time +
1521 stats.impl_stats.rasterize_time_for_now_bins_on_pending_tree); 1498 stats.impl_stats.rasterize_time_for_now_bins_on_pending_tree);
1522 } 1499 }
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
2535 2512
2536 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( 2513 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource(
2537 UIResourceId uid) const { 2514 UIResourceId uid) const {
2538 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); 2515 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid);
2539 if (iter != ui_resource_map_.end()) 2516 if (iter != ui_resource_map_.end())
2540 return iter->second; 2517 return iter->second;
2541 return 0; 2518 return 0;
2542 } 2519 }
2543 2520
2544 } // namespace cc 2521 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698