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 } | |
401 | 393 |
402 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { | 394 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { |
403 visible_rect_for_tile_priority_ = visible_content_rect(); | 395 visible_rect_for_tile_priority_ = visible_content_rect(); |
404 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); | 396 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); |
405 screen_space_transform_for_tile_priority_ = screen_space_transform(); | 397 screen_space_transform_for_tile_priority_ = screen_space_transform(); |
406 } | 398 } |
407 | 399 |
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 | |
408 if (!tilings_->num_tilings()) | 417 if (!tilings_->num_tilings()) |
409 return; | 418 return; |
410 | 419 |
411 double current_frame_time_in_seconds = | 420 double current_frame_time_in_seconds = |
412 (layer_tree_impl()->CurrentFrameTimeTicks() - | 421 (layer_tree_impl()->CurrentFrameTimeTicks() - |
413 base::TimeTicks()).InSecondsF(); | 422 base::TimeTicks()).InSecondsF(); |
414 | 423 |
415 bool tiling_needs_update = false; | 424 bool tiling_needs_update = false; |
416 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 425 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
417 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( | 426 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1158 if (tilings_->num_tilings() == 0) | 1167 if (tilings_->num_tilings() == 0) |
1159 return; | 1168 return; |
1160 | 1169 |
1161 float min_acceptable_high_res_scale = std::min( | 1170 float min_acceptable_high_res_scale = std::min( |
1162 raster_contents_scale_, ideal_contents_scale_); | 1171 raster_contents_scale_, ideal_contents_scale_); |
1163 float max_acceptable_high_res_scale = std::max( | 1172 float max_acceptable_high_res_scale = std::max( |
1164 raster_contents_scale_, ideal_contents_scale_); | 1173 raster_contents_scale_, ideal_contents_scale_); |
1165 float twin_low_res_scale = 0.f; | 1174 float twin_low_res_scale = 0.f; |
1166 | 1175 |
1167 PictureLayerImpl* twin = twin_layer_; | 1176 PictureLayerImpl* twin = twin_layer_; |
1168 if (twin) { | 1177 if (twin && twin->CanHaveTilings()) { |
1169 min_acceptable_high_res_scale = std::min( | 1178 min_acceptable_high_res_scale = std::min( |
1170 min_acceptable_high_res_scale, | 1179 min_acceptable_high_res_scale, |
1171 std::min(twin->raster_contents_scale_, twin->ideal_contents_scale_)); | 1180 std::min(twin->raster_contents_scale_, twin->ideal_contents_scale_)); |
1172 max_acceptable_high_res_scale = std::max( | 1181 max_acceptable_high_res_scale = std::max( |
1173 max_acceptable_high_res_scale, | 1182 max_acceptable_high_res_scale, |
1174 std::max(twin->raster_contents_scale_, twin->ideal_contents_scale_)); | 1183 std::max(twin->raster_contents_scale_, twin->ideal_contents_scale_)); |
1175 | 1184 |
1176 for (size_t i = 0; i < twin->tilings_->num_tilings(); ++i) { | 1185 for (size_t i = 0; i < twin->tilings_->num_tilings(); ++i) { |
1177 PictureLayerTiling* tiling = twin->tilings_->tiling_at(i); | 1186 PictureLayerTiling* tiling = twin->tilings_->tiling_at(i); |
1178 if (tiling->resolution() == LOW_RESOLUTION) | 1187 if (tiling->resolution() == LOW_RESOLUTION) |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1281 float PictureLayerImpl::MaximumTilingContentsScale() const { | 1290 float PictureLayerImpl::MaximumTilingContentsScale() const { |
1282 float max_contents_scale = MinimumContentsScale(); | 1291 float max_contents_scale = MinimumContentsScale(); |
1283 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 1292 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
1284 const PictureLayerTiling* tiling = tilings_->tiling_at(i); | 1293 const PictureLayerTiling* tiling = tilings_->tiling_at(i); |
1285 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); | 1294 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); |
1286 } | 1295 } |
1287 return max_contents_scale; | 1296 return max_contents_scale; |
1288 } | 1297 } |
1289 | 1298 |
1290 void PictureLayerImpl::UpdateIdealScales() { | 1299 void PictureLayerImpl::UpdateIdealScales() { |
1291 if (!CanHaveTilings()) { | |
enne (OOO)
2014/06/18 23:08:02
I kind of liked this code being in UpdateIdealScal
danakj
2014/06/19 01:03:52
ok, i can leave it there. I liked the idea of movi
| |
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 } | |
1299 | |
1300 float min_contents_scale = MinimumContentsScale(); | 1300 float min_contents_scale = MinimumContentsScale(); |
1301 DCHECK_GT(min_contents_scale, 0.f); | 1301 DCHECK_GT(min_contents_scale, 0.f); |
1302 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); | 1302 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); |
1303 DCHECK_GT(min_page_scale, 0.f); | 1303 DCHECK_GT(min_page_scale, 0.f); |
1304 float min_device_scale = 1.f; | 1304 float min_device_scale = 1.f; |
1305 float min_source_scale = | 1305 float min_source_scale = |
1306 min_contents_scale / min_page_scale / min_device_scale; | 1306 min_contents_scale / min_page_scale / min_device_scale; |
1307 | 1307 |
1308 float ideal_page_scale = draw_properties().page_scale_factor; | 1308 float ideal_page_scale = draw_properties().page_scale_factor; |
1309 float ideal_device_scale = draw_properties().device_scale_factor; | 1309 float ideal_device_scale = draw_properties().device_scale_factor; |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1637 return iterator_index_ < iterators_.size(); | 1637 return iterator_index_ < iterators_.size(); |
1638 } | 1638 } |
1639 | 1639 |
1640 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1640 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1641 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1641 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1642 return it->get_type() == iteration_stage_ && | 1642 return it->get_type() == iteration_stage_ && |
1643 (**it)->required_for_activation() == required_for_activation_; | 1643 (**it)->required_for_activation() == required_for_activation_; |
1644 } | 1644 } |
1645 | 1645 |
1646 } // namespace cc | 1646 } // namespace cc |
OLD | NEW |