| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 | 426 |
| 447 // Bump up the priority if we determined it's NEVER_BIN on one tree, | 427 // Bump up the priority if we determined it's NEVER_BIN on one tree, |
| 448 // but is still required on the other tree. | 428 // but is still required on the other tree. |
| 449 bool is_in_never_bin_on_both_trees = tree_bin[ACTIVE_TREE] == NEVER_BIN && | 429 bool is_in_never_bin_on_both_trees = tree_bin[ACTIVE_TREE] == NEVER_BIN && |
| 450 tree_bin[PENDING_TREE] == NEVER_BIN; | 430 tree_bin[PENDING_TREE] == NEVER_BIN; |
| 451 | 431 |
| 452 if (mts.bin == NEVER_BIN && !is_in_never_bin_on_both_trees) | 432 if (mts.bin == NEVER_BIN && !is_in_never_bin_on_both_trees) |
| 453 mts.bin = tile_is_active ? AT_LAST_AND_ACTIVE_BIN : AT_LAST_BIN; | 433 mts.bin = tile_is_active ? AT_LAST_AND_ACTIVE_BIN : AT_LAST_BIN; |
| 454 | 434 |
| 455 mts.resolution = tile_priority.resolution; | 435 mts.resolution = tile_priority.resolution; |
| 456 mts.time_to_needed_in_seconds = tile_priority.time_to_visible_in_seconds; | 436 mts.priority_bin = tile_priority.priority_bin; |
| 457 mts.distance_to_visible_in_pixels = | 437 mts.distance_to_visible = tile_priority.distance_to_visible; |
| 458 tile_priority.distance_to_visible_in_pixels; | |
| 459 mts.required_for_activation = tile_priority.required_for_activation; | 438 mts.required_for_activation = tile_priority.required_for_activation; |
| 460 | 439 |
| 461 mts.visible_and_ready_to_draw = | 440 mts.visible_and_ready_to_draw = |
| 462 tree_bin[ACTIVE_TREE] == NOW_AND_READY_TO_DRAW_BIN; | 441 tree_bin[ACTIVE_TREE] == NOW_AND_READY_TO_DRAW_BIN; |
| 463 | 442 |
| 464 if (mts.bin == NEVER_BIN) { | 443 if (mts.bin == NEVER_BIN) { |
| 465 FreeResourcesForTile(tile); | 444 FreeResourcesForTile(tile); |
| 466 continue; | 445 continue; |
| 467 } | 446 } |
| 468 | 447 |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 resource_pool_->ReleaseResource(resource.Pass()); | 931 resource_pool_->ReleaseResource(resource.Pass()); |
| 953 } else { | 932 } else { |
| 954 tile_version.set_use_resource(); | 933 tile_version.set_use_resource(); |
| 955 tile_version.resource_ = resource.Pass(); | 934 tile_version.resource_ = resource.Pass(); |
| 956 | 935 |
| 957 bytes_releasable_ += BytesConsumedIfAllocated(tile); | 936 bytes_releasable_ += BytesConsumedIfAllocated(tile); |
| 958 ++resources_releasable_; | 937 ++resources_releasable_; |
| 959 } | 938 } |
| 960 | 939 |
| 961 FreeUnusedResourcesForTile(tile); | 940 FreeUnusedResourcesForTile(tile); |
| 962 if (tile->priority(ACTIVE_TREE).distance_to_visible_in_pixels == 0) | 941 if (tile->priority(ACTIVE_TREE).distance_to_visible == 0.f) |
| 963 did_initialize_visible_tile_ = true; | 942 did_initialize_visible_tile_ = true; |
| 964 } | 943 } |
| 965 | 944 |
| 966 scoped_refptr<Tile> TileManager::CreateTile(PicturePileImpl* picture_pile, | 945 scoped_refptr<Tile> TileManager::CreateTile(PicturePileImpl* picture_pile, |
| 967 const gfx::Size& tile_size, | 946 const gfx::Size& tile_size, |
| 968 const gfx::Rect& content_rect, | 947 const gfx::Rect& content_rect, |
| 969 const gfx::Rect& opaque_rect, | 948 const gfx::Rect& opaque_rect, |
| 970 float contents_scale, | 949 float contents_scale, |
| 971 int layer_id, | 950 int layer_id, |
| 972 int source_frame_number, | 951 int source_frame_number, |
| 973 int flags) { | 952 int flags) { |
| 974 scoped_refptr<Tile> tile = make_scoped_refptr(new Tile(this, | 953 scoped_refptr<Tile> tile = make_scoped_refptr(new Tile(this, |
| 975 picture_pile, | 954 picture_pile, |
| 976 tile_size, | 955 tile_size, |
| 977 content_rect, | 956 content_rect, |
| 978 opaque_rect, | 957 opaque_rect, |
| 979 contents_scale, | 958 contents_scale, |
| 980 layer_id, | 959 layer_id, |
| 981 source_frame_number, | 960 source_frame_number, |
| 982 flags)); | 961 flags)); |
| 983 DCHECK(tiles_.find(tile->id()) == tiles_.end()); | 962 DCHECK(tiles_.find(tile->id()) == tiles_.end()); |
| 984 | 963 |
| 985 tiles_[tile->id()] = tile; | 964 tiles_[tile->id()] = tile; |
| 986 used_layer_counts_[tile->layer_id()]++; | 965 used_layer_counts_[tile->layer_id()]++; |
| 987 prioritized_tiles_dirty_ = true; | 966 prioritized_tiles_dirty_ = true; |
| 988 return tile; | 967 return tile; |
| 989 } | 968 } |
| 990 | 969 |
| 991 } // namespace cc | 970 } // namespace cc |
| OLD | NEW |