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. | 118 if (prio.priority_bin == TilePriority::NOW) |
119 // Note: All very arbitrary constants: metric-based tuning is welcome! | 119 return NOW_BIN; |
120 const float kPrepaintingWindowTimeSeconds = 1.0f; | |
enne (OOO)
2014/01/31 23:07:46
Should the soon bin skewport window be 1 second in
vmpstr
2014/02/03 20:27:24
Done.
| |
121 const float kBackflingGuardDistancePixels = 314.0f; | |
vmpstr
2014/01/31 20:53:38
Note that this patch eliminates backfling thing. W
| |
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 | 120 |
128 if (prio.distance_to_visible_in_pixels == | 121 if (prio.priority_bin == TilePriority::SOON) |
122 return SOON_BIN; | |
123 | |
124 if (prio.distance_to_visible == | |
enne (OOO)
2014/01/31 23:07:46
When does this happen?
vmpstr
2014/02/03 20:27:24
This is magic :P. distance_to_visible == inf means
| |
129 std::numeric_limits<float>::infinity()) | 125 std::numeric_limits<float>::infinity()) |
130 return NEVER_BIN; | 126 return NEVER_BIN; |
131 | 127 |
132 if (prio.time_to_visible_in_seconds == 0) | |
133 return NOW_BIN; | |
134 | |
135 if (prio.resolution == NON_IDEAL_RESOLUTION) | |
136 return EVENTUALLY_BIN; | |
137 | |
138 float max_prepainting_distance_pixels = | |
139 (prio.resolution == HIGH_RESOLUTION) | |
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 | |
150 return EVENTUALLY_BIN; | 128 return EVENTUALLY_BIN; |
151 } | 129 } |
152 | 130 |
153 } // namespace | 131 } // namespace |
154 | 132 |
155 RasterTaskCompletionStats::RasterTaskCompletionStats() | 133 RasterTaskCompletionStats::RasterTaskCompletionStats() |
156 : completed_count(0u), canceled_count(0u) {} | 134 : completed_count(0u), canceled_count(0u) {} |
157 | 135 |
158 scoped_ptr<base::Value> RasterTaskCompletionStatsAsValue( | 136 scoped_ptr<base::Value> RasterTaskCompletionStatsAsValue( |
159 const RasterTaskCompletionStats& stats) { | 137 const RasterTaskCompletionStats& stats) { |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 | 419 |
442 // Bump up the priority if we determined it's NEVER_BIN on one tree, | 420 // Bump up the priority if we determined it's NEVER_BIN on one tree, |
443 // but is still required on the other tree. | 421 // but is still required on the other tree. |
444 bool is_in_never_bin_on_both_trees = tree_bin[ACTIVE_TREE] == NEVER_BIN && | 422 bool is_in_never_bin_on_both_trees = tree_bin[ACTIVE_TREE] == NEVER_BIN && |
445 tree_bin[PENDING_TREE] == NEVER_BIN; | 423 tree_bin[PENDING_TREE] == NEVER_BIN; |
446 | 424 |
447 if (mts.bin == NEVER_BIN && !is_in_never_bin_on_both_trees) | 425 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; | 426 mts.bin = tile_is_active ? AT_LAST_AND_ACTIVE_BIN : AT_LAST_BIN; |
449 | 427 |
450 mts.resolution = tile_priority.resolution; | 428 mts.resolution = tile_priority.resolution; |
451 mts.time_to_needed_in_seconds = tile_priority.time_to_visible_in_seconds; | 429 mts.priority_bin = tile_priority.priority_bin; |
452 mts.distance_to_visible_in_pixels = | 430 mts.distance_to_visible = |
453 tile_priority.distance_to_visible_in_pixels; | 431 tile_priority.distance_to_visible; |
454 mts.required_for_activation = tile_priority.required_for_activation; | 432 mts.required_for_activation = tile_priority.required_for_activation; |
455 | 433 |
456 mts.visible_and_ready_to_draw = | 434 mts.visible_and_ready_to_draw = |
457 tree_bin[ACTIVE_TREE] == NOW_AND_READY_TO_DRAW_BIN; | 435 tree_bin[ACTIVE_TREE] == NOW_AND_READY_TO_DRAW_BIN; |
458 | 436 |
459 if (mts.bin == NEVER_BIN) { | 437 if (mts.bin == NEVER_BIN) { |
460 FreeResourcesForTile(tile); | 438 FreeResourcesForTile(tile); |
461 continue; | 439 continue; |
462 } | 440 } |
463 | 441 |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
945 resource_pool_->ReleaseResource(resource.Pass()); | 923 resource_pool_->ReleaseResource(resource.Pass()); |
946 } else { | 924 } else { |
947 tile_version.set_use_resource(); | 925 tile_version.set_use_resource(); |
948 tile_version.resource_ = resource.Pass(); | 926 tile_version.resource_ = resource.Pass(); |
949 | 927 |
950 bytes_releasable_ += BytesConsumedIfAllocated(tile); | 928 bytes_releasable_ += BytesConsumedIfAllocated(tile); |
951 ++resources_releasable_; | 929 ++resources_releasable_; |
952 } | 930 } |
953 | 931 |
954 FreeUnusedResourcesForTile(tile); | 932 FreeUnusedResourcesForTile(tile); |
955 if (tile->priority(ACTIVE_TREE).distance_to_visible_in_pixels == 0) | 933 if (tile->priority(ACTIVE_TREE).distance_to_visible == 0) |
enne (OOO)
2014/01/31 23:07:46
style nit: 0.f
vmpstr
2014/02/03 20:27:24
Done.
| |
956 did_initialize_visible_tile_ = true; | 934 did_initialize_visible_tile_ = true; |
957 } | 935 } |
958 | 936 |
959 scoped_refptr<Tile> TileManager::CreateTile(PicturePileImpl* picture_pile, | 937 scoped_refptr<Tile> TileManager::CreateTile(PicturePileImpl* picture_pile, |
960 const gfx::Size& tile_size, | 938 const gfx::Size& tile_size, |
961 const gfx::Rect& content_rect, | 939 const gfx::Rect& content_rect, |
962 const gfx::Rect& opaque_rect, | 940 const gfx::Rect& opaque_rect, |
963 float contents_scale, | 941 float contents_scale, |
964 int layer_id, | 942 int layer_id, |
965 int source_frame_number, | 943 int source_frame_number, |
966 int flags) { | 944 int flags) { |
967 scoped_refptr<Tile> tile = make_scoped_refptr(new Tile(this, | 945 scoped_refptr<Tile> tile = make_scoped_refptr(new Tile(this, |
968 picture_pile, | 946 picture_pile, |
969 tile_size, | 947 tile_size, |
970 content_rect, | 948 content_rect, |
971 opaque_rect, | 949 opaque_rect, |
972 contents_scale, | 950 contents_scale, |
973 layer_id, | 951 layer_id, |
974 source_frame_number, | 952 source_frame_number, |
975 flags)); | 953 flags)); |
976 DCHECK(tiles_.find(tile->id()) == tiles_.end()); | 954 DCHECK(tiles_.find(tile->id()) == tiles_.end()); |
977 | 955 |
978 tiles_[tile->id()] = tile; | 956 tiles_[tile->id()] = tile; |
979 used_layer_counts_[tile->layer_id()]++; | 957 used_layer_counts_[tile->layer_id()]++; |
980 prioritized_tiles_dirty_ = true; | 958 prioritized_tiles_dirty_ = true; |
981 return tile; | 959 return tile; |
982 } | 960 } |
983 | 961 |
984 } // namespace cc | 962 } // namespace cc |
OLD | NEW |