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 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 tile_priorities_dirty_ = true; | 1170 tile_priorities_dirty_ = true; |
1171 client_->SetNeedsManageTilesOnImplThread(); | 1171 client_->SetNeedsManageTilesOnImplThread(); |
1172 } | 1172 } |
1173 | 1173 |
1174 void LayerTreeHostImpl::DidInitializeVisibleTile() { | 1174 void LayerTreeHostImpl::DidInitializeVisibleTile() { |
1175 if (client_ && !client_->IsInsideDraw()) | 1175 if (client_ && !client_->IsInsideDraw()) |
1176 client_->DidInitializeVisibleTileOnImplThread(); | 1176 client_->DidInitializeVisibleTileOnImplThread(); |
1177 } | 1177 } |
1178 | 1178 |
1179 void LayerTreeHostImpl::GetPictureLayerImplPairs( | 1179 void LayerTreeHostImpl::GetPictureLayerImplPairs( |
1180 std::vector<PictureLayerImpl::Pair>* layer_pairs) const { | 1180 std::vector<PictureLayerImpl::Pair>* layer_pairs, |
| 1181 bool need_valid_tile_priorities) const { |
1181 DCHECK(layer_pairs->empty()); | 1182 DCHECK(layer_pairs->empty()); |
1182 for (std::vector<PictureLayerImpl*>::const_iterator it = | 1183 for (std::vector<PictureLayerImpl*>::const_iterator it = |
1183 picture_layers_.begin(); | 1184 picture_layers_.begin(); |
1184 it != picture_layers_.end(); | 1185 it != picture_layers_.end(); |
1185 ++it) { | 1186 ++it) { |
1186 PictureLayerImpl* layer = *it; | 1187 PictureLayerImpl* layer = *it; |
1187 | 1188 |
1188 // TODO(vmpstr): Iterators and should handle this instead. crbug.com/381704 | 1189 if (!layer->IsOnActiveOrPendingTree() || |
1189 if (!layer->HasValidTilePriorities()) | 1190 (need_valid_tile_priorities && !layer->HasValidTilePriorities())) |
1190 continue; | 1191 continue; |
1191 | 1192 |
1192 PictureLayerImpl* twin_layer = layer->GetPendingOrActiveTwinLayer(); | 1193 PictureLayerImpl* twin_layer = layer->GetPendingOrActiveTwinLayer(); |
1193 | 1194 |
1194 // Ignore the twin layer when tile priorities are invalid. | 1195 // Ignore the twin layer when tile priorities are invalid. |
1195 // TODO(vmpstr): Iterators should handle this instead. crbug.com/381704 | 1196 if (need_valid_tile_priorities && twin_layer && |
1196 if (twin_layer && !twin_layer->HasValidTilePriorities()) | 1197 !twin_layer->HasValidTilePriorities()) |
1197 twin_layer = NULL; | 1198 twin_layer = NULL; |
1198 | 1199 |
1199 // If the current tree is ACTIVE_TREE, then always generate a layer_pair. | 1200 // If the current tree is ACTIVE_TREE, then always generate a layer_pair. |
1200 // If current tree is PENDING_TREE, then only generate a layer_pair if | 1201 // If current tree is PENDING_TREE, then only generate a layer_pair if |
1201 // there is no twin layer. | 1202 // there is no twin layer. |
1202 if (layer->GetTree() == ACTIVE_TREE) { | 1203 if (layer->GetTree() == ACTIVE_TREE) { |
1203 DCHECK(!twin_layer || twin_layer->GetTree() == PENDING_TREE); | 1204 DCHECK_IMPLIES(twin_layer, twin_layer->GetTree() == PENDING_TREE); |
1204 layer_pairs->push_back(PictureLayerImpl::Pair(layer, twin_layer)); | 1205 layer_pairs->push_back(PictureLayerImpl::Pair(layer, twin_layer)); |
1205 } else if (!twin_layer) { | 1206 } else if (!twin_layer) { |
| 1207 DCHECK(layer->GetTree() == PENDING_TREE); |
1206 layer_pairs->push_back(PictureLayerImpl::Pair(NULL, layer)); | 1208 layer_pairs->push_back(PictureLayerImpl::Pair(NULL, layer)); |
1207 } | 1209 } |
1208 } | 1210 } |
1209 } | 1211 } |
1210 | 1212 |
1211 void LayerTreeHostImpl::BuildRasterQueue(RasterTilePriorityQueue* queue, | 1213 void LayerTreeHostImpl::BuildRasterQueue(RasterTilePriorityQueue* queue, |
1212 TreePriority tree_priority) { | 1214 TreePriority tree_priority) { |
1213 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); | 1215 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); |
1214 picture_layer_pairs_.clear(); | 1216 picture_layer_pairs_.clear(); |
1215 GetPictureLayerImplPairs(&picture_layer_pairs_); | 1217 GetPictureLayerImplPairs(&picture_layer_pairs_, true); |
1216 queue->Build(picture_layer_pairs_, tree_priority); | 1218 queue->Build(picture_layer_pairs_, tree_priority); |
1217 } | 1219 } |
1218 | 1220 |
1219 void LayerTreeHostImpl::BuildEvictionQueue(EvictionTilePriorityQueue* queue, | 1221 void LayerTreeHostImpl::BuildEvictionQueue(EvictionTilePriorityQueue* queue, |
1220 TreePriority tree_priority) { | 1222 TreePriority tree_priority) { |
1221 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); | 1223 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); |
1222 picture_layer_pairs_.clear(); | 1224 picture_layer_pairs_.clear(); |
1223 GetPictureLayerImplPairs(&picture_layer_pairs_); | 1225 GetPictureLayerImplPairs(&picture_layer_pairs_, false); |
1224 queue->Build(picture_layer_pairs_, tree_priority); | 1226 queue->Build(picture_layer_pairs_, tree_priority); |
1225 } | 1227 } |
1226 | 1228 |
1227 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() | 1229 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() |
1228 const { | 1230 const { |
1229 return picture_layers_; | 1231 return picture_layers_; |
1230 } | 1232 } |
1231 | 1233 |
1232 void LayerTreeHostImpl::NotifyReadyToActivate() { | 1234 void LayerTreeHostImpl::NotifyReadyToActivate() { |
1233 client_->NotifyReadyToActivate(); | 1235 client_->NotifyReadyToActivate(); |
(...skipping 2181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3415 } | 3417 } |
3416 | 3418 |
3417 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3419 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3418 std::vector<PictureLayerImpl*>::iterator it = | 3420 std::vector<PictureLayerImpl*>::iterator it = |
3419 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3421 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3420 DCHECK(it != picture_layers_.end()); | 3422 DCHECK(it != picture_layers_.end()); |
3421 picture_layers_.erase(it); | 3423 picture_layers_.erase(it); |
3422 } | 3424 } |
3423 | 3425 |
3424 } // namespace cc | 3426 } // namespace cc |
OLD | NEW |