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/tile_manager.h" | 5 #include "cc/tile_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #if defined(OS_ANDROID) | 27 #if defined(OS_ANDROID) |
28 // For reference, the Nexus10 can upload 1MB in about 2.5ms. | 28 // For reference, the Nexus10 can upload 1MB in about 2.5ms. |
29 // Assuming a three frame deep pipeline this implies ~20MB. | 29 // Assuming a three frame deep pipeline this implies ~20MB. |
30 const int kMaxPendingUploadBytes = 20 * 1024 * 1024; | 30 const int kMaxPendingUploadBytes = 20 * 1024 * 1024; |
31 #else | 31 #else |
32 const int kMaxPendingUploadBytes = 100 * 1024 * 1024; | 32 const int kMaxPendingUploadBytes = 100 * 1024 * 1024; |
33 #endif | 33 #endif |
34 | 34 |
35 // Determine bin based on three categories of tiles: things we need now, | 35 // Determine bin based on three categories of tiles: things we need now, |
36 // things we need soon, and eventually. | 36 // things we need soon, and eventually. |
37 TileManagerBin BinFromTilePriority(const TilePriority& prio) { | 37 inline TileManagerBin BinFromTilePriority(const TilePriority& prio) { |
38 | 38 |
39 // The amount of time for which we want to have prepainting coverage. | 39 // The amount of time for which we want to have prepainting coverage. |
40 const double prepainting_window_time_seconds = 1.0; | 40 const double prepainting_window_time_seconds = 1.0; |
41 const double backfling_guard_distance_pixels = 314.0; | 41 const double backfling_guard_distance_pixels = 314.0; |
42 | 42 |
43 // Explicitly limit how far ahead we will prepaint for low and non-low res. | 43 // Explicitly limit how far ahead we will prepaint for low and non-low res. |
44 const double max_lores_paint_distance_pixels = 8192.0; | 44 const double max_lores_paint_distance_pixels = 8192.0; |
45 const double max_hires_paint_distance_pixels = 4096.0; | 45 const double max_hires_paint_distance_pixels = 4096.0; |
46 if (prio.resolution == cc::LOW_RESOLUTION) { | 46 if (prio.resolution == cc::LOW_RESOLUTION) { |
47 if (prio.distance_to_visible_in_pixels > max_lores_paint_distance_pixels) | 47 if (prio.distance_to_visible_in_pixels > max_lores_paint_distance_pixels) |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 for (int i = 0; i < NUM_TREES; ++i) | 188 for (int i = 0; i < NUM_TREES; ++i) |
189 --raster_state_count_[mts.raster_state][i][mts.tree_bin[i]]; | 189 --raster_state_count_[mts.raster_state][i][mts.tree_bin[i]]; |
190 FreeResourcesForTile(tile); | 190 FreeResourcesForTile(tile); |
191 tiles_.erase(it); | 191 tiles_.erase(it); |
192 return; | 192 return; |
193 } | 193 } |
194 } | 194 } |
195 DCHECK(false) << "Could not find tile version."; | 195 DCHECK(false) << "Could not find tile version."; |
196 } | 196 } |
197 | 197 |
198 void TileManager::WillModifyTilePriority( | |
199 Tile* tile, WhichTree tree, const TilePriority& new_priority) { | |
200 // TODO(nduca): Do something smarter if reprioritization turns out to be | |
201 // costly. | |
202 ScheduleManageTiles(); | |
203 } | |
204 | |
205 void TileManager::ScheduleManageTiles() { | |
206 if (manage_tiles_pending_) | |
207 return; | |
208 client_->ScheduleManageTiles(); | |
209 manage_tiles_pending_ = true; | |
210 } | |
211 | |
212 class BinComparator { | 198 class BinComparator { |
213 public: | 199 public: |
214 bool operator() (const Tile* a, const Tile* b) const { | 200 bool operator() (const Tile* a, const Tile* b) const { |
215 const ManagedTileState& ams = a->managed_state(); | 201 const ManagedTileState& ams = a->managed_state(); |
216 const ManagedTileState& bms = b->managed_state(); | 202 const ManagedTileState& bms = b->managed_state(); |
217 if (ams.bin[HIGH_PRIORITY_BIN] != bms.bin[HIGH_PRIORITY_BIN]) | 203 if (ams.bin[HIGH_PRIORITY_BIN] != bms.bin[HIGH_PRIORITY_BIN]) |
218 return ams.bin[HIGH_PRIORITY_BIN] < bms.bin[HIGH_PRIORITY_BIN]; | 204 return ams.bin[HIGH_PRIORITY_BIN] < bms.bin[HIGH_PRIORITY_BIN]; |
219 | 205 |
220 if (ams.bin[LOW_PRIORITY_BIN] != bms.bin[LOW_PRIORITY_BIN]) | 206 if (ams.bin[LOW_PRIORITY_BIN] != bms.bin[LOW_PRIORITY_BIN]) |
221 return ams.bin[LOW_PRIORITY_BIN] < bms.bin[LOW_PRIORITY_BIN]; | 207 return ams.bin[LOW_PRIORITY_BIN] < bms.bin[LOW_PRIORITY_BIN]; |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 --raster_state_count_[mts.raster_state][tree][mts.tree_bin[tree]]; | 736 --raster_state_count_[mts.raster_state][tree][mts.tree_bin[tree]]; |
751 DCHECK_GE(raster_state_count_[mts.raster_state][tree][mts.tree_bin[tree]], 0); | 737 DCHECK_GE(raster_state_count_[mts.raster_state][tree][mts.tree_bin[tree]], 0); |
752 | 738 |
753 // Increment count for new bin. | 739 // Increment count for new bin. |
754 ++raster_state_count_[mts.raster_state][tree][bin]; | 740 ++raster_state_count_[mts.raster_state][tree][bin]; |
755 | 741 |
756 mts.tree_bin[tree] = bin; | 742 mts.tree_bin[tree] = bin; |
757 } | 743 } |
758 | 744 |
759 } // namespace cc | 745 } // namespace cc |
OLD | NEW |