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/tile_manager.h" | 5 #include "cc/resources/tile_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 EVENTUALLY_AND_ACTIVE_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] | 108 EVENTUALLY_AND_ACTIVE_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] |
109 EVENTUALLY_AND_ACTIVE_BIN, // [EVENTUALLY_BIN] | 109 EVENTUALLY_AND_ACTIVE_BIN, // [EVENTUALLY_BIN] |
110 AT_LAST_AND_ACTIVE_BIN, // [AT_LAST_AND_ACTIVE_BIN] | 110 AT_LAST_AND_ACTIVE_BIN, // [AT_LAST_AND_ACTIVE_BIN] |
111 AT_LAST_AND_ACTIVE_BIN, // [AT_LAST_BIN] | 111 AT_LAST_AND_ACTIVE_BIN, // [AT_LAST_BIN] |
112 NEVER_BIN // [NEVER_BIN] | 112 NEVER_BIN // [NEVER_BIN] |
113 }}; | 113 }}; |
114 | 114 |
115 // Determine bin based on three categories of tiles: things we need now, | 115 // Determine bin based on three categories of tiles: things we need now, |
116 // things we need soon, and eventually. | 116 // things we need soon, and eventually. |
117 inline ManagedTileBin BinFromTilePriority(const TilePriority& prio) { | 117 inline ManagedTileBin BinFromTilePriority(const TilePriority& prio) { |
118 // The amount of time/pixels for which we want to have prepainting coverage. | |
119 // Note: All very arbitrary constants: metric-based tuning is welcome! | |
120 const float kPrepaintingWindowTimeSeconds = 1.0f; | |
121 const float kBackflingGuardDistancePixels = 314.0f; | 118 const float kBackflingGuardDistancePixels = 314.0f; |
122 // Note: The max distances here assume that SOON_BIN will never help overcome | |
123 // raster being too slow (only caching in advance will do that), so we just | |
124 // need enough padding to handle some latency and per-tile variability. | |
125 const float kMaxPrepaintingDistancePixelsHighRes = 2000.0f; | |
126 const float kMaxPrepaintingDistancePixelsLowRes = 4000.0f; | |
127 | 119 |
128 if (prio.distance_to_visible_in_pixels == | 120 if (prio.priority_bin == TilePriority::NOW) |
129 std::numeric_limits<float>::infinity()) | |
130 return NEVER_BIN; | |
131 | |
132 if (prio.time_to_visible_in_seconds == 0) | |
133 return NOW_BIN; | 121 return NOW_BIN; |
134 | 122 |
135 if (prio.resolution == NON_IDEAL_RESOLUTION) | 123 if (prio.priority_bin == TilePriority::SOON || |
136 return EVENTUALLY_BIN; | 124 prio.distance_to_visible < kBackflingGuardDistancePixels) |
| 125 return SOON_BIN; |
137 | 126 |
138 float max_prepainting_distance_pixels = | 127 if (prio.distance_to_visible == std::numeric_limits<float>::infinity()) |
139 (prio.resolution == HIGH_RESOLUTION) | 128 return NEVER_BIN; |
140 ? kMaxPrepaintingDistancePixelsHighRes | |
141 : kMaxPrepaintingDistancePixelsLowRes; | |
142 | |
143 // Soon bin if we are within backfling-guard, or under both the time window | |
144 // and the max distance window. | |
145 if (prio.distance_to_visible_in_pixels < kBackflingGuardDistancePixels || | |
146 (prio.time_to_visible_in_seconds < kPrepaintingWindowTimeSeconds && | |
147 prio.distance_to_visible_in_pixels <= max_prepainting_distance_pixels)) | |
148 return SOON_BIN; | |
149 | 129 |
150 return EVENTUALLY_BIN; | 130 return EVENTUALLY_BIN; |
151 } | 131 } |
152 | 132 |
153 } // namespace | 133 } // namespace |
154 | 134 |
155 RasterTaskCompletionStats::RasterTaskCompletionStats() | 135 RasterTaskCompletionStats::RasterTaskCompletionStats() |
156 : completed_count(0u), canceled_count(0u) {} | 136 : completed_count(0u), canceled_count(0u) {} |
157 | 137 |
158 scoped_ptr<base::Value> RasterTaskCompletionStatsAsValue( | 138 scoped_ptr<base::Value> RasterTaskCompletionStatsAsValue( |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 | 421 |
442 // Bump up the priority if we determined it's NEVER_BIN on one tree, | 422 // Bump up the priority if we determined it's NEVER_BIN on one tree, |
443 // but is still required on the other tree. | 423 // but is still required on the other tree. |
444 bool is_in_never_bin_on_both_trees = tree_bin[ACTIVE_TREE] == NEVER_BIN && | 424 bool is_in_never_bin_on_both_trees = tree_bin[ACTIVE_TREE] == NEVER_BIN && |
445 tree_bin[PENDING_TREE] == NEVER_BIN; | 425 tree_bin[PENDING_TREE] == NEVER_BIN; |
446 | 426 |
447 if (mts.bin == NEVER_BIN && !is_in_never_bin_on_both_trees) | 427 if (mts.bin == NEVER_BIN && !is_in_never_bin_on_both_trees) |
448 mts.bin = tile_is_active ? AT_LAST_AND_ACTIVE_BIN : AT_LAST_BIN; | 428 mts.bin = tile_is_active ? AT_LAST_AND_ACTIVE_BIN : AT_LAST_BIN; |
449 | 429 |
450 mts.resolution = tile_priority.resolution; | 430 mts.resolution = tile_priority.resolution; |
451 mts.time_to_needed_in_seconds = tile_priority.time_to_visible_in_seconds; | 431 mts.priority_bin = tile_priority.priority_bin; |
452 mts.distance_to_visible_in_pixels = | 432 mts.distance_to_visible = tile_priority.distance_to_visible; |
453 tile_priority.distance_to_visible_in_pixels; | |
454 mts.required_for_activation = tile_priority.required_for_activation; | 433 mts.required_for_activation = tile_priority.required_for_activation; |
455 | 434 |
456 mts.visible_and_ready_to_draw = | 435 mts.visible_and_ready_to_draw = |
457 tree_bin[ACTIVE_TREE] == NOW_AND_READY_TO_DRAW_BIN; | 436 tree_bin[ACTIVE_TREE] == NOW_AND_READY_TO_DRAW_BIN; |
458 | 437 |
459 if (mts.bin == NEVER_BIN) { | 438 if (mts.bin == NEVER_BIN) { |
460 FreeResourcesForTile(tile); | 439 FreeResourcesForTile(tile); |
461 continue; | 440 continue; |
462 } | 441 } |
463 | 442 |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 resource_pool_->ReleaseResource(resource.Pass()); | 924 resource_pool_->ReleaseResource(resource.Pass()); |
946 } else { | 925 } else { |
947 tile_version.set_use_resource(); | 926 tile_version.set_use_resource(); |
948 tile_version.resource_ = resource.Pass(); | 927 tile_version.resource_ = resource.Pass(); |
949 | 928 |
950 bytes_releasable_ += BytesConsumedIfAllocated(tile); | 929 bytes_releasable_ += BytesConsumedIfAllocated(tile); |
951 ++resources_releasable_; | 930 ++resources_releasable_; |
952 } | 931 } |
953 | 932 |
954 FreeUnusedResourcesForTile(tile); | 933 FreeUnusedResourcesForTile(tile); |
955 if (tile->priority(ACTIVE_TREE).distance_to_visible_in_pixels == 0) | 934 if (tile->priority(ACTIVE_TREE).distance_to_visible == 0.f) |
956 did_initialize_visible_tile_ = true; | 935 did_initialize_visible_tile_ = true; |
957 } | 936 } |
958 | 937 |
959 scoped_refptr<Tile> TileManager::CreateTile(PicturePileImpl* picture_pile, | 938 scoped_refptr<Tile> TileManager::CreateTile(PicturePileImpl* picture_pile, |
960 const gfx::Size& tile_size, | 939 const gfx::Size& tile_size, |
961 const gfx::Rect& content_rect, | 940 const gfx::Rect& content_rect, |
962 const gfx::Rect& opaque_rect, | 941 const gfx::Rect& opaque_rect, |
963 float contents_scale, | 942 float contents_scale, |
964 int layer_id, | 943 int layer_id, |
965 int source_frame_number, | 944 int source_frame_number, |
966 int flags) { | 945 int flags) { |
967 scoped_refptr<Tile> tile = make_scoped_refptr(new Tile(this, | 946 scoped_refptr<Tile> tile = make_scoped_refptr(new Tile(this, |
968 picture_pile, | 947 picture_pile, |
969 tile_size, | 948 tile_size, |
970 content_rect, | 949 content_rect, |
971 opaque_rect, | 950 opaque_rect, |
972 contents_scale, | 951 contents_scale, |
973 layer_id, | 952 layer_id, |
974 source_frame_number, | 953 source_frame_number, |
975 flags)); | 954 flags)); |
976 DCHECK(tiles_.find(tile->id()) == tiles_.end()); | 955 DCHECK(tiles_.find(tile->id()) == tiles_.end()); |
977 | 956 |
978 tiles_[tile->id()] = tile; | 957 tiles_[tile->id()] = tile; |
979 used_layer_counts_[tile->layer_id()]++; | 958 used_layer_counts_[tile->layer_id()]++; |
980 prioritized_tiles_dirty_ = true; | 959 prioritized_tiles_dirty_ = true; |
981 return tile; | 960 return tile; |
982 } | 961 } |
983 | 962 |
984 } // namespace cc | 963 } // namespace cc |
OLD | NEW |