diff options
author | reveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-27 07:42:08 +0000 |
---|---|---|
committer | reveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-27 07:42:08 +0000 |
commit | 3eb24ca27b6b3335049742551372ffb857f5dc29 (patch) | |
tree | 9cfb213c05cf2eeaecb7c4ea9f5258c1275b9ece /cc | |
parent | ba0a45470676430bc1eed0016407d33938ec6d34 (diff) | |
download | chromium_src-3eb24ca27b6b3335049742551372ffb857f5dc29.zip chromium_src-3eb24ca27b6b3335049742551372ffb857f5dc29.tar.gz chromium_src-3eb24ca27b6b3335049742551372ffb857f5dc29.tar.bz2 |
cc: BinFromTilePriority cleanup.
BUG=
Review URL: https://codereview.chromium.org/24783002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225677 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/resources/picture_layer_tiling.cc | 28 | ||||
-rw-r--r-- | cc/resources/tile_manager.cc | 149 | ||||
-rw-r--r-- | cc/resources/tile_priority.h | 6 |
3 files changed, 98 insertions, 85 deletions
diff --git a/cc/resources/picture_layer_tiling.cc b/cc/resources/picture_layer_tiling.cc index 12bfb18..4d21e65 100644 --- a/cc/resources/picture_layer_tiling.cc +++ b/cc/resources/picture_layer_tiling.cc @@ -423,10 +423,6 @@ void PictureLayerTiling::UpdateTilePriorities( float current_scale = current_layer_contents_scale / contents_scale_; float last_scale = last_layer_contents_scale / contents_scale_; - bool store_screen_space_quads_on_tiles; - TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("cc.debug"), - &store_screen_space_quads_on_tiles); - // Fast path tile priority calculation when both transforms are translations. if (ApproximatelyTranslation(last_screen_transform.matrix()) && ApproximatelyTranslation(current_screen_transform.matrix())) { @@ -465,8 +461,6 @@ void PictureLayerTiling::UpdateTilePriorities( resolution_, time_to_visible_in_seconds, distance_to_visible_in_pixels); - if (store_screen_space_quads_on_tiles) - priority.set_current_screen_quad(gfx::QuadF(current_screen_rect)); tile->SetPriority(tree, priority); } } else if (!last_screen_transform.HasPerspective() && @@ -547,21 +541,6 @@ void PictureLayerTiling::UpdateTilePriorities( resolution_, time_to_visible_in_seconds, distance_to_visible_in_pixels); - - if (store_screen_space_quads_on_tiles) { - // This overhead is only triggered when logging event tracing data. - gfx::Rect tile_bounds = - tiling_data_.TileBounds(iter.index_x(), iter.index_y()); - gfx::RectF current_layer_content_rect = gfx::ScaleRect( - tile_bounds, - current_scale, - current_scale); - bool clipped; - priority.set_current_screen_quad( - MathUtil::MapQuad(current_screen_transform, - gfx::QuadF(current_layer_content_rect), - &clipped)); - } tile->SetPriority(tree, priority); } } else { @@ -598,13 +577,6 @@ void PictureLayerTiling::UpdateTilePriorities( resolution_, time_to_visible_in_seconds, distance_to_visible_in_pixels); - if (store_screen_space_quads_on_tiles) { - bool clipped; - priority.set_current_screen_quad( - MathUtil::MapQuad(current_screen_transform, - gfx::QuadF(current_layer_content_rect), - &clipped)); - } tile->SetPriority(tree, priority); } } diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc index a70c5d5..a0a1822610 100644 --- a/cc/resources/tile_manager.cc +++ b/cc/resources/tile_manager.cc @@ -34,67 +34,105 @@ const ManagedTileBin kBinPolicyMap[NUM_TILE_MEMORY_LIMIT_POLICIES][NUM_BINS] = { NEVER_BIN, // [EVENTUALLY_BIN] NEVER_BIN, // [AT_LAST_AND_ACTIVE_BIN] NEVER_BIN, // [AT_LAST_BIN] - NEVER_BIN // [NEVER_BIN] + NEVER_BIN }, { // [ALLOW_ABSOLUTE_MINIMUM] - NOW_AND_READY_TO_DRAW_BIN, // [NOW_AND_READY_TO_DRAW_BIN] - NOW_BIN, // [NOW_BIN] + NOW_AND_READY_TO_DRAW_BIN, + NOW_BIN, NEVER_BIN, // [SOON_BIN] NEVER_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] NEVER_BIN, // [EVENTUALLY_BIN] NEVER_BIN, // [AT_LAST_AND_ACTIVE_BIN] NEVER_BIN, // [AT_LAST_BIN] - NEVER_BIN // [NEVER_BIN] + NEVER_BIN }, { // [ALLOW_PREPAINT_ONLY] - NOW_AND_READY_TO_DRAW_BIN, // [NOW_AND_READY_TO_DRAW_BIN] - NOW_BIN, // [NOW_BIN] - SOON_BIN, // [SOON_BIN] + NOW_AND_READY_TO_DRAW_BIN, + NOW_BIN, + SOON_BIN, NEVER_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] NEVER_BIN, // [EVENTUALLY_BIN] NEVER_BIN, // [AT_LAST_AND_ACTIVE_BIN] NEVER_BIN, // [AT_LAST_BIN] - NEVER_BIN // [NEVER_BIN] + NEVER_BIN }, { // [ALLOW_ANYTHING] - NOW_AND_READY_TO_DRAW_BIN, // [NOW_AND_READY_TO_DRAW_BIN] - NOW_BIN, // [NOW_BIN] - SOON_BIN, // [SOON_BIN] - EVENTUALLY_AND_ACTIVE_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] - EVENTUALLY_BIN, // [EVENTUALLY_BIN] - AT_LAST_AND_ACTIVE_BIN, // [AT_LAST_AND_ACTIVE_BIN] - AT_LAST_BIN, // [AT_LAST_BIN] - NEVER_BIN // [NEVER_BIN] + NOW_AND_READY_TO_DRAW_BIN, + NOW_BIN, + SOON_BIN, + EVENTUALLY_AND_ACTIVE_BIN, + EVENTUALLY_BIN, + AT_LAST_AND_ACTIVE_BIN, + AT_LAST_BIN, + NEVER_BIN + } +}; + +// Ready to draw works by mapping NOW_BIN to NOW_AND_READY_TO_DRAW_BIN. +const ManagedTileBin kBinReadyToDrawMap[2][NUM_BINS] = { + { // Not ready + NOW_AND_READY_TO_DRAW_BIN, + NOW_BIN, + SOON_BIN, + EVENTUALLY_AND_ACTIVE_BIN, + EVENTUALLY_BIN, + AT_LAST_AND_ACTIVE_BIN, + AT_LAST_BIN, + NEVER_BIN + }, { // Ready + NOW_AND_READY_TO_DRAW_BIN, + NOW_AND_READY_TO_DRAW_BIN, // [NOW_BIN] + SOON_BIN, + EVENTUALLY_AND_ACTIVE_BIN, + EVENTUALLY_BIN, + AT_LAST_AND_ACTIVE_BIN, + AT_LAST_BIN, + NEVER_BIN + } +}; + +// Active works by mapping some bin stats to equivalent _ACTIVE_BIN state. +const ManagedTileBin kBinIsActiveMap[2][NUM_BINS] = { + { // Inactive + NOW_AND_READY_TO_DRAW_BIN, + NOW_BIN, + SOON_BIN, + EVENTUALLY_AND_ACTIVE_BIN, + EVENTUALLY_BIN, + AT_LAST_AND_ACTIVE_BIN, + AT_LAST_BIN, + NEVER_BIN + }, { // Active + NOW_AND_READY_TO_DRAW_BIN, + NOW_BIN, + SOON_BIN, + EVENTUALLY_AND_ACTIVE_BIN, + EVENTUALLY_AND_ACTIVE_BIN, // [EVENTUALLY_BIN] + AT_LAST_AND_ACTIVE_BIN, + AT_LAST_AND_ACTIVE_BIN, // [AT_LAST_BIN] + NEVER_BIN } }; // Determine bin based on three categories of tiles: things we need now, // things we need soon, and eventually. -inline ManagedTileBin BinFromTilePriority(const TilePriority& prio, - TreePriority tree_priority, - bool is_ready_to_draw, - bool is_active) { +inline ManagedTileBin BinFromTilePriority(const TilePriority& prio) { // The amount of time for which we want to have prepainting coverage. const float kPrepaintingWindowTimeSeconds = 1.0f; const float kBackflingGuardDistancePixels = 314.0f; - // Don't let low res tiles be in the now bin unless we're in a mode where - // we're prioritizing checkerboard prevention. - bool can_be_in_now_bin = tree_priority == SMOOTHNESS_TAKES_PRIORITY || - prio.resolution != LOW_RESOLUTION; - if (prio.distance_to_visible_in_pixels == std::numeric_limits<float>::infinity()) return NEVER_BIN; - if (can_be_in_now_bin && prio.time_to_visible_in_seconds == 0) - return is_ready_to_draw ? NOW_AND_READY_TO_DRAW_BIN : NOW_BIN; + if (prio.time_to_visible_in_seconds == 0) + return NOW_BIN; if (prio.resolution == NON_IDEAL_RESOLUTION) - return is_active ? EVENTUALLY_AND_ACTIVE_BIN : EVENTUALLY_BIN; + return EVENTUALLY_BIN; if (prio.distance_to_visible_in_pixels < kBackflingGuardDistancePixels || prio.time_to_visible_in_seconds < kPrepaintingWindowTimeSeconds) return SOON_BIN; - return is_active ? EVENTUALLY_AND_ACTIVE_BIN : EVENTUALLY_BIN; + return EVENTUALLY_BIN; } // Limit to the number of raster tasks that can be scheduled. @@ -316,44 +354,55 @@ void TileManager::GetTilesWithAssignedBins(PrioritizedTileSet* tiles) { // Get the active priority and bin. TilePriority active_priority = tile->priority(ACTIVE_TREE); - ManagedTileBin active_bin = BinFromTilePriority( - active_priority, tree_priority, tile_is_ready_to_draw, tile_is_active); - mts.tree_bin[ACTIVE_TREE] = kBinPolicyMap[memory_policy][active_bin]; + ManagedTileBin active_bin = BinFromTilePriority(active_priority); // Get the pending priority and bin. TilePriority pending_priority = tile->priority(PENDING_TREE); - ManagedTileBin pending_bin = BinFromTilePriority( - pending_priority, tree_priority, tile_is_ready_to_draw, tile_is_active); - mts.tree_bin[PENDING_TREE] = kBinPolicyMap[memory_policy][pending_bin]; + ManagedTileBin pending_bin = BinFromTilePriority(pending_priority); + + // Adjust pending bin state for low res tiles. This prevents + // pending tree low-res tiles from being initialized before + // high-res tiles. + if (pending_priority.resolution == LOW_RESOLUTION) + pending_bin = std::max(pending_bin, EVENTUALLY_BIN); + + // Compute combined bin. + ManagedTileBin combined_bin = std::min(active_bin, pending_bin); + + // Adjust bin state based on if ready to draw. + active_bin = kBinReadyToDrawMap[tile_is_ready_to_draw][active_bin]; + pending_bin = kBinReadyToDrawMap[tile_is_ready_to_draw][pending_bin]; + combined_bin = kBinReadyToDrawMap[tile_is_ready_to_draw][combined_bin]; - // Get the combined priority and bin. - TilePriority combined_priority = tile->combined_priority(); - ManagedTileBin combined_bin = BinFromTilePriority(combined_priority, - tree_priority, - tile_is_ready_to_draw, - tile_is_active); + // Adjust bin state based on if active. + active_bin = kBinIsActiveMap[tile_is_active][active_bin]; + pending_bin = kBinIsActiveMap[tile_is_active][pending_bin]; + combined_bin = kBinIsActiveMap[tile_is_active][combined_bin]; + + mts.tree_bin[ACTIVE_TREE] = kBinPolicyMap[memory_policy][active_bin]; + mts.tree_bin[PENDING_TREE] = kBinPolicyMap[memory_policy][pending_bin]; // The bin that the tile would have if the GPU memory manager had // a maximally permissive policy, send to the GPU memory manager // to determine policy. ManagedTileBin gpu_memmgr_stats_bin = NEVER_BIN; + TilePriority tile_priority; - TilePriority* high_priority = NULL; switch (tree_priority) { case SAME_PRIORITY_FOR_BOTH_TREES: mts.bin = kBinPolicyMap[memory_policy][combined_bin]; gpu_memmgr_stats_bin = combined_bin; - high_priority = &combined_priority; + tile_priority = tile->combined_priority(); break; case SMOOTHNESS_TAKES_PRIORITY: mts.bin = mts.tree_bin[ACTIVE_TREE]; gpu_memmgr_stats_bin = active_bin; - high_priority = &active_priority; + tile_priority = active_priority; break; case NEW_CONTENT_TAKES_PRIORITY: mts.bin = mts.tree_bin[PENDING_TREE]; gpu_memmgr_stats_bin = pending_bin; - high_priority = &pending_priority; + tile_priority = pending_priority; break; } @@ -374,13 +423,11 @@ void TileManager::GetTilesWithAssignedBins(PrioritizedTileSet* tiles) { if (mts.bin == NEVER_BIN && !is_in_never_bin_on_both_trees) mts.bin = tile_is_active ? AT_LAST_AND_ACTIVE_BIN : AT_LAST_BIN; - DCHECK(high_priority != NULL); - - mts.resolution = high_priority->resolution; - mts.time_to_needed_in_seconds = high_priority->time_to_visible_in_seconds; + mts.resolution = tile_priority.resolution; + mts.time_to_needed_in_seconds = tile_priority.time_to_visible_in_seconds; mts.distance_to_visible_in_pixels = - high_priority->distance_to_visible_in_pixels; - mts.required_for_activation = high_priority->required_for_activation; + tile_priority.distance_to_visible_in_pixels; + mts.required_for_activation = tile_priority.required_for_activation; mts.visible_and_ready_to_draw = mts.tree_bin[ACTIVE_TREE] == NOW_AND_READY_TO_DRAW_BIN; diff --git a/cc/resources/tile_priority.h b/cc/resources/tile_priority.h index 914b565b..e49114b 100644 --- a/cc/resources/tile_priority.h +++ b/cc/resources/tile_priority.h @@ -75,7 +75,6 @@ struct CC_EXPORT TilePriority { std::min(active.distance_to_visible_in_pixels, pending.distance_to_visible_in_pixels); } - void set_current_screen_quad(const gfx::QuadF& q) { current_screen_quad = q; } scoped_ptr<base::Value> AsValue() const; @@ -108,8 +107,6 @@ struct CC_EXPORT TilePriority { time_to_visible_in_seconds == other.time_to_visible_in_seconds && distance_to_visible_in_pixels == other.distance_to_visible_in_pixels && required_for_activation == other.required_for_activation; - // No need to compare current_screen_quad which is for debug only and - // never changes by itself. } bool operator !=(const TilePriority& other) const { @@ -120,9 +117,6 @@ struct CC_EXPORT TilePriority { bool required_for_activation; float time_to_visible_in_seconds; float distance_to_visible_in_pixels; - - private: - gfx::QuadF current_screen_quad; }; enum TileMemoryLimitPolicy { |