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 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1176 active_tree_->DetachLayerTree(); | 1176 active_tree_->DetachLayerTree(); |
1177 active_tree_ = LayerTreeImpl::create(this); | 1177 active_tree_ = LayerTreeImpl::create(this); |
1178 if (pending_tree_) | 1178 if (pending_tree_) |
1179 pending_tree_->DetachLayerTree(); | 1179 pending_tree_->DetachLayerTree(); |
1180 pending_tree_ = nullptr; | 1180 pending_tree_ = nullptr; |
1181 if (recycle_tree_) | 1181 if (recycle_tree_) |
1182 recycle_tree_->DetachLayerTree(); | 1182 recycle_tree_->DetachLayerTree(); |
1183 recycle_tree_ = nullptr; | 1183 recycle_tree_ = nullptr; |
1184 } | 1184 } |
1185 | 1185 |
| 1186 void LayerTreeHostImpl::ResetRecycleTreeForTesting() { |
| 1187 if (recycle_tree_) |
| 1188 recycle_tree_->DetachLayerTree(); |
| 1189 recycle_tree_ = nullptr; |
| 1190 } |
| 1191 |
1186 void LayerTreeHostImpl::EnforceManagedMemoryPolicy( | 1192 void LayerTreeHostImpl::EnforceManagedMemoryPolicy( |
1187 const ManagedMemoryPolicy& policy) { | 1193 const ManagedMemoryPolicy& policy) { |
1188 | 1194 |
1189 bool evicted_resources = client_->ReduceContentsTextureMemoryOnImplThread( | 1195 bool evicted_resources = client_->ReduceContentsTextureMemoryOnImplThread( |
1190 visible_ ? policy.bytes_limit_when_visible : 0, | 1196 visible_ ? policy.bytes_limit_when_visible : 0, |
1191 ManagedMemoryPolicy::PriorityCutoffToValue( | 1197 ManagedMemoryPolicy::PriorityCutoffToValue( |
1192 visible_ ? policy.priority_cutoff_when_visible | 1198 visible_ ? policy.priority_cutoff_when_visible |
1193 : gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING)); | 1199 : gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING)); |
1194 if (evicted_resources) { | 1200 if (evicted_resources) { |
1195 active_tree_->SetContentsTexturesPurged(); | 1201 active_tree_->SetContentsTexturesPurged(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 for (std::vector<PictureLayerImpl*>::const_iterator it = | 1279 for (std::vector<PictureLayerImpl*>::const_iterator it = |
1274 picture_layers_.begin(); | 1280 picture_layers_.begin(); |
1275 it != picture_layers_.end(); | 1281 it != picture_layers_.end(); |
1276 ++it) { | 1282 ++it) { |
1277 PictureLayerImpl* layer = *it; | 1283 PictureLayerImpl* layer = *it; |
1278 | 1284 |
1279 // TODO(vmpstr): Iterators and should handle this instead. crbug.com/381704 | 1285 // TODO(vmpstr): Iterators and should handle this instead. crbug.com/381704 |
1280 if (!layer->HasValidTilePriorities()) | 1286 if (!layer->HasValidTilePriorities()) |
1281 continue; | 1287 continue; |
1282 | 1288 |
1283 PictureLayerImpl* twin_layer = layer->GetPendingOrActiveTwinLayer(); | 1289 PictureLayerImpl* twin_layer = layer->GetTwinLayer(); |
1284 | 1290 |
1285 // Ignore the twin layer when tile priorities are invalid. | 1291 // Ignore the twin layer when tile priorities are invalid. |
1286 // TODO(vmpstr): Iterators should handle this instead. crbug.com/381704 | 1292 // TODO(vmpstr): Iterators should handle this instead. crbug.com/381704 |
1287 if (twin_layer && !twin_layer->HasValidTilePriorities()) | 1293 if (twin_layer && !twin_layer->HasValidTilePriorities()) |
1288 twin_layer = NULL; | 1294 twin_layer = NULL; |
1289 | 1295 |
1290 // If the current tree is ACTIVE_TREE, then always generate a layer_pair. | 1296 // If the current tree is ACTIVE_TREE, then always generate a layer_pair. |
1291 // If current tree is PENDING_TREE, then only generate a layer_pair if | 1297 // If current tree is PENDING_TREE, then only generate a layer_pair if |
1292 // there is no twin layer. | 1298 // there is no twin layer. |
1293 if (layer->GetTree() == ACTIVE_TREE) { | 1299 if (layer->GetTree() == ACTIVE_TREE) { |
(...skipping 2178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3472 } | 3478 } |
3473 | 3479 |
3474 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3480 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3475 std::vector<PictureLayerImpl*>::iterator it = | 3481 std::vector<PictureLayerImpl*>::iterator it = |
3476 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3482 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3477 DCHECK(it != picture_layers_.end()); | 3483 DCHECK(it != picture_layers_.end()); |
3478 picture_layers_.erase(it); | 3484 picture_layers_.erase(it); |
3479 } | 3485 } |
3480 | 3486 |
3481 } // namespace cc | 3487 } // namespace cc |
OLD | NEW |