Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(688)

Side by Side Diff: cc/tiles/picture_layer_tiling.cc

Issue 2726343004: cc: Optimize decode scheduling for checker-images. (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/tiles/picture_layer_tiling.h ('k') | cc/tiles/prioritized_tile.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/tiles/picture_layer_tiling.h" 5 #include "cc/tiles/picture_layer_tiling.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); 797 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index());
798 bool tile_is_visible = current_visible_rect_.Intersects(tile_bounds); 798 bool tile_is_visible = current_visible_rect_.Intersects(tile_bounds);
799 if (!tile_is_visible) 799 if (!tile_is_visible)
800 return false; 800 return false;
801 801
802 if (IsTileOccludedOnCurrentTree(tile)) 802 if (IsTileOccludedOnCurrentTree(tile))
803 return false; 803 return false;
804 return true; 804 return true;
805 } 805 }
806 806
807 bool PictureLayerTiling::ShouldDecodeCheckeredImagesForTile(
808 const Tile* tile) const {
809 // If this is the pending tree and the tile is not occluded, any checkered
810 // images on this tile should be decoded.
811 if (tree_ == PENDING_TREE)
812 return !IsTileOccludedOnCurrentTree(tile);
813
814 DCHECK_EQ(tree_, ACTIVE_TREE);
815 const PictureLayerTiling* pending_twin =
816 client_->GetPendingOrActiveTwinTiling(this);
817
818 // If we don't have a pending twin, then 2 cases are possible. Either we don't
819 // have a pending tree, in which case we should be decoding images for tiles
820 // which are unoccluded.
821 // If we do have a pending tree, then not having a twin implies that this
822 // tiling will be evicted upon activation. TODO(khushalsagar): Plumb this
823 // information here and return false for this case.
824 if (!pending_twin)
825 return !IsTileOccludedOnCurrentTree(tile);
826
827 // If the tile will be replaced upon activation, then we don't need to process
828 // it for checkered images. Since once the pending tree is activated, it is
829 // the new active tree's content that we will invalidate and replace once the
830 // decode finishes.
831 if (!TilingMatchesTileIndices(pending_twin) ||
832 pending_twin->TileAt(tile->tiling_i_index(), tile->tiling_j_index())) {
833 return false;
834 }
835
836 // Ask the pending twin if this tile will become occluded upon activation.
837 return !pending_twin->IsTileOccludedOnCurrentTree(tile);
838 }
839
807 void PictureLayerTiling::UpdateRequiredStatesOnTile(Tile* tile) const { 840 void PictureLayerTiling::UpdateRequiredStatesOnTile(Tile* tile) const {
808 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); 841 tile->set_required_for_activation(IsTileRequiredForActivation(tile));
809 tile->set_required_for_draw(IsTileRequiredForDraw(tile)); 842 tile->set_required_for_draw(IsTileRequiredForDraw(tile));
810 } 843 }
811 844
812 PrioritizedTile PictureLayerTiling::MakePrioritizedTile( 845 PrioritizedTile PictureLayerTiling::MakePrioritizedTile(
813 Tile* tile, 846 Tile* tile,
814 PriorityRectType priority_rect_type) const { 847 PriorityRectType priority_rect_type) const {
815 DCHECK(tile); 848 DCHECK(tile);
816 DCHECK(raster_source()->CoversRect(tile->enclosing_layer_rect())) 849 DCHECK(raster_source()->CoversRect(tile->enclosing_layer_rect()))
817 << "Recording rect: " 850 << "Recording rect: "
818 << EnclosingLayerRectFromContentsRect(tile->content_rect()).ToString(); 851 << EnclosingLayerRectFromContentsRect(tile->content_rect()).ToString();
819 852
820 UpdateRequiredStatesOnTile(tile); 853 UpdateRequiredStatesOnTile(tile);
821 const auto& tile_priority = ComputePriorityForTile(tile, priority_rect_type); 854 const auto& tile_priority = ComputePriorityForTile(tile, priority_rect_type);
822 DCHECK((!tile->required_for_activation() && !tile->required_for_draw()) || 855 DCHECK((!tile->required_for_activation() && !tile->required_for_draw()) ||
823 tile_priority.priority_bin == TilePriority::NOW || 856 tile_priority.priority_bin == TilePriority::NOW ||
824 !client_->HasValidTilePriorities()); 857 !client_->HasValidTilePriorities());
825 858
826 // Note that TileManager will consider this flag but may rasterize the tile 859 // Note that TileManager will consider this flag but may rasterize the tile
827 // anyway (if tile is required for activation for example). We should process 860 // anyway (if tile is required for activation for example). We should process
828 // the tile for images only if it's further than half of the skewport extent. 861 // the tile for images only if it's further than half of the skewport extent.
829 bool process_for_images_only = 862 bool process_for_images_only =
830 tile_priority.distance_to_visible > min_preraster_distance_ && 863 tile_priority.distance_to_visible > min_preraster_distance_ &&
831 (tile_priority.distance_to_visible > max_preraster_distance_ || 864 (tile_priority.distance_to_visible > max_preraster_distance_ ||
832 tile_priority.distance_to_visible > 865 tile_priority.distance_to_visible >
833 0.5f * max_skewport_extent_in_screen_space_); 866 0.5f * max_skewport_extent_in_screen_space_);
834 return PrioritizedTile(tile, this, tile_priority, IsTileOccluded(tile), 867 return PrioritizedTile(tile, this, tile_priority, IsTileOccluded(tile),
835 process_for_images_only); 868 process_for_images_only,
869 ShouldDecodeCheckeredImagesForTile(tile));
836 } 870 }
837 871
838 std::map<const Tile*, PrioritizedTile> 872 std::map<const Tile*, PrioritizedTile>
839 PictureLayerTiling::UpdateAndGetAllPrioritizedTilesForTesting() const { 873 PictureLayerTiling::UpdateAndGetAllPrioritizedTilesForTesting() const {
840 std::map<const Tile*, PrioritizedTile> result; 874 std::map<const Tile*, PrioritizedTile> result;
841 for (const auto& key_tile_pair : tiles_) { 875 for (const auto& key_tile_pair : tiles_) {
842 Tile* tile = key_tile_pair.second.get(); 876 Tile* tile = key_tile_pair.second.get();
843 PrioritizedTile prioritized_tile = 877 PrioritizedTile prioritized_tile =
844 MakePrioritizedTile(tile, ComputePriorityRectTypeForTile(tile)); 878 MakePrioritizedTile(tile, ComputePriorityRectTypeForTile(tile));
845 result.insert(std::make_pair(prioritized_tile.tile(), prioritized_tile)); 879 result.insert(std::make_pair(prioritized_tile.tile(), prioritized_tile));
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 return ToEnclosingRect(raster_transform_.MapRect(gfx::RectF(layer_rect))); 979 return ToEnclosingRect(raster_transform_.MapRect(gfx::RectF(layer_rect)));
946 } 980 }
947 981
948 gfx::Rect PictureLayerTiling::EnclosingLayerRectFromContentsRect( 982 gfx::Rect PictureLayerTiling::EnclosingLayerRectFromContentsRect(
949 const gfx::Rect& contents_rect) const { 983 const gfx::Rect& contents_rect) const {
950 return ToEnclosingRect( 984 return ToEnclosingRect(
951 raster_transform_.InverseMapRect(gfx::RectF(contents_rect))); 985 raster_transform_.InverseMapRect(gfx::RectF(contents_rect)));
952 } 986 }
953 987
954 } // namespace cc 988 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/picture_layer_tiling.h ('k') | cc/tiles/prioritized_tile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698