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 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
498 | 498 |
499 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds; | 499 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds; |
500 last_visible_rect_in_content_space_ = visible_rect_in_content_space; | 500 last_visible_rect_in_content_space_ = visible_rect_in_content_space; |
501 | 501 |
502 eviction_tiles_cache_valid_ = false; | 502 eviction_tiles_cache_valid_ = false; |
503 | 503 |
504 TilePriority now_priority(resolution_, TilePriority::NOW, 0); | 504 TilePriority now_priority(resolution_, TilePriority::NOW, 0); |
505 float content_to_screen_scale = ideal_contents_scale / contents_scale_; | 505 float content_to_screen_scale = ideal_contents_scale / contents_scale_; |
506 | 506 |
507 // Assign now priority to all visible tiles. | 507 // Assign now priority to all visible tiles. |
508 bool include_borders = true; | 508 bool include_borders = true; |
enne (OOO)
2014/08/26 18:56:45
I guess really it's a question of why we include b
danakj
2014/08/26 19:29:34
Ok I am happy to make this false everywhere then.
| |
509 has_visible_rect_tiles_ = false; | 509 has_visible_rect_tiles_ = false; |
510 for (TilingData::Iterator iter( | 510 for (TilingData::Iterator iter( |
511 &tiling_data_, visible_rect_in_content_space, include_borders); | 511 &tiling_data_, visible_rect_in_content_space, include_borders); |
512 iter; | 512 iter; |
513 ++iter) { | 513 ++iter) { |
514 TileMap::iterator find = tiles_.find(iter.index()); | 514 TileMap::iterator find = tiles_.find(iter.index()); |
515 if (find == tiles_.end()) | 515 if (find == tiles_.end()) |
516 continue; | 516 continue; |
517 has_visible_rect_tiles_ = true; | 517 has_visible_rect_tiles_ = true; |
518 Tile* tile = find->second.get(); | 518 Tile* tile = find->second.get(); |
519 | 519 |
520 tile->SetPriority(tree, now_priority); | 520 tile->SetPriority(tree, now_priority); |
521 | 521 |
522 // Set whether tile is occluded or not. | 522 // Set whether tile is occluded or not. |
523 bool is_occluded = false; | 523 bool is_occluded = false; |
524 if (occlusion_tracker) { | 524 if (occlusion_tracker) { |
525 gfx::Rect tile_query_rect = ScaleToEnclosingRect( | 525 gfx::Rect tile_query_rect = ScaleToEnclosingRect( |
526 IntersectRects(tile->content_rect(), visible_rect_in_content_space), | 526 IntersectRects(tile->content_rect(), visible_rect_in_content_space), |
527 1.0f / contents_scale_); | 527 1.0f / contents_scale_); |
528 // TODO(vmpstr): Remove render_target and draw_transform from the | 528 // TODO(vmpstr): Remove render_target and draw_transform from the |
529 // parameters so they can be hidden from the tiling. | 529 // parameters so they can be hidden from the tiling. |
530 is_occluded = occlusion_tracker->Occluded( | 530 is_occluded = occlusion_tracker->Occluded( |
531 render_target, tile_query_rect, draw_transform); | 531 render_target, tile_query_rect, draw_transform); |
532 } | 532 } |
533 tile->set_is_occluded(tree, is_occluded); | 533 tile->set_is_occluded(tree, is_occluded); |
534 } | 534 } |
535 | 535 |
536 // Assign soon priority to skewport tiles. | 536 // Assign soon priority to skewport tiles. Include borders to also prioritize |
537 // tiles whose borders are in the skewport, and to exclude tiles whose borders | |
538 // are in the visible rect, since those are handled above. | |
537 has_skewport_rect_tiles_ = false; | 539 has_skewport_rect_tiles_ = false; |
538 for (TilingData::DifferenceIterator iter( | 540 for (TilingData::DifferenceIterator iter(&tiling_data_, |
539 &tiling_data_, skewport, visible_rect_in_content_space); | 541 skewport, |
542 visible_rect_in_content_space, | |
543 include_borders); | |
540 iter; | 544 iter; |
541 ++iter) { | 545 ++iter) { |
542 TileMap::iterator find = tiles_.find(iter.index()); | 546 TileMap::iterator find = tiles_.find(iter.index()); |
543 if (find == tiles_.end()) | 547 if (find == tiles_.end()) |
544 continue; | 548 continue; |
545 has_skewport_rect_tiles_ = true; | 549 has_skewport_rect_tiles_ = true; |
546 Tile* tile = find->second.get(); | 550 Tile* tile = find->second.get(); |
547 | 551 |
548 gfx::Rect tile_bounds = | 552 gfx::Rect tile_bounds = |
549 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); | 553 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); |
550 | 554 |
551 float distance_to_visible = | 555 float distance_to_visible = |
552 visible_rect_in_content_space.ManhattanInternalDistance(tile_bounds) * | 556 visible_rect_in_content_space.ManhattanInternalDistance(tile_bounds) * |
553 content_to_screen_scale; | 557 content_to_screen_scale; |
554 | 558 |
555 TilePriority priority(resolution_, TilePriority::SOON, distance_to_visible); | 559 TilePriority priority(resolution_, TilePriority::SOON, distance_to_visible); |
556 tile->SetPriority(tree, priority); | 560 tile->SetPriority(tree, priority); |
557 } | 561 } |
558 | 562 |
559 // Assign eventually priority to interest rect tiles. | 563 // Assign eventually priority to interest rect tiles. Include borders to |
564 // also prioritize tiles whose borders are in the eventually rect and exclude | |
565 // tiles whose borders are in the skewport, as those are handled above. | |
560 has_eventually_rect_tiles_ = false; | 566 has_eventually_rect_tiles_ = false; |
561 for (TilingData::DifferenceIterator iter( | 567 for (TilingData::DifferenceIterator iter( |
562 &tiling_data_, eventually_rect, skewport); | 568 &tiling_data_, eventually_rect, skewport, include_borders); |
563 iter; | 569 iter; |
564 ++iter) { | 570 ++iter) { |
565 TileMap::iterator find = tiles_.find(iter.index()); | 571 TileMap::iterator find = tiles_.find(iter.index()); |
566 if (find == tiles_.end()) | 572 if (find == tiles_.end()) |
567 continue; | 573 continue; |
568 has_eventually_rect_tiles_ = true; | 574 has_eventually_rect_tiles_ = true; |
569 Tile* tile = find->second.get(); | 575 Tile* tile = find->second.get(); |
570 | 576 |
571 gfx::Rect tile_bounds = | 577 gfx::Rect tile_bounds = |
572 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); | 578 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); |
573 | 579 |
574 float distance_to_visible = | 580 float distance_to_visible = |
575 visible_rect_in_content_space.ManhattanInternalDistance(tile_bounds) * | 581 visible_rect_in_content_space.ManhattanInternalDistance(tile_bounds) * |
576 content_to_screen_scale; | 582 content_to_screen_scale; |
577 TilePriority priority( | 583 TilePriority priority( |
578 resolution_, TilePriority::EVENTUALLY, distance_to_visible); | 584 resolution_, TilePriority::EVENTUALLY, distance_to_visible); |
579 tile->SetPriority(tree, priority); | 585 tile->SetPriority(tree, priority); |
580 } | 586 } |
581 | 587 |
582 // Upgrade the priority on border tiles to be SOON. | 588 // Upgrade the priority on border tiles to be SOON. Include borders to include |
589 // tiles whose borders are in the soon_border_rect and exclude those with | |
590 // borders in the skewport, as those are handled above. | |
583 gfx::Rect soon_border_rect = visible_rect_in_content_space; | 591 gfx::Rect soon_border_rect = visible_rect_in_content_space; |
584 float border = kSoonBorderDistanceInScreenPixels / content_to_screen_scale; | 592 float border = kSoonBorderDistanceInScreenPixels / content_to_screen_scale; |
585 soon_border_rect.Inset(-border, -border, -border, -border); | 593 soon_border_rect.Inset(-border, -border, -border, -border); |
586 has_soon_border_rect_tiles_ = false; | 594 has_soon_border_rect_tiles_ = false; |
587 for (TilingData::DifferenceIterator iter( | 595 for (TilingData::DifferenceIterator iter( |
588 &tiling_data_, soon_border_rect, skewport); | 596 &tiling_data_, soon_border_rect, skewport, include_borders); |
589 iter; | 597 iter; |
590 ++iter) { | 598 ++iter) { |
591 TileMap::iterator find = tiles_.find(iter.index()); | 599 TileMap::iterator find = tiles_.find(iter.index()); |
592 if (find == tiles_.end()) | 600 if (find == tiles_.end()) |
593 continue; | 601 continue; |
594 has_soon_border_rect_tiles_ = true; | 602 has_soon_border_rect_tiles_ = true; |
595 Tile* tile = find->second.get(); | 603 Tile* tile = find->second.get(); |
596 | 604 |
597 TilePriority priority(resolution_, | 605 TilePriority priority(resolution_, |
598 TilePriority::SOON, | 606 TilePriority::SOON, |
(...skipping 10 matching lines...) Expand all Loading... | |
609 | 617 |
610 void PictureLayerTiling::SetLiveTilesRect( | 618 void PictureLayerTiling::SetLiveTilesRect( |
611 const gfx::Rect& new_live_tiles_rect) { | 619 const gfx::Rect& new_live_tiles_rect) { |
612 DCHECK(new_live_tiles_rect.IsEmpty() || | 620 DCHECK(new_live_tiles_rect.IsEmpty() || |
613 gfx::Rect(tiling_size()).Contains(new_live_tiles_rect)) | 621 gfx::Rect(tiling_size()).Contains(new_live_tiles_rect)) |
614 << "tiling_size: " << tiling_size().ToString() | 622 << "tiling_size: " << tiling_size().ToString() |
615 << " new_live_tiles_rect: " << new_live_tiles_rect.ToString(); | 623 << " new_live_tiles_rect: " << new_live_tiles_rect.ToString(); |
616 if (live_tiles_rect_ == new_live_tiles_rect) | 624 if (live_tiles_rect_ == new_live_tiles_rect) |
617 return; | 625 return; |
618 | 626 |
619 // Iterate to delete all tiles outside of our new live_tiles rect. | 627 // Iterate to delete all tiles outside of our new live_tiles rect. Iterate |
628 // without borders to avoid including tiles that have only border pixels | |
629 // outside the new live tiles rect. | |
630 bool include_borders = false; | |
620 for (TilingData::DifferenceIterator iter(&tiling_data_, | 631 for (TilingData::DifferenceIterator iter(&tiling_data_, |
621 live_tiles_rect_, | 632 live_tiles_rect_, |
622 new_live_tiles_rect); | 633 new_live_tiles_rect, |
634 include_borders); | |
623 iter; | 635 iter; |
624 ++iter) { | 636 ++iter) { |
625 TileMapKey key(iter.index()); | 637 TileMapKey key(iter.index()); |
626 TileMap::iterator found = tiles_.find(key); | 638 TileMap::iterator found = tiles_.find(key); |
627 // If the tile was outside of the recorded region, it won't exist even | 639 // If the tile was outside of the recorded region, it won't exist even |
628 // though it was in the live rect. | 640 // though it was in the live rect. |
629 if (found != tiles_.end()) { | 641 if (found != tiles_.end()) { |
630 ReleaseTile(found->second.get(), client_->GetTree()); | 642 ReleaseTile(found->second.get(), client_->GetTree()); |
631 tiles_.erase(found); | 643 tiles_.erase(found); |
632 } | 644 } |
633 } | 645 } |
634 | 646 |
635 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | 647 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); |
636 | 648 |
637 // Iterate to allocate new tiles for all regions with newly exposed area. | 649 // Iterate to allocate new tiles for all regions with newly exposed area. |
650 // Do the iteration without borders to avoid adding tiles that already exist | |
651 // for tiles whose border pixels are in the new live tiles rect. | |
638 for (TilingData::DifferenceIterator iter(&tiling_data_, | 652 for (TilingData::DifferenceIterator iter(&tiling_data_, |
639 new_live_tiles_rect, | 653 new_live_tiles_rect, |
640 live_tiles_rect_); | 654 live_tiles_rect_, |
655 include_borders); | |
641 iter; | 656 iter; |
642 ++iter) { | 657 ++iter) { |
643 TileMapKey key(iter.index()); | 658 TileMapKey key(iter.index()); |
644 CreateTile(key.first, key.second, twin_tiling); | 659 CreateTile(key.first, key.second, twin_tiling); |
645 } | 660 } |
646 | 661 |
647 live_tiles_rect_ = new_live_tiles_rect; | 662 live_tiles_rect_ = new_live_tiles_rect; |
648 } | 663 } |
649 | 664 |
650 void PictureLayerTiling::DidBecomeRecycled() { | 665 void PictureLayerTiling::DidBecomeRecycled() { |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1089 DCHECK(*this); | 1104 DCHECK(*this); |
1090 do { | 1105 do { |
1091 ++current_eviction_tiles_index_; | 1106 ++current_eviction_tiles_index_; |
1092 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && | 1107 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && |
1093 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); | 1108 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); |
1094 | 1109 |
1095 return *this; | 1110 return *this; |
1096 } | 1111 } |
1097 | 1112 |
1098 } // namespace cc | 1113 } // namespace cc |
OLD | NEW |