Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1213)

Side by Side Diff: cc/resources/tile_manager.cc

Issue 140513006: cc: Simplify picture layer tiling update tile priorities. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed dead code Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/resources/prioritized_tile_set_unittest.cc ('k') | cc/resources/tile_priority.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 422
443 // Bump up the priority if we determined it's NEVER_BIN on one tree, 423 // Bump up the priority if we determined it's NEVER_BIN on one tree,
444 // but is still required on the other tree. 424 // but is still required on the other tree.
445 bool is_in_never_bin_on_both_trees = tree_bin[ACTIVE_TREE] == NEVER_BIN && 425 bool is_in_never_bin_on_both_trees = tree_bin[ACTIVE_TREE] == NEVER_BIN &&
446 tree_bin[PENDING_TREE] == NEVER_BIN; 426 tree_bin[PENDING_TREE] == NEVER_BIN;
447 427
448 if (mts.bin == NEVER_BIN && !is_in_never_bin_on_both_trees) 428 if (mts.bin == NEVER_BIN && !is_in_never_bin_on_both_trees)
449 mts.bin = tile_is_active ? AT_LAST_AND_ACTIVE_BIN : AT_LAST_BIN; 429 mts.bin = tile_is_active ? AT_LAST_AND_ACTIVE_BIN : AT_LAST_BIN;
450 430
451 mts.resolution = tile_priority.resolution; 431 mts.resolution = tile_priority.resolution;
452 mts.time_to_needed_in_seconds = tile_priority.time_to_visible_in_seconds; 432 mts.priority_bin = tile_priority.priority_bin;
453 mts.distance_to_visible_in_pixels = 433 mts.distance_to_visible = tile_priority.distance_to_visible;
454 tile_priority.distance_to_visible_in_pixels;
455 mts.required_for_activation = tile_priority.required_for_activation; 434 mts.required_for_activation = tile_priority.required_for_activation;
456 435
457 mts.visible_and_ready_to_draw = 436 mts.visible_and_ready_to_draw =
458 tree_bin[ACTIVE_TREE] == NOW_AND_READY_TO_DRAW_BIN; 437 tree_bin[ACTIVE_TREE] == NOW_AND_READY_TO_DRAW_BIN;
459 438
460 if (mts.bin == NEVER_BIN) { 439 if (mts.bin == NEVER_BIN) {
461 FreeResourcesForTile(tile); 440 FreeResourcesForTile(tile);
462 continue; 441 continue;
463 } 442 }
464 443
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 resource_pool_->ReleaseResource(resource.Pass()); 927 resource_pool_->ReleaseResource(resource.Pass());
949 } else { 928 } else {
950 tile_version.set_use_resource(); 929 tile_version.set_use_resource();
951 tile_version.resource_ = resource.Pass(); 930 tile_version.resource_ = resource.Pass();
952 931
953 bytes_releasable_ += BytesConsumedIfAllocated(tile); 932 bytes_releasable_ += BytesConsumedIfAllocated(tile);
954 ++resources_releasable_; 933 ++resources_releasable_;
955 } 934 }
956 935
957 FreeUnusedResourcesForTile(tile); 936 FreeUnusedResourcesForTile(tile);
958 if (tile->priority(ACTIVE_TREE).distance_to_visible_in_pixels == 0) 937 if (tile->priority(ACTIVE_TREE).distance_to_visible == 0.f)
959 did_initialize_visible_tile_ = true; 938 did_initialize_visible_tile_ = true;
960 } 939 }
961 940
962 scoped_refptr<Tile> TileManager::CreateTile(PicturePileImpl* picture_pile, 941 scoped_refptr<Tile> TileManager::CreateTile(PicturePileImpl* picture_pile,
963 const gfx::Size& tile_size, 942 const gfx::Size& tile_size,
964 const gfx::Rect& content_rect, 943 const gfx::Rect& content_rect,
965 const gfx::Rect& opaque_rect, 944 const gfx::Rect& opaque_rect,
966 float contents_scale, 945 float contents_scale,
967 int layer_id, 946 int layer_id,
968 int source_frame_number, 947 int source_frame_number,
969 int flags) { 948 int flags) {
970 scoped_refptr<Tile> tile = make_scoped_refptr(new Tile(this, 949 scoped_refptr<Tile> tile = make_scoped_refptr(new Tile(this,
971 picture_pile, 950 picture_pile,
972 tile_size, 951 tile_size,
973 content_rect, 952 content_rect,
974 opaque_rect, 953 opaque_rect,
975 contents_scale, 954 contents_scale,
976 layer_id, 955 layer_id,
977 source_frame_number, 956 source_frame_number,
978 flags)); 957 flags));
979 DCHECK(tiles_.find(tile->id()) == tiles_.end()); 958 DCHECK(tiles_.find(tile->id()) == tiles_.end());
980 959
981 tiles_[tile->id()] = tile; 960 tiles_[tile->id()] = tile;
982 used_layer_counts_[tile->layer_id()]++; 961 used_layer_counts_[tile->layer_id()]++;
983 prioritized_tiles_dirty_ = true; 962 prioritized_tiles_dirty_ = true;
984 return tile; 963 return tile;
985 } 964 }
986 965
987 } // namespace cc 966 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/prioritized_tile_set_unittest.cc ('k') | cc/resources/tile_priority.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698