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 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1194 } | 1194 } |
1195 | 1195 |
1196 // Don't remove tilings that are being used (and thus would cause a flash.) | 1196 // Don't remove tilings that are being used (and thus would cause a flash.) |
1197 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) != | 1197 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) != |
1198 used_tilings.end()) | 1198 used_tilings.end()) |
1199 continue; | 1199 continue; |
1200 | 1200 |
1201 to_remove.push_back(tiling); | 1201 to_remove.push_back(tiling); |
1202 } | 1202 } |
1203 | 1203 |
1204 if (to_remove.empty()) | |
1205 return; | |
1206 | |
1207 // Remove tilings on this tree and the twin tree. | |
1204 for (size_t i = 0; i < to_remove.size(); ++i) { | 1208 for (size_t i = 0; i < to_remove.size(); ++i) { |
1205 const PictureLayerTiling* twin_tiling = GetTwinTiling(to_remove[i]); | 1209 const PictureLayerTiling* twin_tiling = GetTwinTiling(to_remove[i]); |
1206 // Only remove tilings from the twin layer if they have | 1210 // Only remove tilings from the twin layer if they have |
1207 // NON_IDEAL_RESOLUTION. | 1211 // NON_IDEAL_RESOLUTION. |
1208 if (twin_tiling && twin_tiling->resolution() == NON_IDEAL_RESOLUTION) | 1212 if (twin_tiling && twin_tiling->resolution() == NON_IDEAL_RESOLUTION) |
1209 twin->RemoveTiling(to_remove[i]->contents_scale()); | 1213 twin->RemoveTiling(to_remove[i]->contents_scale()); |
1210 // TODO(enne): temporary sanity CHECK for http://crbug.com/358350 | 1214 // TODO(enne): temporary sanity CHECK for http://crbug.com/358350 |
1211 CHECK_NE(HIGH_RESOLUTION, to_remove[i]->resolution()); | 1215 CHECK_NE(HIGH_RESOLUTION, to_remove[i]->resolution()); |
1212 tilings_->Remove(to_remove[i]); | 1216 tilings_->Remove(to_remove[i]); |
1213 } | 1217 } |
1218 | |
1214 DCHECK_GT(tilings_->num_tilings(), 0u); | 1219 DCHECK_GT(tilings_->num_tilings(), 0u); |
1220 SanityCheckTilingState(); | |
1215 | 1221 |
1216 SanityCheckTilingState(); | 1222 // Also remove tilings from the recycle tree to ensure that recycle tree |
1223 // doesn't have any unshared tiles. | |
1224 PictureLayerImpl* recycled_twin = static_cast<PictureLayerImpl*>( | |
1225 layer_tree_impl()->FindRecycleTreeLayerById(id())); | |
1226 if (!recycled_twin) | |
1227 return; | |
1228 | |
1229 for (size_t i = 0; i < to_remove.size(); ++i) | |
1230 recycled_twin->RemoveTiling(to_remove[i]->contents_scale()); | |
danakj
2014/07/17 22:22:49
er, wait, to_remove[i] is a use-after-free here, c
vmpstr
2014/07/17 22:30:59
Hmm.. that's not good. Good thing my testing worke
| |
1217 } | 1231 } |
1218 | 1232 |
1219 float PictureLayerImpl::MinimumContentsScale() const { | 1233 float PictureLayerImpl::MinimumContentsScale() const { |
1220 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; | 1234 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; |
1221 | 1235 |
1222 // If the contents scale is less than 1 / width (also for height), | 1236 // If the contents scale is less than 1 / width (also for height), |
1223 // then it will end up having less than one pixel of content in that | 1237 // then it will end up having less than one pixel of content in that |
1224 // dimension. Bump the minimum contents scale up in this case to prevent | 1238 // dimension. Bump the minimum contents scale up in this case to prevent |
1225 // this from happening. | 1239 // this from happening. |
1226 int min_dimension = std::min(bounds().width(), bounds().height()); | 1240 int min_dimension = std::min(bounds().width(), bounds().height()); |
(...skipping 27 matching lines...) Expand all Loading... | |
1254 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { | 1268 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { |
1255 if (!CanHaveTilings()) | 1269 if (!CanHaveTilings()) |
1256 return false; | 1270 return false; |
1257 if (contents_scale < MinimumContentsScale()) | 1271 if (contents_scale < MinimumContentsScale()) |
1258 return false; | 1272 return false; |
1259 return true; | 1273 return true; |
1260 } | 1274 } |
1261 | 1275 |
1262 void PictureLayerImpl::SanityCheckTilingState() const { | 1276 void PictureLayerImpl::SanityCheckTilingState() const { |
1263 #if DCHECK_IS_ON | 1277 #if DCHECK_IS_ON |
1278 // Recycle tree doesn't have any restrictions. | |
1279 if (layer_tree_impl()->IsRecycleTree()) | |
1280 return; | |
1281 | |
1264 if (!CanHaveTilings()) { | 1282 if (!CanHaveTilings()) { |
1265 DCHECK_EQ(0u, tilings_->num_tilings()); | 1283 DCHECK_EQ(0u, tilings_->num_tilings()); |
1266 return; | 1284 return; |
1267 } | 1285 } |
1268 if (tilings_->num_tilings() == 0) | 1286 if (tilings_->num_tilings() == 0) |
1269 return; | 1287 return; |
1270 | 1288 |
1271 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res | 1289 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res |
1272 // tiling to mark its tiles as being required for activation. | 1290 // tiling to mark its tiles as being required for activation. |
1273 DCHECK_EQ(1, tilings_->NumHighResTilings()); | 1291 DCHECK_EQ(1, tilings_->NumHighResTilings()); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1635 return iterator_index_ < iterators_.size(); | 1653 return iterator_index_ < iterators_.size(); |
1636 } | 1654 } |
1637 | 1655 |
1638 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1656 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1639 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1657 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1640 return it->get_type() == iteration_stage_ && | 1658 return it->get_type() == iteration_stage_ && |
1641 (**it)->required_for_activation() == required_for_activation_; | 1659 (**it)->required_for_activation() == required_for_activation_; |
1642 } | 1660 } |
1643 | 1661 |
1644 } // namespace cc | 1662 } // namespace cc |
OLD | NEW |