| 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 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 | 929 |
| 930 DCHECK(pile_->HasRecordings()); | 930 DCHECK(pile_->HasRecordings()); |
| 931 | 931 |
| 932 if (twin_layer_) | 932 if (twin_layer_) |
| 933 twin_layer_->SyncTiling(tiling); | 933 twin_layer_->SyncTiling(tiling); |
| 934 | 934 |
| 935 return tiling; | 935 return tiling; |
| 936 } | 936 } |
| 937 | 937 |
| 938 void PictureLayerImpl::RemoveTiling(float contents_scale) { | 938 void PictureLayerImpl::RemoveTiling(float contents_scale) { |
| 939 if (!tilings_ || tilings_->num_tilings() == 0) |
| 940 return; |
| 941 |
| 939 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 942 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| 940 PictureLayerTiling* tiling = tilings_->tiling_at(i); | 943 PictureLayerTiling* tiling = tilings_->tiling_at(i); |
| 941 if (tiling->contents_scale() == contents_scale) { | 944 if (tiling->contents_scale() == contents_scale) { |
| 942 tilings_->Remove(tiling); | 945 tilings_->Remove(tiling); |
| 943 break; | 946 break; |
| 944 } | 947 } |
| 945 } | 948 } |
| 946 if (tilings_->num_tilings() == 0) | 949 if (tilings_->num_tilings() == 0) |
| 947 ResetRasterScale(); | 950 ResetRasterScale(); |
| 948 SanityCheckTilingState(); | 951 SanityCheckTilingState(); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 } | 1191 } |
| 1189 | 1192 |
| 1190 // Don't remove tilings that are being used (and thus would cause a flash.) | 1193 // 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) != | 1194 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) != |
| 1192 used_tilings.end()) | 1195 used_tilings.end()) |
| 1193 continue; | 1196 continue; |
| 1194 | 1197 |
| 1195 to_remove.push_back(tiling); | 1198 to_remove.push_back(tiling); |
| 1196 } | 1199 } |
| 1197 | 1200 |
| 1201 if (to_remove.empty()) |
| 1202 return; |
| 1203 |
| 1204 PictureLayerImpl* recycled_twin = static_cast<PictureLayerImpl*>( |
| 1205 layer_tree_impl()->FindRecycleTreeLayerById(id())); |
| 1206 // Remove tilings on this tree and the twin tree. |
| 1198 for (size_t i = 0; i < to_remove.size(); ++i) { | 1207 for (size_t i = 0; i < to_remove.size(); ++i) { |
| 1199 const PictureLayerTiling* twin_tiling = GetTwinTiling(to_remove[i]); | 1208 const PictureLayerTiling* twin_tiling = GetTwinTiling(to_remove[i]); |
| 1200 // Only remove tilings from the twin layer if they have | 1209 // Only remove tilings from the twin layer if they have |
| 1201 // NON_IDEAL_RESOLUTION. | 1210 // NON_IDEAL_RESOLUTION. |
| 1202 if (twin_tiling && twin_tiling->resolution() == NON_IDEAL_RESOLUTION) | 1211 if (twin_tiling && twin_tiling->resolution() == NON_IDEAL_RESOLUTION) |
| 1203 twin->RemoveTiling(to_remove[i]->contents_scale()); | 1212 twin->RemoveTiling(to_remove[i]->contents_scale()); |
| 1213 // Remove the tiling from the recycle tree. Note that we ignore resolution, |
| 1214 // since we don't need to maintain high/low res on the recycle tree. |
| 1215 if (recycled_twin) |
| 1216 recycled_twin->RemoveTiling(to_remove[i]->contents_scale()); |
| 1204 // TODO(enne): temporary sanity CHECK for http://crbug.com/358350 | 1217 // TODO(enne): temporary sanity CHECK for http://crbug.com/358350 |
| 1205 CHECK_NE(HIGH_RESOLUTION, to_remove[i]->resolution()); | 1218 CHECK_NE(HIGH_RESOLUTION, to_remove[i]->resolution()); |
| 1206 tilings_->Remove(to_remove[i]); | 1219 tilings_->Remove(to_remove[i]); |
| 1207 } | 1220 } |
| 1221 |
| 1208 DCHECK_GT(tilings_->num_tilings(), 0u); | 1222 DCHECK_GT(tilings_->num_tilings(), 0u); |
| 1209 | |
| 1210 SanityCheckTilingState(); | 1223 SanityCheckTilingState(); |
| 1211 } | 1224 } |
| 1212 | 1225 |
| 1213 float PictureLayerImpl::MinimumContentsScale() const { | 1226 float PictureLayerImpl::MinimumContentsScale() const { |
| 1214 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; | 1227 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; |
| 1215 | 1228 |
| 1216 // If the contents scale is less than 1 / width (also for height), | 1229 // 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 | 1230 // 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 | 1231 // dimension. Bump the minimum contents scale up in this case to prevent |
| 1219 // this from happening. | 1232 // this from happening. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1248 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { | 1261 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { |
| 1249 if (!CanHaveTilings()) | 1262 if (!CanHaveTilings()) |
| 1250 return false; | 1263 return false; |
| 1251 if (contents_scale < MinimumContentsScale()) | 1264 if (contents_scale < MinimumContentsScale()) |
| 1252 return false; | 1265 return false; |
| 1253 return true; | 1266 return true; |
| 1254 } | 1267 } |
| 1255 | 1268 |
| 1256 void PictureLayerImpl::SanityCheckTilingState() const { | 1269 void PictureLayerImpl::SanityCheckTilingState() const { |
| 1257 #if DCHECK_IS_ON | 1270 #if DCHECK_IS_ON |
| 1271 // Recycle tree doesn't have any restrictions. |
| 1272 if (layer_tree_impl()->IsRecycleTree()) |
| 1273 return; |
| 1274 |
| 1258 if (!CanHaveTilings()) { | 1275 if (!CanHaveTilings()) { |
| 1259 DCHECK_EQ(0u, tilings_->num_tilings()); | 1276 DCHECK_EQ(0u, tilings_->num_tilings()); |
| 1260 return; | 1277 return; |
| 1261 } | 1278 } |
| 1262 if (tilings_->num_tilings() == 0) | 1279 if (tilings_->num_tilings() == 0) |
| 1263 return; | 1280 return; |
| 1264 | 1281 |
| 1265 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res | 1282 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res |
| 1266 // tiling to mark its tiles as being required for activation. | 1283 // tiling to mark its tiles as being required for activation. |
| 1267 DCHECK_EQ(1, tilings_->NumHighResTilings()); | 1284 DCHECK_EQ(1, tilings_->NumHighResTilings()); |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1629 return iterator_index_ < iterators_.size(); | 1646 return iterator_index_ < iterators_.size(); |
| 1630 } | 1647 } |
| 1631 | 1648 |
| 1632 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1649 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
| 1633 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1650 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
| 1634 return it->get_type() == iteration_stage_ && | 1651 return it->get_type() == iteration_stage_ && |
| 1635 (**it)->required_for_activation() == required_for_activation_; | 1652 (**it)->required_for_activation() == required_for_activation_; |
| 1636 } | 1653 } |
| 1637 | 1654 |
| 1638 } // namespace cc | 1655 } // namespace cc |
| OLD | NEW |