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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 // that this is at the expense of doing cause more frequent re-painting. A | 384 // that this is at the expense of doing cause more frequent re-painting. A |
385 // better scheme would be to maintain a tighter visible_content_rect for the | 385 // better scheme would be to maintain a tighter visible_content_rect for the |
386 // finer tilings. | 386 // finer tilings. |
387 CleanUpTilingsOnActiveLayer(seen_tilings); | 387 CleanUpTilingsOnActiveLayer(seen_tilings); |
388 } | 388 } |
389 | 389 |
390 void PictureLayerImpl::UpdateTilePriorities() { | 390 void PictureLayerImpl::UpdateTilePriorities() { |
391 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); | 391 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); |
392 | 392 |
393 DoPostCommitInitializationIfNeeded(); | 393 DoPostCommitInitializationIfNeeded(); |
394 UpdateIdealScales(); | |
395 // TODO(sohanjg): Avoid needlessly update priorities when syncing to a | |
396 // non-updated tree which will then be updated immediately afterwards. | |
397 should_update_tile_priorities_ = true; | |
398 if (CanHaveTilings()) { | |
399 ManageTilings(draw_properties().screen_space_transform_is_animating, | |
400 draw_properties().maximum_animation_contents_scale); | |
401 } | |
402 | 394 |
403 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { | 395 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { |
404 visible_rect_for_tile_priority_ = visible_content_rect(); | 396 visible_rect_for_tile_priority_ = visible_content_rect(); |
405 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); | 397 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); |
406 screen_space_transform_for_tile_priority_ = screen_space_transform(); | 398 screen_space_transform_for_tile_priority_ = screen_space_transform(); |
407 } | 399 } |
408 | 400 |
| 401 if (!CanHaveTilings()) { |
| 402 ideal_page_scale_ = 0.f; |
| 403 ideal_device_scale_ = 0.f; |
| 404 ideal_contents_scale_ = 0.f; |
| 405 ideal_source_scale_ = 0.f; |
| 406 SanityCheckTilingState(); |
| 407 return; |
| 408 } |
| 409 |
| 410 // TODO(sohanjg): Avoid needlessly update priorities when syncing to a |
| 411 // non-updated tree which will then be updated immediately afterwards. |
| 412 should_update_tile_priorities_ = true; |
| 413 |
| 414 UpdateIdealScales(); |
| 415 ManageTilings(draw_properties().screen_space_transform_is_animating, |
| 416 draw_properties().maximum_animation_contents_scale); |
| 417 |
409 if (!tilings_->num_tilings()) | 418 if (!tilings_->num_tilings()) |
410 return; | 419 return; |
411 | 420 |
412 double current_frame_time_in_seconds = | 421 double current_frame_time_in_seconds = |
413 (layer_tree_impl()->CurrentFrameTimeTicks() - | 422 (layer_tree_impl()->CurrentFrameTimeTicks() - |
414 base::TimeTicks()).InSecondsF(); | 423 base::TimeTicks()).InSecondsF(); |
415 | 424 |
416 bool tiling_needs_update = false; | 425 bool tiling_needs_update = false; |
417 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 426 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
418 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( | 427 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 if (tilings_->num_tilings() == 0) | 1152 if (tilings_->num_tilings() == 0) |
1144 return; | 1153 return; |
1145 | 1154 |
1146 float min_acceptable_high_res_scale = std::min( | 1155 float min_acceptable_high_res_scale = std::min( |
1147 raster_contents_scale_, ideal_contents_scale_); | 1156 raster_contents_scale_, ideal_contents_scale_); |
1148 float max_acceptable_high_res_scale = std::max( | 1157 float max_acceptable_high_res_scale = std::max( |
1149 raster_contents_scale_, ideal_contents_scale_); | 1158 raster_contents_scale_, ideal_contents_scale_); |
1150 float twin_low_res_scale = 0.f; | 1159 float twin_low_res_scale = 0.f; |
1151 | 1160 |
1152 PictureLayerImpl* twin = twin_layer_; | 1161 PictureLayerImpl* twin = twin_layer_; |
1153 if (twin) { | 1162 if (twin && twin->CanHaveTilings()) { |
1154 min_acceptable_high_res_scale = std::min( | 1163 min_acceptable_high_res_scale = std::min( |
1155 min_acceptable_high_res_scale, | 1164 min_acceptable_high_res_scale, |
1156 std::min(twin->raster_contents_scale_, twin->ideal_contents_scale_)); | 1165 std::min(twin->raster_contents_scale_, twin->ideal_contents_scale_)); |
1157 max_acceptable_high_res_scale = std::max( | 1166 max_acceptable_high_res_scale = std::max( |
1158 max_acceptable_high_res_scale, | 1167 max_acceptable_high_res_scale, |
1159 std::max(twin->raster_contents_scale_, twin->ideal_contents_scale_)); | 1168 std::max(twin->raster_contents_scale_, twin->ideal_contents_scale_)); |
1160 | 1169 |
1161 for (size_t i = 0; i < twin->tilings_->num_tilings(); ++i) { | 1170 for (size_t i = 0; i < twin->tilings_->num_tilings(); ++i) { |
1162 PictureLayerTiling* tiling = twin->tilings_->tiling_at(i); | 1171 PictureLayerTiling* tiling = twin->tilings_->tiling_at(i); |
1163 if (tiling->resolution() == LOW_RESOLUTION) | 1172 if (tiling->resolution() == LOW_RESOLUTION) |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 float PictureLayerImpl::MaximumTilingContentsScale() const { | 1275 float PictureLayerImpl::MaximumTilingContentsScale() const { |
1267 float max_contents_scale = MinimumContentsScale(); | 1276 float max_contents_scale = MinimumContentsScale(); |
1268 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 1277 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
1269 const PictureLayerTiling* tiling = tilings_->tiling_at(i); | 1278 const PictureLayerTiling* tiling = tilings_->tiling_at(i); |
1270 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); | 1279 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); |
1271 } | 1280 } |
1272 return max_contents_scale; | 1281 return max_contents_scale; |
1273 } | 1282 } |
1274 | 1283 |
1275 void PictureLayerImpl::UpdateIdealScales() { | 1284 void PictureLayerImpl::UpdateIdealScales() { |
1276 if (!CanHaveTilings()) { | 1285 DCHECK(CanHaveTilings()); |
1277 ideal_page_scale_ = draw_properties().page_scale_factor; | |
1278 ideal_device_scale_ = draw_properties().device_scale_factor; | |
1279 ideal_contents_scale_ = draw_properties().ideal_contents_scale; | |
1280 ideal_source_scale_ = | |
1281 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_; | |
1282 return; | |
1283 } | |
1284 | 1286 |
1285 float min_contents_scale = MinimumContentsScale(); | 1287 float min_contents_scale = MinimumContentsScale(); |
1286 DCHECK_GT(min_contents_scale, 0.f); | 1288 DCHECK_GT(min_contents_scale, 0.f); |
1287 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); | 1289 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); |
1288 DCHECK_GT(min_page_scale, 0.f); | 1290 DCHECK_GT(min_page_scale, 0.f); |
1289 float min_device_scale = 1.f; | 1291 float min_device_scale = 1.f; |
1290 float min_source_scale = | 1292 float min_source_scale = |
1291 min_contents_scale / min_page_scale / min_device_scale; | 1293 min_contents_scale / min_page_scale / min_device_scale; |
1292 | 1294 |
1293 float ideal_page_scale = draw_properties().page_scale_factor; | 1295 float ideal_page_scale = draw_properties().page_scale_factor; |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1622 return iterator_index_ < iterators_.size(); | 1624 return iterator_index_ < iterators_.size(); |
1623 } | 1625 } |
1624 | 1626 |
1625 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1627 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1626 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1628 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1627 return it->get_type() == iteration_stage_ && | 1629 return it->get_type() == iteration_stage_ && |
1628 (**it)->required_for_activation() == required_for_activation_; | 1630 (**it)->required_for_activation() == required_for_activation_; |
1629 } | 1631 } |
1630 | 1632 |
1631 } // namespace cc | 1633 } // namespace cc |
OLD | NEW |