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

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: 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
Index: cc/tile_priority.h
diff --git a/cc/tile_priority.h b/cc/tile_priority.h
index fb900608eb175b42ce0ba5d587378ab923b93a31..e5e0bb8a41c6f4b43fc711438b1d2d02df200c00 100644
--- a/cc/tile_priority.h
+++ b/cc/tile_priority.h
@@ -61,17 +61,30 @@ struct CC_EXPORT TilePriority {
time_to_ideal_resolution_in_seconds);
}
- static const double kMaxTimeToVisibleInSeconds;
-
- static int manhattanDistance(const gfx::RectF& a, const gfx::RectF& b);
+ static const float kMaxTimeToVisibleInSeconds;
+
+ 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);
TileResolution resolution;
float time_to_visible_in_seconds;
« cc/picture_layer_tiling.cc ('K') | « cc/tile_manager.cc ('k') | cc/tile_priority.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698