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 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1198 DidModifyTilePriorities(); | 1198 DidModifyTilePriorities(); |
1199 } | 1199 } |
1200 | 1200 |
1201 void LayerTreeHostImpl::DidModifyTilePriorities() { | 1201 void LayerTreeHostImpl::DidModifyTilePriorities() { |
1202 DCHECK(settings_.impl_side_painting); | 1202 DCHECK(settings_.impl_side_painting); |
1203 // Mark priorities as dirty and schedule a PrepareTiles(). | 1203 // Mark priorities as dirty and schedule a PrepareTiles(). |
1204 tile_priorities_dirty_ = true; | 1204 tile_priorities_dirty_ = true; |
1205 client_->SetNeedsPrepareTilesOnImplThread(); | 1205 client_->SetNeedsPrepareTilesOnImplThread(); |
1206 } | 1206 } |
1207 | 1207 |
1208 void LayerTreeHostImpl::GetPictureLayerImplPairs( | 1208 bool LayerTreeHostImpl::PendingTreeExists() { |
1209 std::vector<PictureLayerImpl::Pair>* layer_pairs, | 1209 return !!pending_tree(); |
1210 bool need_valid_tile_priorities) const { | |
1211 DCHECK(layer_pairs->empty()); | |
1212 | |
1213 for (auto& layer : active_tree_->picture_layers()) { | |
1214 if (need_valid_tile_priorities && !layer->HasValidTilePriorities()) | |
1215 continue; | |
1216 PictureLayerImpl* twin_layer = layer->GetPendingOrActiveTwinLayer(); | |
1217 // Ignore the twin layer when tile priorities are invalid. | |
1218 if (need_valid_tile_priorities && twin_layer && | |
1219 !twin_layer->HasValidTilePriorities()) { | |
1220 twin_layer = nullptr; | |
1221 } | |
1222 layer_pairs->push_back(PictureLayerImpl::Pair(layer, twin_layer)); | |
1223 } | |
1224 | |
1225 if (pending_tree_) { | |
1226 for (auto& layer : pending_tree_->picture_layers()) { | |
1227 if (need_valid_tile_priorities && !layer->HasValidTilePriorities()) | |
1228 continue; | |
1229 if (layer->GetPendingOrActiveTwinLayer()) { | |
1230 // Already captured from the active tree. | |
1231 continue; | |
1232 } | |
1233 layer_pairs->push_back(PictureLayerImpl::Pair(nullptr, layer)); | |
1234 } | |
1235 } | |
1236 } | |
1237 | |
1238 scoped_ptr<RasterTilePriorityQueue> LayerTreeHostImpl::BuildRasterQueue( | |
1239 TreePriority tree_priority, | |
1240 RasterTilePriorityQueue::Type type) { | |
1241 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); | |
1242 picture_layer_pairs_.clear(); | |
1243 GetPictureLayerImplPairs(&picture_layer_pairs_, true); | |
1244 return RasterTilePriorityQueue::Create(picture_layer_pairs_, tree_priority, | |
1245 type); | |
1246 } | |
1247 | |
1248 scoped_ptr<EvictionTilePriorityQueue> LayerTreeHostImpl::BuildEvictionQueue( | |
1249 TreePriority tree_priority) { | |
1250 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); | |
1251 scoped_ptr<EvictionTilePriorityQueue> queue(new EvictionTilePriorityQueue); | |
1252 picture_layer_pairs_.clear(); | |
1253 GetPictureLayerImplPairs(&picture_layer_pairs_, false); | |
1254 queue->Build(picture_layer_pairs_, tree_priority); | |
1255 return queue; | |
1256 } | 1210 } |
1257 | 1211 |
1258 void LayerTreeHostImpl::SetIsLikelyToRequireADraw( | 1212 void LayerTreeHostImpl::SetIsLikelyToRequireADraw( |
1259 bool is_likely_to_require_a_draw) { | 1213 bool is_likely_to_require_a_draw) { |
1260 // Proactively tell the scheduler that we expect to draw within each vsync | 1214 // Proactively tell the scheduler that we expect to draw within each vsync |
1261 // until we get all the tiles ready to draw. If we happen to miss a required | 1215 // until we get all the tiles ready to draw. If we happen to miss a required |
1262 // for draw tile here, then we will miss telling the scheduler each frame that | 1216 // for draw tile here, then we will miss telling the scheduler each frame that |
1263 // we intend to draw so it may make worse scheduling decisions. | 1217 // we intend to draw so it may make worse scheduling decisions. |
1264 is_likely_to_require_a_draw_ = is_likely_to_require_a_draw; | 1218 is_likely_to_require_a_draw_ = is_likely_to_require_a_draw; |
1265 } | 1219 } |
(...skipping 2219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3485 (*it)->OnSetNeedsRedrawOnImpl(); | 3439 (*it)->OnSetNeedsRedrawOnImpl(); |
3486 } | 3440 } |
3487 | 3441 |
3488 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { | 3442 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { |
3489 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3443 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3490 for (; it != swap_promise_monitor_.end(); it++) | 3444 for (; it != swap_promise_monitor_.end(); it++) |
3491 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); | 3445 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); |
3492 } | 3446 } |
3493 | 3447 |
3494 } // namespace cc | 3448 } // namespace cc |
OLD | NEW |