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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 // that this is at the expense of doing cause more frequent re-painting. A | 383 // that this is at the expense of doing cause more frequent re-painting. A |
384 // better scheme would be to maintain a tighter visible_content_rect for the | 384 // better scheme would be to maintain a tighter visible_content_rect for the |
385 // finer tilings. | 385 // finer tilings. |
386 CleanUpTilingsOnActiveLayer(seen_tilings); | 386 CleanUpTilingsOnActiveLayer(seen_tilings); |
387 } | 387 } |
388 | 388 |
389 void PictureLayerImpl::UpdateTilePriorities() { | 389 void PictureLayerImpl::UpdateTilePriorities() { |
390 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); | 390 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); |
391 | 391 |
392 DoPostCommitInitializationIfNeeded(); | 392 DoPostCommitInitializationIfNeeded(); |
| 393 UpdateIdealScales(); |
| 394 // TODO(sohanjg): Avoid needlessly update priorities when syncing to a |
| 395 // non-updated tree which will then be updated immediately afterwards. |
| 396 should_update_tile_priorities_ = true; |
| 397 if (CanHaveTilings()) { |
| 398 ManageTilings(draw_properties().screen_space_transform_is_animating, |
| 399 draw_properties().maximum_animation_contents_scale); |
| 400 } |
393 | 401 |
394 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { | 402 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { |
395 visible_rect_for_tile_priority_ = visible_content_rect(); | 403 visible_rect_for_tile_priority_ = visible_content_rect(); |
396 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); | 404 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); |
397 screen_space_transform_for_tile_priority_ = screen_space_transform(); | 405 screen_space_transform_for_tile_priority_ = screen_space_transform(); |
398 } | 406 } |
399 | 407 |
400 if (!CanHaveTilings()) { | |
401 ideal_page_scale_ = 0.f; | |
402 ideal_device_scale_ = 0.f; | |
403 ideal_contents_scale_ = 0.f; | |
404 ideal_source_scale_ = 0.f; | |
405 SanityCheckTilingState(); | |
406 return; | |
407 } | |
408 | |
409 // TODO(sohanjg): Avoid needlessly update priorities when syncing to a | |
410 // non-updated tree which will then be updated immediately afterwards. | |
411 should_update_tile_priorities_ = true; | |
412 | |
413 UpdateIdealScales(); | |
414 ManageTilings(draw_properties().screen_space_transform_is_animating, | |
415 draw_properties().maximum_animation_contents_scale); | |
416 | |
417 if (!tilings_->num_tilings()) | 408 if (!tilings_->num_tilings()) |
418 return; | 409 return; |
419 | 410 |
420 double current_frame_time_in_seconds = | 411 double current_frame_time_in_seconds = |
421 (layer_tree_impl()->CurrentFrameTimeTicks() - | 412 (layer_tree_impl()->CurrentFrameTimeTicks() - |
422 base::TimeTicks()).InSecondsF(); | 413 base::TimeTicks()).InSecondsF(); |
423 | 414 |
424 bool tiling_needs_update = false; | 415 bool tiling_needs_update = false; |
425 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 416 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
426 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( | 417 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 if (tilings_->num_tilings() == 0) | 1158 if (tilings_->num_tilings() == 0) |
1168 return; | 1159 return; |
1169 | 1160 |
1170 float min_acceptable_high_res_scale = std::min( | 1161 float min_acceptable_high_res_scale = std::min( |
1171 raster_contents_scale_, ideal_contents_scale_); | 1162 raster_contents_scale_, ideal_contents_scale_); |
1172 float max_acceptable_high_res_scale = std::max( | 1163 float max_acceptable_high_res_scale = std::max( |
1173 raster_contents_scale_, ideal_contents_scale_); | 1164 raster_contents_scale_, ideal_contents_scale_); |
1174 float twin_low_res_scale = 0.f; | 1165 float twin_low_res_scale = 0.f; |
1175 | 1166 |
1176 PictureLayerImpl* twin = twin_layer_; | 1167 PictureLayerImpl* twin = twin_layer_; |
1177 if (twin && twin->CanHaveTilings()) { | 1168 if (twin) { |
1178 min_acceptable_high_res_scale = std::min( | 1169 min_acceptable_high_res_scale = std::min( |
1179 min_acceptable_high_res_scale, | 1170 min_acceptable_high_res_scale, |
1180 std::min(twin->raster_contents_scale_, twin->ideal_contents_scale_)); | 1171 std::min(twin->raster_contents_scale_, twin->ideal_contents_scale_)); |
1181 max_acceptable_high_res_scale = std::max( | 1172 max_acceptable_high_res_scale = std::max( |
1182 max_acceptable_high_res_scale, | 1173 max_acceptable_high_res_scale, |
1183 std::max(twin->raster_contents_scale_, twin->ideal_contents_scale_)); | 1174 std::max(twin->raster_contents_scale_, twin->ideal_contents_scale_)); |
1184 | 1175 |
1185 for (size_t i = 0; i < twin->tilings_->num_tilings(); ++i) { | 1176 for (size_t i = 0; i < twin->tilings_->num_tilings(); ++i) { |
1186 PictureLayerTiling* tiling = twin->tilings_->tiling_at(i); | 1177 PictureLayerTiling* tiling = twin->tilings_->tiling_at(i); |
1187 if (tiling->resolution() == LOW_RESOLUTION) | 1178 if (tiling->resolution() == LOW_RESOLUTION) |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 float PictureLayerImpl::MaximumTilingContentsScale() const { | 1281 float PictureLayerImpl::MaximumTilingContentsScale() const { |
1291 float max_contents_scale = MinimumContentsScale(); | 1282 float max_contents_scale = MinimumContentsScale(); |
1292 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 1283 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
1293 const PictureLayerTiling* tiling = tilings_->tiling_at(i); | 1284 const PictureLayerTiling* tiling = tilings_->tiling_at(i); |
1294 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); | 1285 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); |
1295 } | 1286 } |
1296 return max_contents_scale; | 1287 return max_contents_scale; |
1297 } | 1288 } |
1298 | 1289 |
1299 void PictureLayerImpl::UpdateIdealScales() { | 1290 void PictureLayerImpl::UpdateIdealScales() { |
1300 DCHECK(CanHaveTilings()); | 1291 if (!CanHaveTilings()) { |
| 1292 ideal_page_scale_ = draw_properties().page_scale_factor; |
| 1293 ideal_device_scale_ = draw_properties().device_scale_factor; |
| 1294 ideal_contents_scale_ = draw_properties().ideal_contents_scale; |
| 1295 ideal_source_scale_ = |
| 1296 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_; |
| 1297 return; |
| 1298 } |
1301 | 1299 |
1302 float min_contents_scale = MinimumContentsScale(); | 1300 float min_contents_scale = MinimumContentsScale(); |
1303 DCHECK_GT(min_contents_scale, 0.f); | 1301 DCHECK_GT(min_contents_scale, 0.f); |
1304 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); | 1302 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); |
1305 DCHECK_GT(min_page_scale, 0.f); | 1303 DCHECK_GT(min_page_scale, 0.f); |
1306 float min_device_scale = 1.f; | 1304 float min_device_scale = 1.f; |
1307 float min_source_scale = | 1305 float min_source_scale = |
1308 min_contents_scale / min_page_scale / min_device_scale; | 1306 min_contents_scale / min_page_scale / min_device_scale; |
1309 | 1307 |
1310 float ideal_page_scale = draw_properties().page_scale_factor; | 1308 float ideal_page_scale = draw_properties().page_scale_factor; |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1639 return iterator_index_ < iterators_.size(); | 1637 return iterator_index_ < iterators_.size(); |
1640 } | 1638 } |
1641 | 1639 |
1642 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1640 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1643 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1641 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1644 return it->get_type() == iteration_stage_ && | 1642 return it->get_type() == iteration_stage_ && |
1645 (**it)->required_for_activation() == required_for_activation_; | 1643 (**it)->required_for_activation() == required_for_activation_; |
1646 } | 1644 } |
1647 | 1645 |
1648 } // namespace cc | 1646 } // namespace cc |
OLD | NEW |