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 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
686 return false; | 686 return false; |
687 | 687 |
688 if (contents_scale_ != 1.f) { | 688 if (contents_scale_ != 1.f) { |
689 tile_query_rect = | 689 tile_query_rect = |
690 gfx::ScaleToEnclosingRect(tile_query_rect, 1.0f / contents_scale_); | 690 gfx::ScaleToEnclosingRect(tile_query_rect, 1.0f / contents_scale_); |
691 } | 691 } |
692 | 692 |
693 return current_occlusion_in_layer_space_.IsOccluded(tile_query_rect); | 693 return current_occlusion_in_layer_space_.IsOccluded(tile_query_rect); |
694 } | 694 } |
695 | 695 |
696 bool PictureLayerTiling::IsTileRequiredForActivation(const Tile* tile) const { | 696 bool PictureLayerTiling::IsTileRequiredForActivationIfVisible( |
697 const Tile* tile) const { | |
697 DCHECK_EQ(PENDING_TREE, client_->GetTree()); | 698 DCHECK_EQ(PENDING_TREE, client_->GetTree()); |
698 | 699 |
699 // Note that although this function will determine whether tile is required | 700 // This function assumes that the tile is visible (i.e. in the viewport). The |
700 // for activation assuming that it is in visible (ie in the viewport). That is | 701 // caller needs to make sure that this condition is met to ensure we don't |
701 // to say, even if the tile is outside of the viewport, it will be treated as | 702 // block activation on tiles outside of the viewport. |
702 // if it was inside (there are no explicit checks for this). Hence, this | |
703 // function is only called for visible tiles to ensure we don't block | |
704 // activation on tiles outside of the viewport. | |
705 | 703 |
706 // If we are not allowed to mark tiles as required for activation, then don't | 704 // If we are not allowed to mark tiles as required for activation, then don't |
707 // do it. | 705 // do it. |
708 if (!can_require_tiles_for_activation_) | 706 if (!can_require_tiles_for_activation_) |
709 return false; | 707 return false; |
710 | 708 |
711 if (resolution_ != HIGH_RESOLUTION) | 709 if (resolution_ != HIGH_RESOLUTION) |
712 return false; | 710 return false; |
713 | 711 |
714 if (IsTileOccluded(tile)) | 712 if (IsTileOccluded(tile)) |
(...skipping 15 matching lines...) Expand all Loading... | |
730 Tile* twin_tile = | 728 Tile* twin_tile = |
731 twin_tiling->TileAt(tile->tiling_i_index(), tile->tiling_j_index()); | 729 twin_tiling->TileAt(tile->tiling_i_index(), tile->tiling_j_index()); |
732 // If twin tile is missing, it might not have a recording, so we don't need | 730 // If twin tile is missing, it might not have a recording, so we don't need |
733 // this tile to be required for activation. | 731 // this tile to be required for activation. |
734 if (!twin_tile) | 732 if (!twin_tile) |
735 return false; | 733 return false; |
736 | 734 |
737 return true; | 735 return true; |
738 } | 736 } |
739 | 737 |
738 bool PictureLayerTiling::IsTileRequiredForDrawIfVisible( | |
739 const Tile* tile) const { | |
740 DCHECK_EQ(ACTIVE_TREE, client_->GetTree()); | |
741 | |
742 // This function assumes that the tile is visible (i.e. in the viewport). | |
743 | |
744 if (resolution_ != HIGH_RESOLUTION) | |
745 return false; | |
746 | |
747 if (IsTileOccluded(tile)) | |
748 return false; | |
749 | |
750 return true; | |
751 } | |
752 | |
740 void PictureLayerTiling::UpdateTileAndTwinPriority(Tile* tile) const { | 753 void PictureLayerTiling::UpdateTileAndTwinPriority(Tile* tile) const { |
741 UpdateTilePriority(tile); | 754 UpdateTilePriority(tile); |
742 | 755 |
743 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | 756 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); |
744 if (!tile->is_shared() || !twin_tiling) { | 757 if (!tile->is_shared() || !twin_tiling) { |
745 WhichTree tree = client_->GetTree(); | 758 WhichTree tree = client_->GetTree(); |
746 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; | 759 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; |
747 tile->SetPriority(twin_tree, TilePriority()); | 760 tile->SetPriority(twin_tree, TilePriority()); |
748 tile->set_is_occluded(twin_tree, false); | 761 tile->set_is_occluded(twin_tree, false); |
749 if (twin_tree == PENDING_TREE) | 762 if (twin_tree == PENDING_TREE) |
750 tile->set_required_for_activation(false); | 763 tile->set_required_for_activation(false); |
764 else | |
765 tile->set_required_for_draw(false); | |
751 return; | 766 return; |
752 } | 767 } |
753 | 768 |
754 twin_tiling->UpdateTilePriority(tile); | 769 twin_tiling->UpdateTilePriority(tile); |
755 } | 770 } |
756 | 771 |
757 void PictureLayerTiling::UpdateTilePriority(Tile* tile) const { | 772 void PictureLayerTiling::UpdateTilePriority(Tile* tile) const { |
758 // TODO(vmpstr): This code should return the priority instead of setting it on | 773 // TODO(vmpstr): This code should return the priority instead of setting it on |
759 // the tile. This should be a part of the change to move tile priority from | 774 // the tile. This should be a part of the change to move tile priority from |
760 // tiles into iterators. | 775 // tiles into iterators. |
761 WhichTree tree = client_->GetTree(); | 776 WhichTree tree = client_->GetTree(); |
762 | 777 |
763 DCHECK_EQ(TileAt(tile->tiling_i_index(), tile->tiling_j_index()), tile); | 778 DCHECK_EQ(TileAt(tile->tiling_i_index(), tile->tiling_j_index()), tile); |
764 gfx::Rect tile_bounds = | 779 gfx::Rect tile_bounds = |
765 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); | 780 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); |
766 | 781 |
767 if (current_visible_rect_.Intersects(tile_bounds)) { | 782 if (current_visible_rect_.Intersects(tile_bounds)) { |
768 tile->SetPriority(tree, TilePriority(resolution_, TilePriority::NOW, 0)); | 783 tile->SetPriority(tree, TilePriority(resolution_, TilePriority::NOW, 0)); |
769 if (tree == PENDING_TREE) | 784 if (tree == PENDING_TREE) |
danakj
2014/10/31 17:00:57
{}
ernstm
2014/11/03 22:34:41
Done.
| |
770 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); | 785 tile->set_required_for_activation( |
786 IsTileRequiredForActivationIfVisible(tile)); | |
787 else | |
788 tile->set_required_for_draw(IsTileRequiredForDrawIfVisible(tile)); | |
771 tile->set_is_occluded(tree, IsTileOccluded(tile)); | 789 tile->set_is_occluded(tree, IsTileOccluded(tile)); |
772 return; | 790 return; |
773 } | 791 } |
774 | 792 |
775 if (tree == PENDING_TREE) | 793 if (tree == PENDING_TREE) |
776 tile->set_required_for_activation(false); | 794 tile->set_required_for_activation(false); |
795 else | |
796 tile->set_required_for_draw(false); | |
777 tile->set_is_occluded(tree, false); | 797 tile->set_is_occluded(tree, false); |
778 | 798 |
779 DCHECK_GT(content_to_screen_scale_, 0.f); | 799 DCHECK_GT(content_to_screen_scale_, 0.f); |
780 float distance_to_visible = | 800 float distance_to_visible = |
781 current_visible_rect_.ManhattanInternalDistance(tile_bounds) * | 801 current_visible_rect_.ManhattanInternalDistance(tile_bounds) * |
782 content_to_screen_scale_; | 802 content_to_screen_scale_; |
783 | 803 |
784 if (current_soon_border_rect_.Intersects(tile_bounds) || | 804 if (current_soon_border_rect_.Intersects(tile_bounds) || |
785 current_skewport_rect_.Intersects(tile_bounds)) { | 805 current_skewport_rect_.Intersects(tile_bounds)) { |
786 tile->SetPriority( | 806 tile->SetPriority( |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1226 DCHECK(*this); | 1246 DCHECK(*this); |
1227 do { | 1247 do { |
1228 ++current_eviction_tiles_index_; | 1248 ++current_eviction_tiles_index_; |
1229 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && | 1249 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && |
1230 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); | 1250 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); |
1231 | 1251 |
1232 return *this; | 1252 return *this; |
1233 } | 1253 } |
1234 | 1254 |
1235 } // namespace cc | 1255 } // namespace cc |
OLD | NEW |