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 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 DidModifyTilePriorities(); | 1195 DidModifyTilePriorities(); |
1196 } | 1196 } |
1197 | 1197 |
1198 void LayerTreeHostImpl::DidModifyTilePriorities() { | 1198 void LayerTreeHostImpl::DidModifyTilePriorities() { |
1199 DCHECK(settings_.impl_side_painting); | 1199 DCHECK(settings_.impl_side_painting); |
1200 // Mark priorities as dirty and schedule a PrepareTiles(). | 1200 // Mark priorities as dirty and schedule a PrepareTiles(). |
1201 tile_priorities_dirty_ = true; | 1201 tile_priorities_dirty_ = true; |
1202 client_->SetNeedsPrepareTilesOnImplThread(); | 1202 client_->SetNeedsPrepareTilesOnImplThread(); |
1203 } | 1203 } |
1204 | 1204 |
1205 void LayerTreeHostImpl::GetPictureLayerImplPairs( | 1205 bool LayerTreeHostImpl::PendingTreeExists() { |
1206 std::vector<PictureLayerImpl::Pair>* layer_pairs, | 1206 return !!pending_tree(); |
1207 bool need_valid_tile_priorities) const { | |
1208 DCHECK(layer_pairs->empty()); | |
1209 for (std::vector<PictureLayerImpl*>::const_iterator it = | |
1210 picture_layers_.begin(); | |
1211 it != picture_layers_.end(); | |
1212 ++it) { | |
1213 PictureLayerImpl* layer = *it; | |
1214 | |
1215 if (!layer->IsOnActiveOrPendingTree() || | |
1216 (need_valid_tile_priorities && !layer->HasValidTilePriorities())) | |
1217 continue; | |
1218 | |
1219 PictureLayerImpl* twin_layer = layer->GetPendingOrActiveTwinLayer(); | |
1220 | |
1221 // Ignore the twin layer when tile priorities are invalid. | |
1222 if (need_valid_tile_priorities && twin_layer && | |
1223 !twin_layer->HasValidTilePriorities()) | |
1224 twin_layer = NULL; | |
1225 | |
1226 // If the current tree is ACTIVE_TREE, then always generate a layer_pair. | |
1227 // If current tree is PENDING_TREE, then only generate a layer_pair if | |
1228 // there is no twin layer. | |
1229 if (layer->GetTree() == ACTIVE_TREE) { | |
1230 DCHECK_IMPLIES(twin_layer, twin_layer->GetTree() == PENDING_TREE); | |
1231 layer_pairs->push_back(PictureLayerImpl::Pair(layer, twin_layer)); | |
1232 } else if (!twin_layer) { | |
1233 DCHECK(layer->GetTree() == PENDING_TREE); | |
1234 layer_pairs->push_back(PictureLayerImpl::Pair(NULL, layer)); | |
1235 } | |
1236 } | |
1237 } | |
1238 | |
1239 scoped_ptr<RasterTilePriorityQueue> LayerTreeHostImpl::BuildRasterQueue( | |
1240 TreePriority tree_priority, | |
1241 RasterTilePriorityQueue::Type type) { | |
1242 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); | |
1243 picture_layer_pairs_.clear(); | |
1244 GetPictureLayerImplPairs(&picture_layer_pairs_, true); | |
1245 return RasterTilePriorityQueue::Create(picture_layer_pairs_, tree_priority, | |
1246 type); | |
1247 } | |
1248 | |
1249 scoped_ptr<EvictionTilePriorityQueue> LayerTreeHostImpl::BuildEvictionQueue( | |
1250 TreePriority tree_priority) { | |
1251 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); | |
1252 scoped_ptr<EvictionTilePriorityQueue> queue(new EvictionTilePriorityQueue); | |
1253 picture_layer_pairs_.clear(); | |
1254 GetPictureLayerImplPairs(&picture_layer_pairs_, false); | |
1255 queue->Build(picture_layer_pairs_, tree_priority); | |
1256 return queue; | |
1257 } | 1207 } |
1258 | 1208 |
1259 void LayerTreeHostImpl::SetIsLikelyToRequireADraw( | 1209 void LayerTreeHostImpl::SetIsLikelyToRequireADraw( |
1260 bool is_likely_to_require_a_draw) { | 1210 bool is_likely_to_require_a_draw) { |
1261 // Proactively tell the scheduler that we expect to draw within each vsync | 1211 // Proactively tell the scheduler that we expect to draw within each vsync |
1262 // until we get all the tiles ready to draw. If we happen to miss a required | 1212 // until we get all the tiles ready to draw. If we happen to miss a required |
1263 // for draw tile here, then we will miss telling the scheduler each frame that | 1213 // for draw tile here, then we will miss telling the scheduler each frame that |
1264 // we intend to draw so it may make worse scheduling decisions. | 1214 // we intend to draw so it may make worse scheduling decisions. |
1265 is_likely_to_require_a_draw_ = is_likely_to_require_a_draw; | 1215 is_likely_to_require_a_draw_ = is_likely_to_require_a_draw; |
1266 } | 1216 } |
1267 | 1217 |
1268 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() | |
1269 const { | |
1270 return picture_layers_; | |
1271 } | |
1272 | |
1273 void LayerTreeHostImpl::NotifyReadyToActivate() { | 1218 void LayerTreeHostImpl::NotifyReadyToActivate() { |
1274 client_->NotifyReadyToActivate(); | 1219 client_->NotifyReadyToActivate(); |
1275 } | 1220 } |
1276 | 1221 |
1277 void LayerTreeHostImpl::NotifyReadyToDraw() { | 1222 void LayerTreeHostImpl::NotifyReadyToDraw() { |
1278 // Tiles that are ready will cause NotifyTileStateChanged() to be called so we | 1223 // Tiles that are ready will cause NotifyTileStateChanged() to be called so we |
1279 // don't need to schedule a draw here. Just stop WillBeginImplFrame() from | 1224 // don't need to schedule a draw here. Just stop WillBeginImplFrame() from |
1280 // causing optimistic requests to draw a frame. | 1225 // causing optimistic requests to draw a frame. |
1281 is_likely_to_require_a_draw_ = false; | 1226 is_likely_to_require_a_draw_ = false; |
1282 | 1227 |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1822 | 1767 |
1823 UpdateViewportContainerSizes(); | 1768 UpdateViewportContainerSizes(); |
1824 } else { | 1769 } else { |
1825 active_tree_->ProcessUIResourceRequestQueue(); | 1770 active_tree_->ProcessUIResourceRequestQueue(); |
1826 } | 1771 } |
1827 | 1772 |
1828 active_tree_->DidBecomeActive(); | 1773 active_tree_->DidBecomeActive(); |
1829 ActivateAnimations(); | 1774 ActivateAnimations(); |
1830 if (settings_.impl_side_painting) { | 1775 if (settings_.impl_side_painting) { |
1831 client_->RenewTreePriority(); | 1776 client_->RenewTreePriority(); |
1832 // If we have any picture layers, then by activating we also modified tile | 1777 // If tile manager has tiling sets (ie, it tree priority changes would |
1833 // priorities. | 1778 // potentially affect some tiles), then make sure to schedule PrepareTiles |
1834 if (!picture_layers_.empty()) | 1779 // via DidModifyTilePriorities. |
| 1780 if (tile_manager()->HasPictureLayerTilingSets()) |
1835 DidModifyTilePriorities(); | 1781 DidModifyTilePriorities(); |
1836 } | 1782 } |
1837 | 1783 |
1838 client_->OnCanDrawStateChanged(CanDraw()); | 1784 client_->OnCanDrawStateChanged(CanDraw()); |
1839 client_->DidActivateSyncTree(); | 1785 client_->DidActivateSyncTree(); |
1840 if (!tree_activation_callback_.is_null()) | 1786 if (!tree_activation_callback_.is_null()) |
1841 tree_activation_callback_.Run(); | 1787 tree_activation_callback_.Run(); |
1842 | 1788 |
1843 if (debug_state_.continuous_painting) { | 1789 if (debug_state_.continuous_painting) { |
1844 const RenderingStats& stats = | 1790 const RenderingStats& stats = |
(...skipping 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3502 for (; it != swap_promise_monitor_.end(); it++) | 3448 for (; it != swap_promise_monitor_.end(); it++) |
3503 (*it)->OnSetNeedsRedrawOnImpl(); | 3449 (*it)->OnSetNeedsRedrawOnImpl(); |
3504 } | 3450 } |
3505 | 3451 |
3506 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { | 3452 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { |
3507 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3453 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3508 for (; it != swap_promise_monitor_.end(); it++) | 3454 for (; it != swap_promise_monitor_.end(); it++) |
3509 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); | 3455 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); |
3510 } | 3456 } |
3511 | 3457 |
3512 void LayerTreeHostImpl::RegisterPictureLayerImpl(PictureLayerImpl* layer) { | |
3513 DCHECK(std::find(picture_layers_.begin(), picture_layers_.end(), layer) == | |
3514 picture_layers_.end()); | |
3515 picture_layers_.push_back(layer); | |
3516 } | |
3517 | |
3518 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | |
3519 std::vector<PictureLayerImpl*>::iterator it = | |
3520 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | |
3521 DCHECK(it != picture_layers_.end()); | |
3522 picture_layers_.erase(it); | |
3523 } | |
3524 | |
3525 } // namespace cc | 3458 } // namespace cc |
OLD | NEW |