| OLD | NEW |
| 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/base/tiling_data.h" | 5 #include "cc/base/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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 num_tiles_y_ = ComputeNumTiles( | 265 num_tiles_y_ = ComputeNumTiles( |
| 266 max_texture_size_.height(), total_size_.height(), border_texels_); | 266 max_texture_size_.height(), total_size_.height(), border_texels_); |
| 267 } | 267 } |
| 268 | 268 |
| 269 TilingData::BaseIterator::BaseIterator(const TilingData* tiling_data) | 269 TilingData::BaseIterator::BaseIterator(const TilingData* tiling_data) |
| 270 : tiling_data_(tiling_data), | 270 : tiling_data_(tiling_data), |
| 271 index_x_(-1), | 271 index_x_(-1), |
| 272 index_y_(-1) { | 272 index_y_(-1) { |
| 273 } | 273 } |
| 274 | 274 |
| 275 TilingData::Iterator::Iterator(const TilingData* tiling_data, gfx::Rect rect) | 275 TilingData::Iterator::Iterator(const TilingData* tiling_data, |
| 276 const gfx::Rect& tiling_rect) |
| 276 : BaseIterator(tiling_data), | 277 : BaseIterator(tiling_data), |
| 277 left_(-1), | 278 left_(-1), |
| 278 right_(-1), | 279 right_(-1), |
| 279 bottom_(-1) { | 280 bottom_(-1) { |
| 280 if (tiling_data_->num_tiles_x() <= 0 || tiling_data_->num_tiles_y() <= 0) { | 281 if (tiling_data_->num_tiles_x() <= 0 || tiling_data_->num_tiles_y() <= 0) { |
| 281 done(); | 282 done(); |
| 282 return; | 283 return; |
| 283 } | 284 } |
| 284 | 285 |
| 286 gfx::Rect rect(tiling_rect); |
| 285 rect.Intersect(gfx::Rect(tiling_data_->total_size())); | 287 rect.Intersect(gfx::Rect(tiling_data_->total_size())); |
| 286 index_x_ = tiling_data_->FirstBorderTileXIndexFromSrcCoord(rect.x()); | 288 index_x_ = tiling_data_->FirstBorderTileXIndexFromSrcCoord(rect.x()); |
| 287 index_y_ = tiling_data_->FirstBorderTileYIndexFromSrcCoord(rect.y()); | 289 index_y_ = tiling_data_->FirstBorderTileYIndexFromSrcCoord(rect.y()); |
| 288 left_ = index_x_; | 290 left_ = index_x_; |
| 289 right_ = tiling_data_->LastBorderTileXIndexFromSrcCoord(rect.right() - 1); | 291 right_ = tiling_data_->LastBorderTileXIndexFromSrcCoord(rect.right() - 1); |
| 290 bottom_ = tiling_data_->LastBorderTileYIndexFromSrcCoord(rect.bottom() - 1); | 292 bottom_ = tiling_data_->LastBorderTileYIndexFromSrcCoord(rect.bottom() - 1); |
| 291 | 293 |
| 292 // Index functions always return valid indices, so explicitly check | 294 // Index functions always return valid indices, so explicitly check |
| 293 // for non-intersecting rects. | 295 // for non-intersecting rects. |
| 294 gfx::Rect new_rect = tiling_data_->TileBoundsWithBorder(index_x_, index_y_); | 296 gfx::Rect new_rect = tiling_data_->TileBoundsWithBorder(index_x_, index_y_); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 306 index_y_++; | 308 index_y_++; |
| 307 if (index_y_ > bottom_) | 309 if (index_y_ > bottom_) |
| 308 done(); | 310 done(); |
| 309 } | 311 } |
| 310 | 312 |
| 311 return *this; | 313 return *this; |
| 312 } | 314 } |
| 313 | 315 |
| 314 TilingData::DifferenceIterator::DifferenceIterator( | 316 TilingData::DifferenceIterator::DifferenceIterator( |
| 315 const TilingData* tiling_data, | 317 const TilingData* tiling_data, |
| 316 gfx::Rect consider, | 318 const gfx::Rect& consider_rect, |
| 317 gfx::Rect ignore) | 319 const gfx::Rect& ignore_rect) |
| 318 : BaseIterator(tiling_data), | 320 : BaseIterator(tiling_data), |
| 319 consider_left_(-1), | 321 consider_left_(-1), |
| 320 consider_top_(-1), | 322 consider_top_(-1), |
| 321 consider_right_(-1), | 323 consider_right_(-1), |
| 322 consider_bottom_(-1), | 324 consider_bottom_(-1), |
| 323 ignore_left_(-1), | 325 ignore_left_(-1), |
| 324 ignore_top_(-1), | 326 ignore_top_(-1), |
| 325 ignore_right_(-1), | 327 ignore_right_(-1), |
| 326 ignore_bottom_(-1) { | 328 ignore_bottom_(-1) { |
| 327 if (tiling_data_->num_tiles_x() <= 0 || tiling_data_->num_tiles_y() <= 0) { | 329 if (tiling_data_->num_tiles_x() <= 0 || tiling_data_->num_tiles_y() <= 0) { |
| 328 done(); | 330 done(); |
| 329 return; | 331 return; |
| 330 } | 332 } |
| 331 | 333 |
| 332 gfx::Rect bounds(tiling_data_->total_size()); | 334 gfx::Rect bounds(tiling_data_->total_size()); |
| 335 gfx::Rect consider(consider_rect); |
| 336 gfx::Rect ignore(ignore_rect); |
| 333 consider.Intersect(bounds); | 337 consider.Intersect(bounds); |
| 334 ignore.Intersect(bounds); | 338 ignore.Intersect(bounds); |
| 335 if (consider.IsEmpty()) { | 339 if (consider.IsEmpty()) { |
| 336 done(); | 340 done(); |
| 337 return; | 341 return; |
| 338 } | 342 } |
| 339 | 343 |
| 340 consider_left_ = | 344 consider_left_ = |
| 341 tiling_data_->FirstBorderTileXIndexFromSrcCoord(consider.x()); | 345 tiling_data_->FirstBorderTileXIndexFromSrcCoord(consider.x()); |
| 342 consider_top_ = | 346 consider_top_ = |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 } | 403 } |
| 400 | 404 |
| 401 if (index_y_ > consider_bottom_) | 405 if (index_y_ > consider_bottom_) |
| 402 done(); | 406 done(); |
| 403 } | 407 } |
| 404 | 408 |
| 405 return *this; | 409 return *this; |
| 406 } | 410 } |
| 407 | 411 |
| 408 } // namespace cc | 412 } // namespace cc |
| OLD | NEW |