| 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 bool include_borders) | 306 bool include_borders) |
| 307 : BaseIterator(tiling_data), left_(-1), right_(-1), bottom_(-1) { | 307 : BaseIterator(tiling_data), left_(-1), right_(-1), bottom_(-1) { |
| 308 if (tiling_data_->num_tiles_x() <= 0 || tiling_data_->num_tiles_y() <= 0) { | 308 if (tiling_data_->num_tiles_x() <= 0 || tiling_data_->num_tiles_y() <= 0) { |
| 309 done(); | 309 done(); |
| 310 return; | 310 return; |
| 311 } | 311 } |
| 312 | 312 |
| 313 gfx::Rect tiling_bounds_rect(tiling_data_->tiling_size()); | 313 gfx::Rect tiling_bounds_rect(tiling_data_->tiling_size()); |
| 314 gfx::Rect rect(consider_rect); | 314 gfx::Rect rect(consider_rect); |
| 315 rect.Intersect(tiling_bounds_rect); | 315 rect.Intersect(tiling_bounds_rect); |
| 316 if (rect.IsEmpty()) { |
| 317 done(); |
| 318 return; |
| 319 } |
| 316 | 320 |
| 317 gfx::Rect top_left_tile; | 321 gfx::Rect top_left_tile; |
| 318 if (include_borders) { | 322 if (include_borders) { |
| 319 index_x_ = tiling_data_->FirstBorderTileXIndexFromSrcCoord(rect.x()); | 323 index_x_ = tiling_data_->FirstBorderTileXIndexFromSrcCoord(rect.x()); |
| 320 index_y_ = tiling_data_->FirstBorderTileYIndexFromSrcCoord(rect.y()); | 324 index_y_ = tiling_data_->FirstBorderTileYIndexFromSrcCoord(rect.y()); |
| 321 right_ = tiling_data_->LastBorderTileXIndexFromSrcCoord(rect.right() - 1); | 325 right_ = tiling_data_->LastBorderTileXIndexFromSrcCoord(rect.right() - 1); |
| 322 bottom_ = tiling_data_->LastBorderTileYIndexFromSrcCoord(rect.bottom() - 1); | 326 bottom_ = tiling_data_->LastBorderTileYIndexFromSrcCoord(rect.bottom() - 1); |
| 323 top_left_tile = tiling_data_->TileBoundsWithBorder(index_x_, index_y_); | 327 top_left_tile = tiling_data_->TileBoundsWithBorder(index_x_, index_y_); |
| 324 } else { | 328 } else { |
| 325 index_x_ = tiling_data_->TileXIndexFromSrcCoord(rect.x()); | 329 index_x_ = tiling_data_->TileXIndexFromSrcCoord(rect.x()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 347 if (index_y_ > bottom_) | 351 if (index_y_ > bottom_) |
| 348 done(); | 352 done(); |
| 349 } | 353 } |
| 350 | 354 |
| 351 return *this; | 355 return *this; |
| 352 } | 356 } |
| 353 | 357 |
| 354 TilingData::DifferenceIterator::DifferenceIterator( | 358 TilingData::DifferenceIterator::DifferenceIterator( |
| 355 const TilingData* tiling_data, | 359 const TilingData* tiling_data, |
| 356 const gfx::Rect& consider_rect, | 360 const gfx::Rect& consider_rect, |
| 357 const gfx::Rect& ignore_rect) | 361 const gfx::Rect& ignore_rect, |
| 362 bool include_borders) |
| 358 : BaseIterator(tiling_data), | 363 : BaseIterator(tiling_data), |
| 359 consider_left_(-1), | 364 consider_left_(-1), |
| 360 consider_top_(-1), | 365 consider_top_(-1), |
| 361 consider_right_(-1), | 366 consider_right_(-1), |
| 362 consider_bottom_(-1), | 367 consider_bottom_(-1), |
| 363 ignore_left_(-1), | 368 ignore_left_(-1), |
| 364 ignore_top_(-1), | 369 ignore_top_(-1), |
| 365 ignore_right_(-1), | 370 ignore_right_(-1), |
| 366 ignore_bottom_(-1) { | 371 ignore_bottom_(-1) { |
| 367 if (tiling_data_->num_tiles_x() <= 0 || tiling_data_->num_tiles_y() <= 0) { | 372 if (tiling_data_->num_tiles_x() <= 0 || tiling_data_->num_tiles_y() <= 0) { |
| 368 done(); | 373 done(); |
| 369 return; | 374 return; |
| 370 } | 375 } |
| 371 | 376 |
| 372 gfx::Rect tiling_bounds_rect(tiling_data_->tiling_size()); | 377 gfx::Rect tiling_bounds_rect(tiling_data_->tiling_size()); |
| 373 gfx::Rect consider(consider_rect); | 378 gfx::Rect consider(consider_rect); |
| 374 gfx::Rect ignore(ignore_rect); | 379 gfx::Rect ignore(ignore_rect); |
| 375 consider.Intersect(tiling_bounds_rect); | 380 consider.Intersect(tiling_bounds_rect); |
| 376 ignore.Intersect(tiling_bounds_rect); | 381 ignore.Intersect(tiling_bounds_rect); |
| 377 if (consider.IsEmpty()) { | 382 if (consider.IsEmpty()) { |
| 378 done(); | 383 done(); |
| 379 return; | 384 return; |
| 380 } | 385 } |
| 381 | 386 |
| 382 consider_left_ = | 387 if (include_borders) { |
| 383 tiling_data_->FirstBorderTileXIndexFromSrcCoord(consider.x()); | 388 consider_left_ = |
| 384 consider_top_ = | 389 tiling_data_->FirstBorderTileXIndexFromSrcCoord(consider.x()); |
| 385 tiling_data_->FirstBorderTileYIndexFromSrcCoord(consider.y()); | 390 consider_top_ = |
| 386 consider_right_ = | 391 tiling_data_->FirstBorderTileYIndexFromSrcCoord(consider.y()); |
| 387 tiling_data_->LastBorderTileXIndexFromSrcCoord(consider.right() - 1); | 392 consider_right_ = |
| 388 consider_bottom_ = | 393 tiling_data_->LastBorderTileXIndexFromSrcCoord(consider.right() - 1); |
| 389 tiling_data_->LastBorderTileYIndexFromSrcCoord(consider.bottom() - 1); | 394 consider_bottom_ = |
| 395 tiling_data_->LastBorderTileYIndexFromSrcCoord(consider.bottom() - 1); |
| 396 } else { |
| 397 consider_left_ = tiling_data_->TileXIndexFromSrcCoord(consider.x()); |
| 398 consider_top_ = tiling_data_->TileYIndexFromSrcCoord(consider.y()); |
| 399 consider_right_ = |
| 400 tiling_data_->TileXIndexFromSrcCoord(consider.right() - 1); |
| 401 consider_bottom_ = |
| 402 tiling_data_->TileYIndexFromSrcCoord(consider.bottom() - 1); |
| 403 } |
| 390 | 404 |
| 391 if (!ignore.IsEmpty()) { | 405 if (!ignore.IsEmpty()) { |
| 392 ignore_left_ = | 406 if (include_borders) { |
| 393 tiling_data_->FirstBorderTileXIndexFromSrcCoord(ignore.x()); | 407 ignore_left_ = |
| 394 ignore_top_ = | 408 tiling_data_->FirstBorderTileXIndexFromSrcCoord(ignore.x()); |
| 395 tiling_data_->FirstBorderTileYIndexFromSrcCoord(ignore.y()); | 409 ignore_top_ = tiling_data_->FirstBorderTileYIndexFromSrcCoord(ignore.y()); |
| 396 ignore_right_ = | 410 ignore_right_ = |
| 397 tiling_data_->LastBorderTileXIndexFromSrcCoord(ignore.right() - 1); | 411 tiling_data_->LastBorderTileXIndexFromSrcCoord(ignore.right() - 1); |
| 398 ignore_bottom_ = | 412 ignore_bottom_ = |
| 399 tiling_data_->LastBorderTileYIndexFromSrcCoord(ignore.bottom() - 1); | 413 tiling_data_->LastBorderTileYIndexFromSrcCoord(ignore.bottom() - 1); |
| 414 } else { |
| 415 ignore_left_ = tiling_data_->TileXIndexFromSrcCoord(ignore.x()); |
| 416 ignore_top_ = tiling_data_->TileYIndexFromSrcCoord(ignore.y()); |
| 417 ignore_right_ = tiling_data_->TileXIndexFromSrcCoord(ignore.right() - 1); |
| 418 ignore_bottom_ = |
| 419 tiling_data_->TileYIndexFromSrcCoord(ignore.bottom() - 1); |
| 420 } |
| 400 | 421 |
| 401 // Clamp ignore indices to consider indices. | 422 // Clamp ignore indices to consider indices. |
| 402 ignore_left_ = std::max(ignore_left_, consider_left_); | 423 ignore_left_ = std::max(ignore_left_, consider_left_); |
| 403 ignore_top_ = std::max(ignore_top_, consider_top_); | 424 ignore_top_ = std::max(ignore_top_, consider_top_); |
| 404 ignore_right_ = std::min(ignore_right_, consider_right_); | 425 ignore_right_ = std::min(ignore_right_, consider_right_); |
| 405 ignore_bottom_ = std::min(ignore_bottom_, consider_bottom_); | 426 ignore_bottom_ = std::min(ignore_bottom_, consider_bottom_); |
| 406 } | 427 } |
| 407 | 428 |
| 408 if (ignore_left_ == consider_left_ && ignore_right_ == consider_right_ && | 429 if (ignore_left_ == consider_left_ && ignore_right_ == consider_right_ && |
| 409 ignore_top_ == consider_top_ && ignore_bottom_ == consider_bottom_) { | 430 ignore_top_ == consider_top_ && ignore_bottom_ == consider_bottom_) { |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 current_step_ = 0; | 693 current_step_ = 0; |
| 673 direction_ = static_cast<Direction>((direction_ + 1) % 4); | 694 direction_ = static_cast<Direction>((direction_ + 1) % 4); |
| 674 | 695 |
| 675 if (direction_ == RIGHT || direction_ == LEFT) { | 696 if (direction_ == RIGHT || direction_ == LEFT) { |
| 676 ++vertical_step_count_; | 697 ++vertical_step_count_; |
| 677 ++horizontal_step_count_; | 698 ++horizontal_step_count_; |
| 678 } | 699 } |
| 679 } | 700 } |
| 680 | 701 |
| 681 } // namespace cc | 702 } // namespace cc |
| OLD | NEW |