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

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

Issue 1132443003: cc: Move raster_source from Tile to PrioritizedTile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename var Created 5 years, 7 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/resources/picture_layer_tiling.h ('k') | cc/resources/picture_layer_tiling_set.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/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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 131 }
132 132
133 void PictureLayerTiling::TakeTilesAndPropertiesFrom( 133 void PictureLayerTiling::TakeTilesAndPropertiesFrom(
134 PictureLayerTiling* pending_twin, 134 PictureLayerTiling* pending_twin,
135 const Region& layer_invalidation) { 135 const Region& layer_invalidation) {
136 TRACE_EVENT0("cc", "TakeTilesAndPropertiesFrom"); 136 TRACE_EVENT0("cc", "TakeTilesAndPropertiesFrom");
137 SetRasterSourceAndResize(pending_twin->raster_source_); 137 SetRasterSourceAndResize(pending_twin->raster_source_);
138 138
139 RemoveTilesInRegion(layer_invalidation, false /* recreate tiles */); 139 RemoveTilesInRegion(layer_invalidation, false /* recreate tiles */);
140 140
141 for (TileMap::value_type& tile_pair : tiles_)
142 tile_pair.second->set_raster_source(raster_source_.get());
143
144 resolution_ = pending_twin->resolution_; 141 resolution_ = pending_twin->resolution_;
145 bool create_missing_tiles = false; 142 bool create_missing_tiles = false;
146 if (live_tiles_rect_.IsEmpty()) { 143 if (live_tiles_rect_.IsEmpty()) {
147 live_tiles_rect_ = pending_twin->live_tiles_rect(); 144 live_tiles_rect_ = pending_twin->live_tiles_rect();
148 create_missing_tiles = true; 145 create_missing_tiles = true;
149 } else { 146 } else {
150 SetLiveTilesRect(pending_twin->live_tiles_rect()); 147 SetLiveTilesRect(pending_twin->live_tiles_rect());
151 } 148 }
152 149
153 if (tiles_.empty()) { 150 if (tiles_.empty()) {
154 tiles_.swap(pending_twin->tiles_); 151 tiles_.swap(pending_twin->tiles_);
155 } else { 152 } else {
156 while (!pending_twin->tiles_.empty()) { 153 while (!pending_twin->tiles_.empty()) {
157 TileMapKey key = pending_twin->tiles_.begin()->first; 154 TileMapKey key = pending_twin->tiles_.begin()->first;
158 tiles_.set(key, pending_twin->tiles_.take_and_erase(key)); 155 tiles_.set(key, pending_twin->tiles_.take_and_erase(key));
159 DCHECK(tiles_.get(key)->raster_source() == raster_source_.get());
160 } 156 }
161 } 157 }
162 DCHECK(pending_twin->tiles_.empty()); 158 DCHECK(pending_twin->tiles_.empty());
163 159
164 if (create_missing_tiles) 160 if (create_missing_tiles)
165 CreateMissingTilesInLiveTilesRect(); 161 CreateMissingTilesInLiveTilesRect();
166 162
167 VerifyLiveTilesRect(false); 163 VerifyLiveTilesRect(false);
168 164
169 SetTilePriorityRects(pending_twin->current_content_to_screen_scale_, 165 SetTilePriorityRects(pending_twin->current_content_to_screen_scale_,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 if (recreate_tiles) 286 if (recreate_tiles)
291 new_tile_keys.push_back(iter.index()); 287 new_tile_keys.push_back(iter.index());
292 } 288 }
293 } 289 }
294 } 290 }
295 291
296 for (const auto& key : new_tile_keys) 292 for (const auto& key : new_tile_keys)
297 CreateTile(key.first, key.second); 293 CreateTile(key.first, key.second);
298 } 294 }
299 295
300 void PictureLayerTiling::SetRasterSourceOnTiles() {
301 if (tree_ == PENDING_TREE)
302 return;
303
304 for (TileMap::value_type& tile_pair : tiles_)
305 tile_pair.second->set_raster_source(raster_source_.get());
306 }
307
308 bool PictureLayerTiling::ShouldCreateTileAt(int i, int j) const { 296 bool PictureLayerTiling::ShouldCreateTileAt(int i, int j) const {
309 // Active tree should always create a tile. The reason for this is that active 297 // Active tree should always create a tile. The reason for this is that active
310 // tree represents content that we draw on screen, which means that whenever 298 // tree represents content that we draw on screen, which means that whenever
311 // we check whether a tile should exist somewhere, the answer is yes. This 299 // we check whether a tile should exist somewhere, the answer is yes. This
312 // doesn't mean it will actually be created (if raster source doesn't cover 300 // doesn't mean it will actually be created (if raster source doesn't cover
313 // the tile for instance). Pending tree, on the other hand, should only be 301 // the tile for instance). Pending tree, on the other hand, should only be
314 // creating tiles that are different from the current active tree, which is 302 // creating tiles that are different from the current active tree, which is
315 // represented by the logic in the rest of the function. 303 // represented by the logic in the rest of the function.
316 if (tree_ == ACTIVE_TREE) 304 if (tree_ == ACTIVE_TREE)
317 return true; 305 return true;
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 } 800 }
813 801
814 void PictureLayerTiling::UpdateRequiredStatesOnTile(Tile* tile) const { 802 void PictureLayerTiling::UpdateRequiredStatesOnTile(Tile* tile) const {
815 DCHECK(tile); 803 DCHECK(tile);
816 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); 804 tile->set_required_for_activation(IsTileRequiredForActivation(tile));
817 tile->set_required_for_draw(IsTileRequiredForDraw(tile)); 805 tile->set_required_for_draw(IsTileRequiredForDraw(tile));
818 } 806 }
819 807
820 PrioritizedTile PictureLayerTiling::MakePrioritizedTile(Tile* tile) const { 808 PrioritizedTile PictureLayerTiling::MakePrioritizedTile(Tile* tile) const {
821 DCHECK(tile); 809 DCHECK(tile);
822 return PrioritizedTile(tile, ComputePriorityForTile(tile), 810 DCHECK(
811 raster_source()->CoversRect(tile->content_rect(), tile->contents_scale()))
812 << "Recording rect: "
813 << gfx::ScaleToEnclosingRect(tile->content_rect(),
814 1.f / tile->contents_scale()).ToString();
815
816 return PrioritizedTile(tile, raster_source(), ComputePriorityForTile(tile),
823 IsTileOccluded(tile)); 817 IsTileOccluded(tile));
824 } 818 }
825 819
826 std::map<const Tile*, PrioritizedTile> 820 std::map<const Tile*, PrioritizedTile>
827 PictureLayerTiling::UpdateAndGetAllPrioritizedTilesForTesting() { 821 PictureLayerTiling::UpdateAndGetAllPrioritizedTilesForTesting() const {
828 std::map<const Tile*, PrioritizedTile> result; 822 std::map<const Tile*, PrioritizedTile> result;
829 for (const auto& key_tile_pair : tiles_) { 823 for (const auto& key_tile_pair : tiles_) {
830 UpdateRequiredStatesOnTile(key_tile_pair.second); 824 UpdateRequiredStatesOnTile(key_tile_pair.second);
831 PrioritizedTile prioritized_tile = 825 PrioritizedTile prioritized_tile =
832 MakePrioritizedTile(key_tile_pair.second); 826 MakePrioritizedTile(key_tile_pair.second);
833 result.insert(std::make_pair(prioritized_tile.tile(), prioritized_tile)); 827 result.insert(std::make_pair(prioritized_tile.tile(), prioritized_tile));
834 } 828 }
835 return result; 829 return result;
836 } 830 }
837 831
838 void PictureLayerTiling::VerifyAllTilesHaveCurrentRasterSource() const {
839 #if DCHECK_IS_ON()
840 for (const auto& tile_pair : tiles_)
841 DCHECK_EQ(raster_source_.get(), tile_pair.second->raster_source());
842 #endif
843 }
844
845 TilePriority PictureLayerTiling::ComputePriorityForTile( 832 TilePriority PictureLayerTiling::ComputePriorityForTile(
846 const Tile* tile) const { 833 const Tile* tile) const {
847 // TODO(vmpstr): See if this can be moved to iterators. 834 // TODO(vmpstr): See if this can be moved to iterators.
848 TilePriority::PriorityBin max_tile_priority_bin = 835 TilePriority::PriorityBin max_tile_priority_bin =
849 client_->GetMaxTilePriorityBin(); 836 client_->GetMaxTilePriorityBin();
850 837
851 DCHECK_EQ(TileAt(tile->tiling_i_index(), tile->tiling_j_index()), tile); 838 DCHECK_EQ(TileAt(tile->tiling_i_index(), tile->tiling_j_index()), tile);
852 gfx::Rect tile_bounds = 839 gfx::Rect tile_bounds =
853 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); 840 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index());
854 841
(...skipping 15 matching lines...) Expand all
870 if (max_tile_priority_bin <= TilePriority::SOON && 857 if (max_tile_priority_bin <= TilePriority::SOON &&
871 (current_soon_border_rect_.Intersects(tile_bounds) || 858 (current_soon_border_rect_.Intersects(tile_bounds) ||
872 current_skewport_rect_.Intersects(tile_bounds))) { 859 current_skewport_rect_.Intersects(tile_bounds))) {
873 return TilePriority(resolution_, TilePriority::SOON, distance_to_visible); 860 return TilePriority(resolution_, TilePriority::SOON, distance_to_visible);
874 } 861 }
875 862
876 return TilePriority(resolution_, TilePriority::EVENTUALLY, 863 return TilePriority(resolution_, TilePriority::EVENTUALLY,
877 distance_to_visible); 864 distance_to_visible);
878 } 865 }
879 866
880 void PictureLayerTiling::GetAllTilesAndPrioritiesForTracing( 867 void PictureLayerTiling::GetAllPrioritizedTilesForTracing(
881 std::map<const Tile*, TilePriority>* tile_map) const { 868 std::vector<PrioritizedTile>* prioritized_tiles) const {
882 for (const auto& tile_pair : tiles_) { 869 for (const auto& tile_pair : tiles_) {
883 const Tile* tile = tile_pair.second; 870 prioritized_tiles->push_back(MakePrioritizedTile(tile_pair.second));
884 const TilePriority& priority = ComputePriorityForTile(tile);
885 // Store combined priority.
886 (*tile_map)[tile] = priority;
887 } 871 }
888 } 872 }
889 873
890 void PictureLayerTiling::AsValueInto( 874 void PictureLayerTiling::AsValueInto(
891 base::trace_event::TracedValue* state) const { 875 base::trace_event::TracedValue* state) const {
892 state->SetInteger("num_tiles", tiles_.size()); 876 state->SetInteger("num_tiles", tiles_.size());
893 state->SetDouble("content_scale", contents_scale_); 877 state->SetDouble("content_scale", contents_scale_);
894 MathUtil::AddToTracedValue("visible_rect", current_visible_rect_, state); 878 MathUtil::AddToTracedValue("visible_rect", current_visible_rect_, state);
895 MathUtil::AddToTracedValue("skewport_rect", current_skewport_rect_, state); 879 MathUtil::AddToTracedValue("skewport_rect", current_skewport_rect_, state);
896 MathUtil::AddToTracedValue("soon_rect", current_soon_border_rect_, state); 880 MathUtil::AddToTracedValue("soon_rect", current_soon_border_rect_, state);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 break; 1037 break;
1054 } 1038 }
1055 1039
1056 gfx::Rect result(origin_x, origin_y, width, height); 1040 gfx::Rect result(origin_x, origin_y, width, height);
1057 if (cache) 1041 if (cache)
1058 cache->previous_result = result; 1042 cache->previous_result = result;
1059 return result; 1043 return result;
1060 } 1044 }
1061 1045
1062 } // namespace cc 1046 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling.h ('k') | cc/resources/picture_layer_tiling_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698