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

Unified Diff: cc/tile_priority.h

Issue 12084031: A host of micro-optimizations and a refactor of TimeForBoundsToIntersect (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebasing to tip of tree Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/tile_manager.cc ('k') | cc/tile_priority.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tile_priority.h
diff --git a/cc/tile_priority.h b/cc/tile_priority.h
index 7672a38dcd64ad4d21e16a25271b189a771b505b..ae07d5a7b541708f502c286ffeaea7b60b493bed 100644
--- a/cc/tile_priority.h
+++ b/cc/tile_priority.h
@@ -89,18 +89,30 @@ struct CC_EXPORT TilePriority {
pending.distance_to_visible_in_pixels);
}
- static const double kMaxTimeToVisibleInSeconds;
- static const double kMaxDistanceInContentSpace;
-
- static int manhattanDistance(const gfx::RectF& a, const gfx::RectF& b);
+ static const float kMaxDistanceInContentSpace;
+
+ static inline float manhattanDistance(const gfx::RectF& a, const gfx::RectF& b) {
+ // Compute the union explicitly.
+ gfx::RectF c = gfx::RectF(
+ std::min(a.x(), b.x()),
+ std::min(a.y(), b.y()),
+ std::max(a.right(), b.right()) - std::min(a.x(), b.x()),
+ std::max(a.bottom(), b.bottom()) - std::min(a.y(), b.y()));
+
+ // Rects touching the edge of the screen should not be considered visible.
+ // So we add 1 pixel here to avoid that situation.
+ float x = std::max(0.0f, c.width() - a.width() - b.width() + 1.0f);
+ float y = std::max(0.0f, c.height() - a.height() - b.height() + 1.0f);
+ return (x + y);
+ }
// Calculate the time for the |current_bounds| to intersect with the
// |target_bounds| given its previous location and time delta.
// This function should work for both scaling and scrolling case.
- static double TimeForBoundsToIntersect(gfx::RectF previous_bounds,
- gfx::RectF current_bounds,
- double time_delta,
- gfx::RectF target_bounds);
+ static float TimeForBoundsToIntersect(const gfx::RectF& previous_bounds,
+ const gfx::RectF& current_bounds,
+ float time_delta,
+ const gfx::RectF& target_bounds);
// If a tile is not live, then all other fields are invalid.
bool is_live;
« no previous file with comments | « cc/tile_manager.cc ('k') | cc/tile_priority.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698