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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 | 368 |
369 gfx::Size tile_size = tiling_data_.max_texture_size(); | 369 gfx::Size tile_size = tiling_data_.max_texture_size(); |
370 int64 prioritized_rect_area = | 370 int64 prioritized_rect_area = |
371 max_tiles_for_interest_area * | 371 max_tiles_for_interest_area * |
372 tile_size.width() * tile_size.height(); | 372 tile_size.width() * tile_size.height(); |
373 | 373 |
374 gfx::Rect prioritized_rect = ExpandRectEquallyToAreaBoundedBy( | 374 gfx::Rect prioritized_rect = ExpandRectEquallyToAreaBoundedBy( |
375 viewport_in_content_space, | 375 viewport_in_content_space, |
376 prioritized_rect_area, | 376 prioritized_rect_area, |
377 ContentRect()); | 377 ContentRect()); |
378 | |
379 if (prioritized_rect.IsEmpty()) { | |
380 // For a layer out of the viewport, prioritize its tiles near to the | |
381 // viewport border so that they could be available when scrolled in. | |
382 prioritized_rect = ExpandRectBySizeBoundedBy( | |
danakj
2013/04/03 23:08:34
NAK: Using the viewport rect (or something at most
| |
383 viewport_in_content_space, | |
384 tile_size.width() * 2, | |
385 tile_size.height() * 2, | |
386 ContentRect()); | |
387 } | |
388 | |
378 DCHECK(ContentRect().Contains(prioritized_rect)); | 389 DCHECK(ContentRect().Contains(prioritized_rect)); |
379 | 390 |
380 // Iterate through all of the tiles that were live last frame but will | 391 // Iterate through all of the tiles that were live last frame but will |
381 // not be live this frame, and mark them as being dead. | 392 // not be live this frame, and mark them as being dead. |
382 for (TilingData::DifferenceIterator iter(&tiling_data_, | 393 for (TilingData::DifferenceIterator iter(&tiling_data_, |
383 last_prioritized_rect_, | 394 last_prioritized_rect_, |
384 prioritized_rect); | 395 prioritized_rect); |
385 iter; | 396 iter; |
386 ++iter) { | 397 ++iter) { |
387 TileMap::iterator find = tiles_.find(iter.index()); | 398 TileMap::iterator find = tiles_.find(iter.index()); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
524 | 535 |
525 gfx::Rect PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( | 536 gfx::Rect PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
526 gfx::Rect starting_rect, | 537 gfx::Rect starting_rect, |
527 int64 target_area, | 538 int64 target_area, |
528 gfx::Rect bounding_rect) { | 539 gfx::Rect bounding_rect) { |
529 DCHECK(!starting_rect.IsEmpty()); | 540 DCHECK(!starting_rect.IsEmpty()); |
530 DCHECK(!bounding_rect.IsEmpty()); | 541 DCHECK(!bounding_rect.IsEmpty()); |
531 DCHECK_GT(target_area, 0); | 542 DCHECK_GT(target_area, 0); |
532 | 543 |
533 gfx::Rect rect = IntersectRects(starting_rect, bounding_rect); | 544 gfx::Rect rect = IntersectRects(starting_rect, bounding_rect); |
545 | |
534 if (rect.IsEmpty()) | 546 if (rect.IsEmpty()) |
enne (OOO)
2013/04/03 23:41:49
I think this patch should really just remove this
| |
535 return rect; | 547 return rect; |
536 | 548 |
537 // These values will be updated by the loop and uses as the output. | 549 // These values will be updated by the loop and uses as the output. |
538 int origin_x = rect.x(); | 550 int origin_x = rect.x(); |
539 int origin_y = rect.y(); | 551 int origin_y = rect.y(); |
540 int width = rect.width(); | 552 int width = rect.width(); |
541 int height = rect.height(); | 553 int height = rect.height(); |
542 | 554 |
543 // In the beginning we will consider 2 edges in each dimension. | 555 // In the beginning we will consider 2 edges in each dimension. |
544 int num_y_edges = 2; | 556 int num_y_edges = 2; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
607 } | 619 } |
608 | 620 |
609 // If our delta is less then our event distance, we're done. | 621 // If our delta is less then our event distance, we're done. |
610 if (delta < event.distance) | 622 if (delta < event.distance) |
611 break; | 623 break; |
612 } | 624 } |
613 | 625 |
614 return gfx::Rect(origin_x, origin_y, width, height); | 626 return gfx::Rect(origin_x, origin_y, width, height); |
615 } | 627 } |
616 | 628 |
629 gfx::Rect PictureLayerTiling::ExpandRectBySizeBoundedBy( | |
630 gfx::Rect starting_rect, | |
631 int horizontal_expansion, | |
632 int vertical_expansion, | |
633 gfx::Rect bounding_rect) { | |
634 starting_rect.Inset(-horizontal_expansion, -vertical_expansion); | |
635 return IntersectRects(starting_rect, bounding_rect); | |
636 } | |
637 | |
617 } // namespace cc | 638 } // namespace cc |
OLD | NEW |