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/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <set> | 10 #include <set> |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 return false; | 692 return false; |
693 | 693 |
694 if (contents_scale_ != 1.f) { | 694 if (contents_scale_ != 1.f) { |
695 tile_query_rect = | 695 tile_query_rect = |
696 gfx::ScaleToEnclosingRect(tile_query_rect, 1.0f / contents_scale_); | 696 gfx::ScaleToEnclosingRect(tile_query_rect, 1.0f / contents_scale_); |
697 } | 697 } |
698 | 698 |
699 return current_occlusion_in_layer_space_.IsOccluded(tile_query_rect); | 699 return current_occlusion_in_layer_space_.IsOccluded(tile_query_rect); |
700 } | 700 } |
701 | 701 |
702 bool PictureLayerTiling::IsTileRequiredForActivation(const Tile* tile) const { | 702 bool PictureLayerTiling::IsTileRequiredForActivationIfVisible( |
| 703 const Tile* tile) const { |
703 DCHECK_EQ(PENDING_TREE, client_->GetTree()); | 704 DCHECK_EQ(PENDING_TREE, client_->GetTree()); |
704 | 705 |
705 // Note that although this function will determine whether tile is required | 706 // This function assumes that the tile is visible (i.e. in the viewport). The |
706 // for activation assuming that it is in visible (ie in the viewport). That is | 707 // caller needs to make sure that this condition is met to ensure we don't |
707 // to say, even if the tile is outside of the viewport, it will be treated as | 708 // block activation on tiles outside of the viewport. |
708 // if it was inside (there are no explicit checks for this). Hence, this | |
709 // function is only called for visible tiles to ensure we don't block | |
710 // activation on tiles outside of the viewport. | |
711 | 709 |
712 // If we are not allowed to mark tiles as required for activation, then don't | 710 // If we are not allowed to mark tiles as required for activation, then don't |
713 // do it. | 711 // do it. |
714 if (!can_require_tiles_for_activation_) | 712 if (!can_require_tiles_for_activation_) |
715 return false; | 713 return false; |
716 | 714 |
717 if (resolution_ != HIGH_RESOLUTION) | 715 if (resolution_ != HIGH_RESOLUTION) |
718 return false; | 716 return false; |
719 | 717 |
720 if (IsTileOccluded(tile)) | 718 if (IsTileOccluded(tile)) |
(...skipping 16 matching lines...) Expand all Loading... |
737 Tile* twin_tile = | 735 Tile* twin_tile = |
738 twin_tiling->TileAt(tile->tiling_i_index(), tile->tiling_j_index()); | 736 twin_tiling->TileAt(tile->tiling_i_index(), tile->tiling_j_index()); |
739 // If twin tile is missing, it might not have a recording, so we don't need | 737 // If twin tile is missing, it might not have a recording, so we don't need |
740 // this tile to be required for activation. | 738 // this tile to be required for activation. |
741 if (!twin_tile) | 739 if (!twin_tile) |
742 return false; | 740 return false; |
743 | 741 |
744 return true; | 742 return true; |
745 } | 743 } |
746 | 744 |
| 745 bool PictureLayerTiling::IsTileRequiredForDrawIfVisible( |
| 746 const Tile* tile) const { |
| 747 DCHECK_EQ(ACTIVE_TREE, client_->GetTree()); |
| 748 |
| 749 // This function assumes that the tile is visible (i.e. in the viewport). |
| 750 |
| 751 if (resolution_ != HIGH_RESOLUTION) |
| 752 return false; |
| 753 |
| 754 if (IsTileOccluded(tile)) |
| 755 return false; |
| 756 |
| 757 return true; |
| 758 } |
| 759 |
747 void PictureLayerTiling::UpdateTileAndTwinPriority(Tile* tile) const { | 760 void PictureLayerTiling::UpdateTileAndTwinPriority(Tile* tile) const { |
748 UpdateTilePriority(tile); | 761 UpdateTilePriority(tile); |
749 | 762 |
750 const PictureLayerTiling* twin_tiling = | 763 const PictureLayerTiling* twin_tiling = |
751 client_->GetPendingOrActiveTwinTiling(this); | 764 client_->GetPendingOrActiveTwinTiling(this); |
752 if (!tile->is_shared() || !twin_tiling) { | 765 if (!tile->is_shared() || !twin_tiling) { |
753 WhichTree tree = client_->GetTree(); | 766 WhichTree tree = client_->GetTree(); |
754 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; | 767 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; |
755 tile->SetPriority(twin_tree, TilePriority()); | 768 tile->SetPriority(twin_tree, TilePriority()); |
756 tile->set_is_occluded(twin_tree, false); | 769 tile->set_is_occluded(twin_tree, false); |
757 if (twin_tree == PENDING_TREE) | 770 if (twin_tree == PENDING_TREE) |
758 tile->set_required_for_activation(false); | 771 tile->set_required_for_activation(false); |
| 772 else |
| 773 tile->set_required_for_draw(false); |
759 return; | 774 return; |
760 } | 775 } |
761 | 776 |
762 twin_tiling->UpdateTilePriority(tile); | 777 twin_tiling->UpdateTilePriority(tile); |
763 } | 778 } |
764 | 779 |
765 void PictureLayerTiling::UpdateTilePriority(Tile* tile) const { | 780 void PictureLayerTiling::UpdateTilePriority(Tile* tile) const { |
766 // TODO(vmpstr): This code should return the priority instead of setting it on | 781 // TODO(vmpstr): This code should return the priority instead of setting it on |
767 // the tile. This should be a part of the change to move tile priority from | 782 // the tile. This should be a part of the change to move tile priority from |
768 // tiles into iterators. | 783 // tiles into iterators. |
769 WhichTree tree = client_->GetTree(); | 784 WhichTree tree = client_->GetTree(); |
770 | 785 |
771 DCHECK_EQ(TileAt(tile->tiling_i_index(), tile->tiling_j_index()), tile); | 786 DCHECK_EQ(TileAt(tile->tiling_i_index(), tile->tiling_j_index()), tile); |
772 gfx::Rect tile_bounds = | 787 gfx::Rect tile_bounds = |
773 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); | 788 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); |
774 | 789 |
775 if (current_visible_rect_.Intersects(tile_bounds)) { | 790 if (current_visible_rect_.Intersects(tile_bounds)) { |
776 tile->SetPriority(tree, TilePriority(resolution_, TilePriority::NOW, 0)); | 791 tile->SetPriority(tree, TilePriority(resolution_, TilePriority::NOW, 0)); |
777 if (tree == PENDING_TREE) | 792 if (tree == PENDING_TREE) { |
778 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); | 793 tile->set_required_for_activation( |
| 794 IsTileRequiredForActivationIfVisible(tile)); |
| 795 } else { |
| 796 tile->set_required_for_draw(IsTileRequiredForDrawIfVisible(tile)); |
| 797 } |
779 tile->set_is_occluded(tree, IsTileOccluded(tile)); | 798 tile->set_is_occluded(tree, IsTileOccluded(tile)); |
780 return; | 799 return; |
781 } | 800 } |
782 | 801 |
783 if (tree == PENDING_TREE) | 802 if (tree == PENDING_TREE) |
784 tile->set_required_for_activation(false); | 803 tile->set_required_for_activation(false); |
| 804 else |
| 805 tile->set_required_for_draw(false); |
785 tile->set_is_occluded(tree, false); | 806 tile->set_is_occluded(tree, false); |
786 | 807 |
787 DCHECK_GT(content_to_screen_scale_, 0.f); | 808 DCHECK_GT(content_to_screen_scale_, 0.f); |
788 float distance_to_visible = | 809 float distance_to_visible = |
789 current_visible_rect_.ManhattanInternalDistance(tile_bounds) * | 810 current_visible_rect_.ManhattanInternalDistance(tile_bounds) * |
790 content_to_screen_scale_; | 811 content_to_screen_scale_; |
791 | 812 |
792 if (current_soon_border_rect_.Intersects(tile_bounds) || | 813 if (current_soon_border_rect_.Intersects(tile_bounds) || |
793 current_skewport_rect_.Intersects(tile_bounds)) { | 814 current_skewport_rect_.Intersects(tile_bounds)) { |
794 tile->SetPriority( | 815 tile->SetPriority( |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 DCHECK(*this); | 1255 DCHECK(*this); |
1235 do { | 1256 do { |
1236 ++current_eviction_tiles_index_; | 1257 ++current_eviction_tiles_index_; |
1237 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && | 1258 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && |
1238 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); | 1259 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); |
1239 | 1260 |
1240 return *this; | 1261 return *this; |
1241 } | 1262 } |
1242 | 1263 |
1243 } // namespace cc | 1264 } // namespace cc |
OLD | NEW |