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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 ideal_contents_scale_(0.f), | 57 ideal_contents_scale_(0.f), |
58 raster_page_scale_(0.f), | 58 raster_page_scale_(0.f), |
59 raster_device_scale_(0.f), | 59 raster_device_scale_(0.f), |
60 raster_source_scale_(0.f), | 60 raster_source_scale_(0.f), |
61 raster_contents_scale_(0.f), | 61 raster_contents_scale_(0.f), |
62 low_res_raster_contents_scale_(0.f), | 62 low_res_raster_contents_scale_(0.f), |
63 raster_source_scale_is_fixed_(false), | 63 raster_source_scale_is_fixed_(false), |
64 was_animating_transform_to_screen_(false), | 64 was_animating_transform_to_screen_(false), |
65 is_using_lcd_text_(tree_impl->settings().can_use_lcd_text), | 65 is_using_lcd_text_(tree_impl->settings().can_use_lcd_text), |
66 needs_post_commit_initialization_(true), | 66 needs_post_commit_initialization_(true), |
67 should_update_tile_priorities_(false), | 67 should_update_tile_priorities_(false) { |
68 layer_needs_to_register_itself_(true) { | 68 layer_tree_impl()->RegisterPictureLayerImpl(this); |
69 } | 69 } |
70 | 70 |
71 PictureLayerImpl::~PictureLayerImpl() { | 71 PictureLayerImpl::~PictureLayerImpl() { |
72 if (!layer_needs_to_register_itself_) | 72 layer_tree_impl()->UnregisterPictureLayerImpl(this); |
73 layer_tree_impl()->tile_manager()->UnregisterPictureLayerImpl(this); | |
74 } | 73 } |
75 | 74 |
76 const char* PictureLayerImpl::LayerTypeAsString() const { | 75 const char* PictureLayerImpl::LayerTypeAsString() const { |
77 return "cc::PictureLayerImpl"; | 76 return "cc::PictureLayerImpl"; |
78 } | 77 } |
79 | 78 |
80 scoped_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl( | 79 scoped_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl( |
81 LayerTreeImpl* tree_impl) { | 80 LayerTreeImpl* tree_impl) { |
82 return PictureLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); | 81 return PictureLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); |
83 } | 82 } |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 on_demand_missing_tile_count); | 365 on_demand_missing_tile_count); |
367 } | 366 } |
368 | 367 |
369 // Aggressively remove any tilings that are not seen to save memory. Note | 368 // Aggressively remove any tilings that are not seen to save memory. Note |
370 // that this is at the expense of doing cause more frequent re-painting. A | 369 // that this is at the expense of doing cause more frequent re-painting. A |
371 // better scheme would be to maintain a tighter visible_content_rect for the | 370 // better scheme would be to maintain a tighter visible_content_rect for the |
372 // finer tilings. | 371 // finer tilings. |
373 CleanUpTilingsOnActiveLayer(seen_tilings); | 372 CleanUpTilingsOnActiveLayer(seen_tilings); |
374 } | 373 } |
375 | 374 |
376 void PictureLayerImpl::DidUnregisterLayer() { | |
377 TRACE_EVENT0("cc", "PictureLayerImpl::DidUnregisterLayer"); | |
378 | |
379 layer_needs_to_register_itself_ = true; | |
380 } | |
381 | |
382 void PictureLayerImpl::UpdateTilePriorities() { | 375 void PictureLayerImpl::UpdateTilePriorities() { |
383 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); | 376 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); |
384 | 377 |
385 DCHECK(!needs_post_commit_initialization_); | 378 DCHECK(!needs_post_commit_initialization_); |
386 CHECK(should_update_tile_priorities_); | 379 CHECK(should_update_tile_priorities_); |
387 | 380 |
388 if (layer_needs_to_register_itself_) { | |
389 layer_tree_impl()->tile_manager()->RegisterPictureLayerImpl(this); | |
390 layer_needs_to_register_itself_ = false; | |
391 } | |
392 | |
393 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { | 381 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { |
394 visible_rect_for_tile_priority_ = visible_content_rect(); | 382 visible_rect_for_tile_priority_ = visible_content_rect(); |
395 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); | 383 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); |
396 screen_space_transform_for_tile_priority_ = screen_space_transform(); | 384 screen_space_transform_for_tile_priority_ = screen_space_transform(); |
397 } | 385 } |
398 | 386 |
399 if (!tilings_->num_tilings()) | 387 if (!tilings_->num_tilings()) |
400 return; | 388 return; |
401 | 389 |
402 double current_frame_time_in_seconds = | 390 double current_frame_time_in_seconds = |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 } | 1386 } |
1399 | 1387 |
1400 WhichTree PictureLayerImpl::GetTree() const { | 1388 WhichTree PictureLayerImpl::GetTree() const { |
1401 return layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 1389 return layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
1402 } | 1390 } |
1403 | 1391 |
1404 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1392 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
1405 return !layer_tree_impl()->IsRecycleTree(); | 1393 return !layer_tree_impl()->IsRecycleTree(); |
1406 } | 1394 } |
1407 | 1395 |
| 1396 bool PictureLayerImpl::HasValidTilePriorities() const { |
| 1397 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
| 1398 } |
| 1399 |
1408 bool PictureLayerImpl::AllTilesRequiredForActivationAreReadyToDraw() const { | 1400 bool PictureLayerImpl::AllTilesRequiredForActivationAreReadyToDraw() const { |
1409 if (!layer_tree_impl()->IsPendingTree()) | 1401 if (!layer_tree_impl()->IsPendingTree()) |
1410 return true; | 1402 return true; |
1411 | 1403 |
| 1404 if (!HasValidTilePriorities()) |
| 1405 return true; |
| 1406 |
1412 if (!tilings_) | 1407 if (!tilings_) |
1413 return true; | 1408 return true; |
1414 | 1409 |
1415 if (visible_content_rect().IsEmpty()) | 1410 if (visible_content_rect().IsEmpty()) |
1416 return true; | 1411 return true; |
1417 | 1412 |
1418 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 1413 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
1419 PictureLayerTiling* tiling = tilings_->tiling_at(i); | 1414 PictureLayerTiling* tiling = tilings_->tiling_at(i); |
1420 if (tiling->resolution() != HIGH_RESOLUTION && | 1415 if (tiling->resolution() != HIGH_RESOLUTION && |
1421 tiling->resolution() != LOW_RESOLUTION) | 1416 tiling->resolution() != LOW_RESOLUTION) |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1655 return iterator_index_ < iterators_.size(); | 1650 return iterator_index_ < iterators_.size(); |
1656 } | 1651 } |
1657 | 1652 |
1658 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1653 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1659 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1654 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1660 return it->get_type() == iteration_stage_ && | 1655 return it->get_type() == iteration_stage_ && |
1661 (**it)->required_for_activation() == required_for_activation_; | 1656 (**it)->required_for_activation() == required_for_activation_; |
1662 } | 1657 } |
1663 | 1658 |
1664 } // namespace cc | 1659 } // namespace cc |
OLD | NEW |