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

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: 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); 247 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete");
248 248
249 if (settings_.impl_side_painting) { 249 if (settings_.impl_side_painting) {
250 // Impl-side painting needs an update immediately post-commit to have the 250 // Impl-side painting needs an update immediately post-commit to have the
251 // opportunity to create tilings. Other paths can call UpdateDrawProperties 251 // opportunity to create tilings. Other paths can call UpdateDrawProperties
252 // more lazily when needed prior to drawing. 252 // more lazily when needed prior to drawing.
253 pending_tree()->ApplyScrollDeltasSinceBeginFrame(); 253 pending_tree()->ApplyScrollDeltasSinceBeginFrame();
254 pending_tree_->set_needs_update_draw_properties(); 254 pending_tree_->set_needs_update_draw_properties();
255 pending_tree_->UpdateDrawProperties(); 255 pending_tree_->UpdateDrawProperties();
256 // Start working on newly created tiles immediately if needed. 256 // Start working on newly created tiles immediately if needed.
257 ManageTiles(); 257 if (!manage_tiles_needed_)
258 client_->NotifyReadyToActivate();
259 else
260 ManageTiles();
258 } else { 261 } else {
259 active_tree_->set_needs_update_draw_properties(); 262 active_tree_->set_needs_update_draw_properties();
260 } 263 }
261 264
262 client_->SendManagedMemoryStats(); 265 client_->SendManagedMemoryStats();
263 } 266 }
264 267
265 bool LayerTreeHostImpl::CanDraw() const { 268 bool LayerTreeHostImpl::CanDraw() const {
266 // Note: If you are changing this function or any other function that might 269 // Note: If you are changing this function or any other function that might
267 // affect the result of CanDraw, make sure to call 270 // affect the result of CanDraw, make sure to call
(...skipping 810 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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 TRACE_EVENT_ASYNC_STEP1( 1469 TRACE_EVENT_ASYNC_STEP1(
1470 "cc", 1470 "cc",
1471 "PendingTree", pending_tree_.get(), "activate", 1471 "PendingTree", pending_tree_.get(), "activate",
1472 "state", TracedValue::FromValue(ActivationStateAsValue().release())); 1472 "state", TracedValue::FromValue(ActivationStateAsValue().release()));
1473 } 1473 }
1474 1474
1475 void LayerTreeHostImpl::ActivatePendingTree() { 1475 void LayerTreeHostImpl::ActivatePendingTree() {
1476 CHECK(pending_tree_); 1476 CHECK(pending_tree_);
1477 TRACE_EVENT_ASYNC_END0("cc", "PendingTree", pending_tree_.get()); 1477 TRACE_EVENT_ASYNC_END0("cc", "PendingTree", pending_tree_.get());
1478 1478
1479 need_to_update_visible_tiles_before_draw_ = true;
1480
1479 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); 1481 active_tree_->SetRootLayerScrollOffsetDelegate(NULL);
1480 active_tree_->PushPersistedState(pending_tree_.get()); 1482 active_tree_->PushPersistedState(pending_tree_.get());
1481 if (pending_tree_->needs_full_tree_sync()) { 1483 if (pending_tree_->needs_full_tree_sync()) {
1482 active_tree_->SetRootLayer( 1484 active_tree_->SetRootLayer(
1483 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), 1485 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(),
1484 active_tree_->DetachLayerTree(), 1486 active_tree_->DetachLayerTree(),
1485 active_tree_.get())); 1487 active_tree_.get()));
1486 } 1488 }
1487 TreeSynchronizer::PushProperties(pending_tree_->root_layer(), 1489 TreeSynchronizer::PushProperties(pending_tree_->root_layer(),
1488 active_tree_->root_layer()); 1490 active_tree_->root_layer());
1489 DCHECK(!recycle_tree_); 1491 DCHECK(!recycle_tree_);
1490 1492
1491 // Process any requests in the UI resource queue. The request queue is given 1493 // Process any requests in the UI resource queue. The request queue is given
1492 // in LayerTreeHost::FinishCommitOnImplThread. This must take place before 1494 // in LayerTreeHost::FinishCommitOnImplThread. This must take place before
1493 // the swap. 1495 // the swap.
1494 pending_tree_->ProcessUIResourceRequestQueue(); 1496 pending_tree_->ProcessUIResourceRequestQueue();
1495 1497
1496 pending_tree_->PushPropertiesTo(active_tree_.get()); 1498 pending_tree_->PushPropertiesTo(active_tree_.get());
1497 1499
1498 // Now that we've synced everything from the pending tree to the active 1500 // 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 1501 // tree, rename the pending tree the recycle tree so we can reuse it on the
1500 // next sync. 1502 // next sync.
1501 pending_tree_.swap(recycle_tree_); 1503 pending_tree_.swap(recycle_tree_);
1502 1504
1503 active_tree_->SetRootLayerScrollOffsetDelegate( 1505 active_tree_->SetRootLayerScrollOffsetDelegate(
1504 root_layer_scroll_offset_delegate_); 1506 root_layer_scroll_offset_delegate_);
1505 active_tree_->DidBecomeActive(); 1507 active_tree_->DidBecomeActive();
1506 1508
1509 client_->DidActivatePendingTree();
1510 if (!tree_activation_callback_.is_null())
1511 tree_activation_callback_.Run();
1512
1507 // Reduce wasted memory now that unlinked resources are guaranteed not 1513 // Reduce wasted memory now that unlinked resources are guaranteed not
1508 // to be used. 1514 // to be used.
1509 client_->ReduceWastedContentsTextureMemoryOnImplThread(); 1515 client_->ReduceWastedContentsTextureMemoryOnImplThread();
1510 1516
1511 client_->OnCanDrawStateChanged(CanDraw()); 1517 client_->OnCanDrawStateChanged(CanDraw());
1512 client_->OnHasPendingTreeStateChanged(pending_tree_); 1518 client_->OnHasPendingTreeStateChanged(pending_tree_);
1513 client_->SetNeedsRedrawOnImplThread(); 1519 client_->SetNeedsRedrawOnImplThread();
1514 client_->RenewTreePriority(); 1520 client_->RenewTreePriority();
1515 1521
1516 if (debug_state_.continuous_painting) { 1522 if (debug_state_.continuous_painting) {
1517 const RenderingStats& stats = 1523 const RenderingStats& stats =
1518 rendering_stats_instrumentation_->GetRenderingStats(); 1524 rendering_stats_instrumentation_->GetRenderingStats();
1519 paint_time_counter_->SavePaintTime( 1525 paint_time_counter_->SavePaintTime(
1520 stats.main_stats.paint_time + stats.main_stats.record_time + 1526 stats.main_stats.paint_time + stats.main_stats.record_time +
1521 stats.impl_stats.rasterize_time_for_now_bins_on_pending_tree); 1527 stats.impl_stats.rasterize_time_for_now_bins_on_pending_tree);
1522 } 1528 }
1523
1524 client_->DidActivatePendingTree();
1525 if (!tree_activation_callback_.is_null())
1526 tree_activation_callback_.Run();
1527 } 1529 }
1528 1530
1529 void LayerTreeHostImpl::SetVisible(bool visible) { 1531 void LayerTreeHostImpl::SetVisible(bool visible) {
1530 DCHECK(proxy_->IsImplThread()); 1532 DCHECK(proxy_->IsImplThread());
1531 1533
1532 if (visible_ == visible) 1534 if (visible_ == visible)
1533 return; 1535 return;
1534 visible_ = visible; 1536 visible_ = visible;
1535 DidVisibilityChange(this, visible_); 1537 DidVisibilityChange(this, visible_);
1536 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); 1538 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy());
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
2535 2537
2536 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( 2538 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource(
2537 UIResourceId uid) const { 2539 UIResourceId uid) const {
2538 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); 2540 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid);
2539 if (iter != ui_resource_map_.end()) 2541 if (iter != ui_resource_map_.end())
2540 return iter->second; 2542 return iter->second;
2541 return 0; 2543 return 0;
2542 } 2544 }
2543 2545
2544 } // namespace cc 2546 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698