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 17 matching lines...) Expand all Loading... |
28 #if defined(OS_ANDROID) | 28 #if defined(OS_ANDROID) |
29 // For reference, the Nexus10 can upload 1MB in about 2.5ms. | 29 // For reference, the Nexus10 can upload 1MB in about 2.5ms. |
30 // Assuming a three frame deep pipeline this implies ~20MB. | 30 // Assuming a three frame deep pipeline this implies ~20MB. |
31 const int kMaxPendingUploadBytes = 20 * 1024 * 1024; | 31 const int kMaxPendingUploadBytes = 20 * 1024 * 1024; |
32 #else | 32 #else |
33 const int kMaxPendingUploadBytes = 100 * 1024 * 1024; | 33 const int kMaxPendingUploadBytes = 100 * 1024 * 1024; |
34 #endif | 34 #endif |
35 | 35 |
36 // Determine bin based on three categories of tiles: things we need now, | 36 // Determine bin based on three categories of tiles: things we need now, |
37 // things we need soon, and eventually. | 37 // things we need soon, and eventually. |
38 TileManagerBin BinFromTilePriority(const TilePriority& prio) { | 38 inline TileManagerBin BinFromTilePriority(const TilePriority& prio) { |
39 if (!prio.is_live) | 39 if (!prio.is_live) |
40 return NEVER_BIN; | 40 return NEVER_BIN; |
41 | 41 |
42 // The amount of time for which we want to have prepainting coverage. | 42 // The amount of time for which we want to have prepainting coverage. |
43 const double prepainting_window_time_seconds = 1.0; | 43 const double prepainting_window_time_seconds = 1.0; |
44 const double backfling_guard_distance_pixels = 314.0; | 44 const double backfling_guard_distance_pixels = 314.0; |
45 | 45 |
46 // Explicitly limit how far ahead we will prepaint to limit memory usage. | 46 // Explicitly limit how far ahead we will prepaint to limit memory usage. |
47 if (prio.distance_to_visible_in_pixels > | 47 if (prio.distance_to_visible_in_pixels > |
48 TilePriority::kMaxDistanceInContentSpace) | 48 TilePriority::kMaxDistanceInContentSpace) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 for (int i = 0; i < NUM_TREES; ++i) | 181 for (int i = 0; i < NUM_TREES; ++i) |
182 --raster_state_count_[mts.raster_state][i][mts.tree_bin[i]]; | 182 --raster_state_count_[mts.raster_state][i][mts.tree_bin[i]]; |
183 FreeResourcesForTile(tile); | 183 FreeResourcesForTile(tile); |
184 tiles_.erase(it); | 184 tiles_.erase(it); |
185 return; | 185 return; |
186 } | 186 } |
187 } | 187 } |
188 DCHECK(false) << "Could not find tile version."; | 188 DCHECK(false) << "Could not find tile version."; |
189 } | 189 } |
190 | 190 |
191 void TileManager::WillModifyTilePriority( | |
192 Tile* tile, WhichTree tree, const TilePriority& new_priority) { | |
193 // TODO(nduca): Do something smarter if reprioritization turns out to be | |
194 // costly. | |
195 ScheduleManageTiles(); | |
196 } | |
197 | |
198 void TileManager::ScheduleManageTiles() { | |
199 if (manage_tiles_pending_) | |
200 return; | |
201 client_->ScheduleManageTiles(); | |
202 manage_tiles_pending_ = true; | |
203 } | |
204 | |
205 class BinComparator { | 191 class BinComparator { |
206 public: | 192 public: |
207 bool operator() (const Tile* a, const Tile* b) const { | 193 bool operator() (const Tile* a, const Tile* b) const { |
208 const ManagedTileState& ams = a->managed_state(); | 194 const ManagedTileState& ams = a->managed_state(); |
209 const ManagedTileState& bms = b->managed_state(); | 195 const ManagedTileState& bms = b->managed_state(); |
210 if (ams.bin[HIGH_PRIORITY_BIN] != bms.bin[HIGH_PRIORITY_BIN]) | 196 if (ams.bin[HIGH_PRIORITY_BIN] != bms.bin[HIGH_PRIORITY_BIN]) |
211 return ams.bin[HIGH_PRIORITY_BIN] < bms.bin[HIGH_PRIORITY_BIN]; | 197 return ams.bin[HIGH_PRIORITY_BIN] < bms.bin[HIGH_PRIORITY_BIN]; |
212 | 198 |
213 if (ams.bin[LOW_PRIORITY_BIN] != bms.bin[LOW_PRIORITY_BIN]) | 199 if (ams.bin[LOW_PRIORITY_BIN] != bms.bin[LOW_PRIORITY_BIN]) |
214 return ams.bin[LOW_PRIORITY_BIN] < bms.bin[LOW_PRIORITY_BIN]; | 200 return ams.bin[LOW_PRIORITY_BIN] < bms.bin[LOW_PRIORITY_BIN]; |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 RenderingStats* stats) { | 759 RenderingStats* stats) { |
774 TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask"); | 760 TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask"); |
775 base::TimeTicks decode_begin_time = base::TimeTicks::Now(); | 761 base::TimeTicks decode_begin_time = base::TimeTicks::Now(); |
776 pixel_ref->Decode(); | 762 pixel_ref->Decode(); |
777 stats->totalDeferredImageDecodeCount++; | 763 stats->totalDeferredImageDecodeCount++; |
778 stats->totalDeferredImageDecodeTime += | 764 stats->totalDeferredImageDecodeTime += |
779 base::TimeTicks::Now() - decode_begin_time; | 765 base::TimeTicks::Now() - decode_begin_time; |
780 } | 766 } |
781 | 767 |
782 } // namespace cc | 768 } // namespace cc |
OLD | NEW |