summaryrefslogtreecommitdiffstats
path: root/cc/base/tiling_data.cc
diff options
context:
space:
mode:
authortomhudson@chromium.org <tomhudson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 00:44:34 +0000
committertomhudson@chromium.org <tomhudson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 00:44:34 +0000
commit7a4a1d8d86a86f87f301fe0969d04871ec800939 (patch)
tree0fd36f63f2b2617dd777580d300ee6f202cce5fa /cc/base/tiling_data.cc
parente1b5ee79c11c375e4207bec2aac6753f280c66e9 (diff)
downloadchromium_src-7a4a1d8d86a86f87f301fe0969d04871ec800939.zip
chromium_src-7a4a1d8d86a86f87f301fe0969d04871ec800939.tar.gz
chromium_src-7a4a1d8d86a86f87f301fe0969d04871ec800939.tar.bz2
Optimize TilingData::TileBoundsWithBorder().
TileBoundsWithBorder called TileBounds(), then had a bunch of if statements that undid all of the if statements in TileBounds. It's more efficient just to do the computation directly, without the function call and with far fewer conditionals; in infinite scrolling test pages (http://groupcloned.com/test/) we see typically 100 calls WithBorder and 200 without border in the compositor on every frame, as well as a few dozen calls of each on the renderer and rasterizer threads. This seems to provide a 1-2% speedup across most of cc_perftests on N7-class hardware. BUG= Review URL: https://chromiumcodereview.appspot.com/15896002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201942 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/base/tiling_data.cc')
-rw-r--r--cc/base/tiling_data.cc52
1 files changed, 28 insertions, 24 deletions
diff --git a/cc/base/tiling_data.cc b/cc/base/tiling_data.cc
index ba6aaa8..1045d89 100644
--- a/cc/base/tiling_data.cc
+++ b/cc/base/tiling_data.cc
@@ -146,14 +146,13 @@ gfx::Rect TilingData::TileBounds(int i, int j) const {
int hi_x = max_texture_size_x * (i + 1) + border_texels_;
if (i + 1 == num_tiles_x_)
hi_x += border_texels_;
- if (hi_x > total_size_x)
- hi_x = total_size_x;
int hi_y = max_texture_size_y * (j + 1) + border_texels_;
if (j + 1 == num_tiles_y_)
hi_y += border_texels_;
- if (hi_y > total_size_y)
- hi_y = total_size_y;
+
+ hi_x = std::min(hi_x, total_size_x);
+ hi_y = std::min(hi_y, total_size_y);
int x = lo_x;
int y = lo_y;
@@ -169,27 +168,32 @@ gfx::Rect TilingData::TileBounds(int i, int j) const {
}
gfx::Rect TilingData::TileBoundsWithBorder(int i, int j) const {
- gfx::Rect bounds = TileBounds(i, j);
-
- if (border_texels_) {
- int x1 = bounds.x();
- int x2 = bounds.right();
- int y1 = bounds.y();
- int y2 = bounds.bottom();
-
- if (i > 0)
- x1-= border_texels_;
- if (i < (num_tiles_x_ - 1))
- x2+= border_texels_;
- if (j > 0)
- y1-= border_texels_;
- if (j < (num_tiles_y_ - 1))
- y2+= border_texels_;
-
- bounds = gfx::Rect(x1, y1, x2 - x1, y2 - y1);
- }
+ AssertTile(i, j);
+ int max_texture_size_x = max_texture_size_.width() - 2 * border_texels_;
+ int max_texture_size_y = max_texture_size_.height() - 2 * border_texels_;
+ int total_size_x = total_size_.width();
+ int total_size_y = total_size_.height();
+
+ int lo_x = max_texture_size_x * i;
+ int lo_y = max_texture_size_y * j;
+
+ int hi_x = lo_x + max_texture_size_x + 2 * border_texels_;
+ int hi_y = lo_y + max_texture_size_y + 2 * border_texels_;
+
+ hi_x = std::min(hi_x, total_size_x);
+ hi_y = std::min(hi_y, total_size_y);
- return bounds;
+ int x = lo_x;
+ int y = lo_y;
+ int width = hi_x - lo_x;
+ int height = hi_y - lo_y;
+ DCHECK_GE(x, 0);
+ DCHECK_GE(y, 0);
+ DCHECK_GE(width, 0);
+ DCHECK_GE(height, 0);
+ DCHECK_LE(x, total_size_.width());
+ DCHECK_LE(y, total_size_.height());
+ return gfx::Rect(x, y, width, height);
}
int TilingData::TilePositionX(int x_index) const {