OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 } | 1188 } |
1189 | 1189 |
1190 // Don't remove tilings that are being used (and thus would cause a flash.) | 1190 // Don't remove tilings that are being used (and thus would cause a flash.) |
1191 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) != | 1191 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) != |
1192 used_tilings.end()) | 1192 used_tilings.end()) |
1193 continue; | 1193 continue; |
1194 | 1194 |
1195 to_remove.push_back(tiling); | 1195 to_remove.push_back(tiling); |
1196 } | 1196 } |
1197 | 1197 |
| 1198 if (to_remove.empty()) |
| 1199 return; |
| 1200 |
| 1201 PictureLayerImpl* recycled_twin = static_cast<PictureLayerImpl*>( |
| 1202 layer_tree_impl()->FindRecycleTreeLayerById(id())); |
| 1203 // Remove tilings on this tree and the twin tree. |
1198 for (size_t i = 0; i < to_remove.size(); ++i) { | 1204 for (size_t i = 0; i < to_remove.size(); ++i) { |
1199 const PictureLayerTiling* twin_tiling = GetTwinTiling(to_remove[i]); | 1205 const PictureLayerTiling* twin_tiling = GetTwinTiling(to_remove[i]); |
1200 // Only remove tilings from the twin layer if they have | 1206 // Only remove tilings from the twin layer if they have |
1201 // NON_IDEAL_RESOLUTION. | 1207 // NON_IDEAL_RESOLUTION. |
1202 if (twin_tiling && twin_tiling->resolution() == NON_IDEAL_RESOLUTION) | 1208 if (twin_tiling && twin_tiling->resolution() == NON_IDEAL_RESOLUTION) |
1203 twin->RemoveTiling(to_remove[i]->contents_scale()); | 1209 twin->RemoveTiling(to_remove[i]->contents_scale()); |
| 1210 // Remove the tiling from the recycle tree. Note that we ignore resolution, |
| 1211 // since we don't need to maintain high/low res on the recycle tree. |
| 1212 if (recycled_twin) |
| 1213 recycled_twin->RemoveTiling(to_remove[i]->contents_scale()); |
1204 // TODO(enne): temporary sanity CHECK for http://crbug.com/358350 | 1214 // TODO(enne): temporary sanity CHECK for http://crbug.com/358350 |
1205 CHECK_NE(HIGH_RESOLUTION, to_remove[i]->resolution()); | 1215 CHECK_NE(HIGH_RESOLUTION, to_remove[i]->resolution()); |
1206 tilings_->Remove(to_remove[i]); | 1216 tilings_->Remove(to_remove[i]); |
1207 } | 1217 } |
| 1218 |
1208 DCHECK_GT(tilings_->num_tilings(), 0u); | 1219 DCHECK_GT(tilings_->num_tilings(), 0u); |
1209 | |
1210 SanityCheckTilingState(); | 1220 SanityCheckTilingState(); |
1211 } | 1221 } |
1212 | 1222 |
1213 float PictureLayerImpl::MinimumContentsScale() const { | 1223 float PictureLayerImpl::MinimumContentsScale() const { |
1214 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; | 1224 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; |
1215 | 1225 |
1216 // If the contents scale is less than 1 / width (also for height), | 1226 // If the contents scale is less than 1 / width (also for height), |
1217 // then it will end up having less than one pixel of content in that | 1227 // then it will end up having less than one pixel of content in that |
1218 // dimension. Bump the minimum contents scale up in this case to prevent | 1228 // dimension. Bump the minimum contents scale up in this case to prevent |
1219 // this from happening. | 1229 // this from happening. |
(...skipping 28 matching lines...) Expand all Loading... |
1248 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { | 1258 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { |
1249 if (!CanHaveTilings()) | 1259 if (!CanHaveTilings()) |
1250 return false; | 1260 return false; |
1251 if (contents_scale < MinimumContentsScale()) | 1261 if (contents_scale < MinimumContentsScale()) |
1252 return false; | 1262 return false; |
1253 return true; | 1263 return true; |
1254 } | 1264 } |
1255 | 1265 |
1256 void PictureLayerImpl::SanityCheckTilingState() const { | 1266 void PictureLayerImpl::SanityCheckTilingState() const { |
1257 #if DCHECK_IS_ON | 1267 #if DCHECK_IS_ON |
| 1268 // Recycle tree doesn't have any restrictions. |
| 1269 if (layer_tree_impl()->IsRecycleTree()) |
| 1270 return; |
| 1271 |
1258 if (!CanHaveTilings()) { | 1272 if (!CanHaveTilings()) { |
1259 DCHECK_EQ(0u, tilings_->num_tilings()); | 1273 DCHECK_EQ(0u, tilings_->num_tilings()); |
1260 return; | 1274 return; |
1261 } | 1275 } |
1262 if (tilings_->num_tilings() == 0) | 1276 if (tilings_->num_tilings() == 0) |
1263 return; | 1277 return; |
1264 | 1278 |
1265 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res | 1279 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res |
1266 // tiling to mark its tiles as being required for activation. | 1280 // tiling to mark its tiles as being required for activation. |
1267 DCHECK_EQ(1, tilings_->NumHighResTilings()); | 1281 DCHECK_EQ(1, tilings_->NumHighResTilings()); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1629 return iterator_index_ < iterators_.size(); | 1643 return iterator_index_ < iterators_.size(); |
1630 } | 1644 } |
1631 | 1645 |
1632 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1646 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1633 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1647 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1634 return it->get_type() == iteration_stage_ && | 1648 return it->get_type() == iteration_stage_ && |
1635 (**it)->required_for_activation() == required_for_activation_; | 1649 (**it)->required_for_activation() == required_for_activation_; |
1636 } | 1650 } |
1637 | 1651 |
1638 } // namespace cc | 1652 } // namespace cc |
OLD | NEW |