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

Side by Side Diff: cc/tiling_data.cc

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, 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
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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/tiling_data.h" 5 #include "cc/tiling_data.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ui/gfx/rect.h" 9 #include "ui/gfx/rect.h"
10 #include "ui/gfx/vector2d.h" 10 #include "ui/gfx/vector2d.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 return 0; 94 return 0;
95 95
96 DCHECK_GT(max_texture_size_.height() - 2 * border_texels_, 0); 96 DCHECK_GT(max_texture_size_.height() - 2 * border_texels_, 0);
97 int inner_tile_size = max_texture_size_.height() - 2 * border_texels_; 97 int inner_tile_size = max_texture_size_.height() - 2 * border_texels_;
98 int y = (src_position - 2 * border_texels_) / inner_tile_size; 98 int y = (src_position - 2 * border_texels_) / inner_tile_size;
99 return std::min(std::max(y, 0), num_tiles_y_ - 1); 99 return std::min(std::max(y, 0), num_tiles_y_ - 1);
100 } 100 }
101 101
102 gfx::Rect TilingData::TileBounds(int i, int j) const { 102 gfx::Rect TilingData::TileBounds(int i, int j) const {
103 AssertTile(i, j); 103 AssertTile(i, j);
104 int x = TilePositionX(i); 104 int max_texture_size_x = max_texture_size_.width() - 2 * border_texels_;
105 int y = TilePositionY(j); 105 int max_texture_size_y = max_texture_size_.height() - 2 * border_texels_;
106 int width = TileSizeX(i); 106 int total_size_x = total_size_.width();
107 int height = TileSizeY(j); 107 int total_size_y = total_size_.height();
108
109 int lo_x = max_texture_size_x * i;
110 if (i != 0)
111 lo_x += border_texels_;
112
113 int lo_y = max_texture_size_y * j;
114 if (j != 0)
115 lo_y += border_texels_;
116
117 int hi_x = max_texture_size_x * (i + 1) + border_texels_;
118 if (i + 1 == num_tiles_x_)
119 hi_x += border_texels_;
120 if (hi_x > total_size_x)
121 hi_x = total_size_x;
122
123 int hi_y = max_texture_size_y * (j + 1) + border_texels_;
124 if (j + 1 == num_tiles_y_)
125 hi_y += border_texels_;
126 if (hi_y > total_size_y)
127 hi_y = total_size_y;
128
129 int x = lo_x;
130 int y = lo_y;
131 int width = hi_x - lo_x;
132 int height = hi_y - lo_y;
108 DCHECK_GE(x, 0); 133 DCHECK_GE(x, 0);
109 DCHECK_GE(y, 0); 134 DCHECK_GE(y, 0);
110 DCHECK_GE(width, 0); 135 DCHECK_GE(width, 0);
111 DCHECK_GE(height, 0); 136 DCHECK_GE(height, 0);
112 DCHECK_LE(x, total_size_.width()); 137 DCHECK_LE(x, total_size_.width());
113 DCHECK_LE(y, total_size_.height()); 138 DCHECK_LE(y, total_size_.height());
114 return gfx::Rect(x, y, width, height); 139 return gfx::Rect(x, y, width, height);
115 } 140 }
116 141
117 gfx::Rect TilingData::TileBoundsWithBorder(int i, int j) const { 142 gfx::Rect TilingData::TileBoundsWithBorder(int i, int j) const {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 TilingData::Iterator::operator bool() const { 281 TilingData::Iterator::operator bool() const {
257 return index_x_ != -1 && index_y_ != -1; 282 return index_x_ != -1 && index_y_ != -1;
258 } 283 }
259 284
260 void TilingData::Iterator::done() { 285 void TilingData::Iterator::done() {
261 index_x_ = -1; 286 index_x_ = -1;
262 index_y_ = -1; 287 index_y_ = -1;
263 } 288 }
264 289
265 } // namespace cc 290 } // namespace cc
OLDNEW
« cc/picture_layer_tiling.cc ('K') | « cc/tile_priority.cc ('k') | ui/gfx/rect_f.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698