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

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: Fixes for tests Created 7 years, 4 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 (!manage_tiles_needed_)
254 client_->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 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 1077
1079 void LayerTreeHostImpl::DidInitializeVisibleTile() { 1078 void LayerTreeHostImpl::DidInitializeVisibleTile() {
1080 // TODO(reveman): Determine tiles that changed and only damage 1079 // TODO(reveman): Determine tiles that changed and only damage
1081 // what's necessary. 1080 // what's necessary.
1082 SetFullRootLayerDamage(); 1081 SetFullRootLayerDamage();
1083 if (client_) 1082 if (client_)
1084 client_->DidInitializeVisibleTileOnImplThread(); 1083 client_->DidInitializeVisibleTileOnImplThread();
1085 } 1084 }
1086 1085
1087 void LayerTreeHostImpl::NotifyReadyToActivate() { 1086 void LayerTreeHostImpl::NotifyReadyToActivate() {
1088 if (pending_tree_) { 1087 client_->NotifyReadyToActivate();
1089 need_to_update_visible_tiles_before_draw_ = true;
1090 ActivatePendingTree();
1091 }
1092 } 1088 }
1093 1089
1094 bool LayerTreeHostImpl::ShouldClearRootRenderPass() const { 1090 bool LayerTreeHostImpl::ShouldClearRootRenderPass() const {
1095 return settings_.should_clear_root_render_pass; 1091 return settings_.should_clear_root_render_pass;
1096 } 1092 }
1097 1093
1098 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { 1094 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) {
1099 SetManagedMemoryPolicy(policy, zero_budget_); 1095 SetManagedMemoryPolicy(policy, zero_budget_);
1100 } 1096 }
1101 1097
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 return 0; 1422 return 0;
1427 } 1423 }
1428 1424
1429 void LayerTreeHostImpl::CreatePendingTree() { 1425 void LayerTreeHostImpl::CreatePendingTree() {
1430 CHECK(!pending_tree_); 1426 CHECK(!pending_tree_);
1431 if (recycle_tree_) 1427 if (recycle_tree_)
1432 recycle_tree_.swap(pending_tree_); 1428 recycle_tree_.swap(pending_tree_);
1433 else 1429 else
1434 pending_tree_ = LayerTreeImpl::create(this); 1430 pending_tree_ = LayerTreeImpl::create(this);
1435 client_->OnCanDrawStateChanged(CanDraw()); 1431 client_->OnCanDrawStateChanged(CanDraw());
1436 client_->OnHasPendingTreeStateChanged(pending_tree_);
1437 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree", pending_tree_.get()); 1432 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree", pending_tree_.get());
1438 TRACE_EVENT_ASYNC_STEP0("cc", 1433 TRACE_EVENT_ASYNC_STEP0("cc",
1439 "PendingTree", pending_tree_.get(), "waiting"); 1434 "PendingTree", pending_tree_.get(), "waiting");
1440 } 1435 }
1441 1436
1442 void LayerTreeHostImpl::UpdateVisibleTiles() { 1437 void LayerTreeHostImpl::UpdateVisibleTiles() {
1443 DCHECK(!client_->IsInsideDraw()) << 1438 DCHECK(!client_->IsInsideDraw()) <<
1444 "Updating visible tiles within a draw may trigger " 1439 "Updating visible tiles within a draw may trigger "
1445 "spurious redraws."; 1440 "spurious redraws.";
1446 if (tile_manager_ && tile_manager_->UpdateVisibleTiles()) 1441 if (tile_manager_ && tile_manager_->UpdateVisibleTiles())
1447 DidInitializeVisibleTile(); 1442 DidInitializeVisibleTile();
1448 1443
1449 need_to_update_visible_tiles_before_draw_ = false; 1444 need_to_update_visible_tiles_before_draw_ = false;
1450 } 1445 }
1451 1446
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()) {
enne (OOO) 2013/08/26 21:55:13 Where does this removed !tile_manager logic end up
brianderson 2013/08/26 22:47:25 Good idea. I will add handle the !time_manager cas
brianderson 2013/08/26 23:33:20 In looking at how to implement this test, it seems
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() { 1447 void LayerTreeHostImpl::ActivatePendingTree() {
1476 CHECK(pending_tree_); 1448 CHECK(pending_tree_);
1477 TRACE_EVENT_ASYNC_END0("cc", "PendingTree", pending_tree_.get()); 1449 TRACE_EVENT_ASYNC_END0("cc", "PendingTree", pending_tree_.get());
1478 1450
1451 need_to_update_visible_tiles_before_draw_ = true;
1452
1479 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); 1453 active_tree_->SetRootLayerScrollOffsetDelegate(NULL);
1480 active_tree_->PushPersistedState(pending_tree_.get()); 1454 active_tree_->PushPersistedState(pending_tree_.get());
1481 if (pending_tree_->needs_full_tree_sync()) { 1455 if (pending_tree_->needs_full_tree_sync()) {
1482 active_tree_->SetRootLayer( 1456 active_tree_->SetRootLayer(
1483 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), 1457 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(),
1484 active_tree_->DetachLayerTree(), 1458 active_tree_->DetachLayerTree(),
1485 active_tree_.get())); 1459 active_tree_.get()));
1486 } 1460 }
1487 TreeSynchronizer::PushProperties(pending_tree_->root_layer(), 1461 TreeSynchronizer::PushProperties(pending_tree_->root_layer(),
1488 active_tree_->root_layer()); 1462 active_tree_->root_layer());
1489 DCHECK(!recycle_tree_); 1463 DCHECK(!recycle_tree_);
1490 1464
1491 // Process any requests in the UI resource queue. The request queue is given 1465 // Process any requests in the UI resource queue. The request queue is given
1492 // in LayerTreeHost::FinishCommitOnImplThread. This must take place before 1466 // in LayerTreeHost::FinishCommitOnImplThread. This must take place before
1493 // the swap. 1467 // the swap.
1494 pending_tree_->ProcessUIResourceRequestQueue(); 1468 pending_tree_->ProcessUIResourceRequestQueue();
1495 1469
1496 pending_tree_->PushPropertiesTo(active_tree_.get()); 1470 pending_tree_->PushPropertiesTo(active_tree_.get());
1497 1471
1498 // Now that we've synced everything from the pending tree to the active 1472 // Now that we've synced everything from the pending tree to the active
1499 // tree, rename the pending tree the recycle tree so we can reuse it on the 1473 // tree, rename the pending tree the recycle tree so we can reuse it on the
1500 // next sync. 1474 // next sync.
1501 pending_tree_.swap(recycle_tree_); 1475 pending_tree_.swap(recycle_tree_);
1502 1476
1503 active_tree_->SetRootLayerScrollOffsetDelegate( 1477 active_tree_->SetRootLayerScrollOffsetDelegate(
1504 root_layer_scroll_offset_delegate_); 1478 root_layer_scroll_offset_delegate_);
1505 active_tree_->DidBecomeActive(); 1479 active_tree_->DidBecomeActive();
1506 1480
1481 client_->DidActivatePendingTree();
enne (OOO) 2013/08/26 21:55:13 Why did this move from the end of the function? (J
brianderson 2013/08/26 22:47:25 I did this a long time ago and copied it over, so
1482 if (!tree_activation_callback_.is_null())
1483 tree_activation_callback_.Run();
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 }
1523
1524 client_->DidActivatePendingTree();
1525 if (!tree_activation_callback_.is_null())
1526 tree_activation_callback_.Run();
1527 } 1500 }
1528 1501
1529 void LayerTreeHostImpl::SetVisible(bool visible) { 1502 void LayerTreeHostImpl::SetVisible(bool visible) {
1530 DCHECK(proxy_->IsImplThread()); 1503 DCHECK(proxy_->IsImplThread());
1531 1504
1532 if (visible_ == visible) 1505 if (visible_ == visible)
1533 return; 1506 return;
1534 visible_ = visible; 1507 visible_ = visible;
1535 DidVisibilityChange(this, visible_); 1508 DidVisibilityChange(this, visible_);
1536 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); 1509 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy());
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
2535 2508
2536 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( 2509 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource(
2537 UIResourceId uid) const { 2510 UIResourceId uid) const {
2538 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); 2511 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid);
2539 if (iter != ui_resource_map_.end()) 2512 if (iter != ui_resource_map_.end())
2540 return iter->second; 2513 return iter->second;
2541 return 0; 2514 return 0;
2542 } 2515 }
2543 2516
2544 } // namespace cc 2517 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698