OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 if (starting_rect.IsEmpty()) | 523 if (starting_rect.IsEmpty()) |
524 return starting_rect; | 524 return starting_rect; |
525 | 525 |
526 DCHECK(!bounding_rect.IsEmpty()); | 526 DCHECK(!bounding_rect.IsEmpty()); |
527 DCHECK_GT(target_area, 0); | 527 DCHECK_GT(target_area, 0); |
528 | 528 |
529 // Expand the starting rect to cover target_area. | 529 // Expand the starting rect to cover target_area. |
530 int delta = ComputeExpansionDelta( | 530 int delta = ComputeExpansionDelta( |
531 2, 2, starting_rect.width(), starting_rect.height(), target_area); | 531 2, 2, starting_rect.width(), starting_rect.height(), target_area); |
532 gfx::Rect expanded_starting_rect = starting_rect; | 532 gfx::Rect expanded_starting_rect = starting_rect; |
533 expanded_starting_rect.Inset(-delta, -delta); | 533 |
| 534 // Expand but not shink the starting_rect to include small layers that are |
| 535 // in viewport but target_area is smaller than the viewport. |
| 536 if (delta > 0) |
| 537 expanded_starting_rect.Inset(-delta, -delta); |
534 | 538 |
535 gfx::Rect rect = IntersectRects(expanded_starting_rect, bounding_rect); | 539 gfx::Rect rect = IntersectRects(expanded_starting_rect, bounding_rect); |
536 if (rect.IsEmpty()) { | 540 if (rect.IsEmpty()) { |
537 // The starting_rect and bounding_rect are far away. | 541 // The starting_rect and bounding_rect are far away. |
538 return rect; | 542 return rect; |
539 } | 543 } |
540 if (rect == expanded_starting_rect) { | 544 if (delta >= 0 && rect == expanded_starting_rect) { |
541 // The expanded starting rect already covers target_area on bounding_rect. | 545 // The expanded starting rect already covers target_area on bounding_rect. |
542 return rect; | 546 return rect; |
543 } | 547 } |
544 | 548 |
545 // Continue to expand rect to let it cover target_area. | 549 // Continue to expand rect to let it cover target_area. |
546 | 550 |
547 // These values will be updated by the loop and uses as the output. | 551 // These values will be updated by the loop and uses as the output. |
548 int origin_x = rect.x(); | 552 int origin_x = rect.x(); |
549 int origin_y = rect.y(); | 553 int origin_y = rect.y(); |
550 int width = rect.width(); | 554 int width = rect.width(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 | 616 |
613 // If our delta is less then our event distance, we're done. | 617 // If our delta is less then our event distance, we're done. |
614 if (delta < event.distance) | 618 if (delta < event.distance) |
615 break; | 619 break; |
616 } | 620 } |
617 | 621 |
618 return gfx::Rect(origin_x, origin_y, width, height); | 622 return gfx::Rect(origin_x, origin_y, width, height); |
619 } | 623 } |
620 | 624 |
621 } // namespace cc | 625 } // namespace cc |
OLD | NEW |