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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 SetLiveTilesRect(eventually_rect); | 460 SetLiveTilesRect(eventually_rect); |
461 | 461 |
462 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds; | 462 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds; |
463 last_visible_rect_in_content_space_ = visible_rect_in_content_space; | 463 last_visible_rect_in_content_space_ = visible_rect_in_content_space; |
464 | 464 |
465 current_visible_rect_in_content_space_ = visible_rect_in_content_space; | 465 current_visible_rect_in_content_space_ = visible_rect_in_content_space; |
466 current_skewport_ = skewport; | 466 current_skewport_ = skewport; |
467 current_eventually_rect_ = eventually_rect; | 467 current_eventually_rect_ = eventually_rect; |
468 eviction_tiles_cache_valid_ = false; | 468 eviction_tiles_cache_valid_ = false; |
469 | 469 |
470 TilePriority now_priority(resolution_, TilePriority::NOW, 0); | 470 TilePriority now_priority(resolution_, false, TilePriority::NOW, 0); |
471 TilePriority now_and_occluded_priority( | |
472 resolution_, true, TilePriority::NOW, 0); | |
471 float content_to_screen_scale = | 473 float content_to_screen_scale = |
472 1.0f / (contents_scale_ * layer_contents_scale); | 474 1.0f / (contents_scale_ * layer_contents_scale); |
473 | 475 |
474 // Assign now priority to all visible tiles. | 476 // Assign now priority to all visible tiles. |
475 bool include_borders = true; | 477 bool include_borders = true; |
476 for (TilingData::Iterator iter( | 478 for (TilingData::Iterator iter( |
477 &tiling_data_, visible_rect_in_content_space, include_borders); | 479 &tiling_data_, visible_rect_in_content_space, include_borders); |
478 iter; | 480 iter; |
479 ++iter) { | 481 ++iter) { |
480 TileMap::iterator find = tiles_.find(iter.index()); | 482 TileMap::iterator find = tiles_.find(iter.index()); |
481 if (find == tiles_.end()) | 483 if (find == tiles_.end()) |
482 continue; | 484 continue; |
483 Tile* tile = find->second.get(); | 485 Tile* tile = find->second.get(); |
484 | 486 |
485 tile->SetPriority(tree, now_priority); | 487 // Determine whether tile is occluded or not. |
486 | |
487 // Set whether tile is occluded or not. | |
488 bool is_occluded = false; | 488 bool is_occluded = false; |
489 if (occlusion_tracker) { | 489 if (occlusion_tracker) { |
490 gfx::Rect tile_query_rect = ScaleToEnclosingRect( | 490 gfx::Rect tile_query_rect = ScaleToEnclosingRect( |
491 IntersectRects(tile->content_rect(), visible_rect_in_content_space), | 491 IntersectRects(tile->content_rect(), visible_rect_in_content_space), |
492 1.0f / contents_scale_); | 492 1.0f / contents_scale_); |
493 // TODO(vmpstr): Remove render_target and draw_transform from the | 493 // TODO(vmpstr): Remove render_target and draw_transform from the |
494 // parameters so they can be hidden from the tiling. | 494 // parameters so they can be hidden from the tiling. |
495 is_occluded = occlusion_tracker->Occluded( | 495 is_occluded = occlusion_tracker->Occluded( |
496 render_target, tile_query_rect, draw_transform); | 496 render_target, tile_query_rect, draw_transform); |
497 } | 497 } |
498 tile->set_is_occluded(is_occluded); | 498 |
499 if (is_occluded) { | |
500 tile->SetPriority(tree, now_and_occluded_priority); | |
501 } else { | |
502 tile->SetPriority(tree, now_priority); | |
503 } | |
499 } | 504 } |
500 | 505 |
501 // Assign soon priority to skewport tiles. | 506 // Assign soon priority to skewport tiles. |
502 for (TilingData::DifferenceIterator iter( | 507 for (TilingData::DifferenceIterator iter( |
503 &tiling_data_, skewport, visible_rect_in_content_space); | 508 &tiling_data_, skewport, visible_rect_in_content_space); |
504 iter; | 509 iter; |
505 ++iter) { | 510 ++iter) { |
506 TileMap::iterator find = tiles_.find(iter.index()); | 511 TileMap::iterator find = tiles_.find(iter.index()); |
507 if (find == tiles_.end()) | 512 if (find == tiles_.end()) |
508 continue; | 513 continue; |
509 Tile* tile = find->second.get(); | 514 Tile* tile = find->second.get(); |
510 | 515 |
511 gfx::Rect tile_bounds = | 516 gfx::Rect tile_bounds = |
512 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); | 517 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); |
513 | 518 |
514 float distance_to_visible = | 519 float distance_to_visible = |
515 visible_rect_in_content_space.ManhattanInternalDistance(tile_bounds) * | 520 visible_rect_in_content_space.ManhattanInternalDistance(tile_bounds) * |
516 content_to_screen_scale; | 521 content_to_screen_scale; |
517 | 522 |
518 TilePriority priority(resolution_, TilePriority::SOON, distance_to_visible); | 523 TilePriority priority( |
524 resolution_, false, TilePriority::SOON, distance_to_visible); | |
danakj
2014/06/19 19:19:59
can you use a temp var here to give the |false| li
jbedley
2014/06/19 20:51:20
Done.
| |
519 tile->SetPriority(tree, priority); | 525 tile->SetPriority(tree, priority); |
520 } | 526 } |
521 | 527 |
522 // Assign eventually priority to interest rect tiles. | 528 // Assign eventually priority to interest rect tiles. |
523 for (TilingData::DifferenceIterator iter( | 529 for (TilingData::DifferenceIterator iter( |
524 &tiling_data_, eventually_rect, skewport); | 530 &tiling_data_, eventually_rect, skewport); |
525 iter; | 531 iter; |
526 ++iter) { | 532 ++iter) { |
527 TileMap::iterator find = tiles_.find(iter.index()); | 533 TileMap::iterator find = tiles_.find(iter.index()); |
528 if (find == tiles_.end()) | 534 if (find == tiles_.end()) |
529 continue; | 535 continue; |
530 Tile* tile = find->second.get(); | 536 Tile* tile = find->second.get(); |
531 | 537 |
532 gfx::Rect tile_bounds = | 538 gfx::Rect tile_bounds = |
533 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); | 539 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); |
534 | 540 |
535 float distance_to_visible = | 541 float distance_to_visible = |
536 visible_rect_in_content_space.ManhattanInternalDistance(tile_bounds) * | 542 visible_rect_in_content_space.ManhattanInternalDistance(tile_bounds) * |
537 content_to_screen_scale; | 543 content_to_screen_scale; |
538 TilePriority priority( | 544 TilePriority priority( |
539 resolution_, TilePriority::EVENTUALLY, distance_to_visible); | 545 resolution_, false, TilePriority::EVENTUALLY, distance_to_visible); |
danakj
2014/06/19 19:19:59
can you use a temp var here to give the |false| li
jbedley
2014/06/19 20:51:20
Done.
| |
540 tile->SetPriority(tree, priority); | 546 tile->SetPriority(tree, priority); |
541 } | 547 } |
542 | 548 |
543 // Upgrade the priority on border tiles to be SOON. | 549 // Upgrade the priority on border tiles to be SOON. |
544 current_soon_border_rect_ = visible_rect_in_content_space; | 550 current_soon_border_rect_ = visible_rect_in_content_space; |
545 float border = kSoonBorderDistanceInScreenPixels / content_to_screen_scale; | 551 float border = kSoonBorderDistanceInScreenPixels / content_to_screen_scale; |
546 current_soon_border_rect_.Inset(-border, -border, -border, -border); | 552 current_soon_border_rect_.Inset(-border, -border, -border, -border); |
547 for (TilingData::DifferenceIterator iter( | 553 for (TilingData::DifferenceIterator iter( |
548 &tiling_data_, current_soon_border_rect_, skewport); | 554 &tiling_data_, current_soon_border_rect_, skewport); |
549 iter; | 555 iter; |
550 ++iter) { | 556 ++iter) { |
551 TileMap::iterator find = tiles_.find(iter.index()); | 557 TileMap::iterator find = tiles_.find(iter.index()); |
552 if (find == tiles_.end()) | 558 if (find == tiles_.end()) |
553 continue; | 559 continue; |
554 Tile* tile = find->second.get(); | 560 Tile* tile = find->second.get(); |
555 | 561 |
556 TilePriority priority(resolution_, | 562 TilePriority priority(resolution_, |
563 false, | |
danakj
2014/06/19 19:19:59
can you use a temp var here to give the |false| li
jbedley
2014/06/19 20:51:20
Done.
| |
557 TilePriority::SOON, | 564 TilePriority::SOON, |
558 tile->priority(tree).distance_to_visible); | 565 tile->priority(tree).distance_to_visible); |
559 tile->SetPriority(tree, priority); | 566 tile->SetPriority(tree, priority); |
560 } | 567 } |
561 } | 568 } |
562 | 569 |
563 void PictureLayerTiling::SetLiveTilesRect( | 570 void PictureLayerTiling::SetLiveTilesRect( |
564 const gfx::Rect& new_live_tiles_rect) { | 571 const gfx::Rect& new_live_tiles_rect) { |
565 DCHECK(new_live_tiles_rect.IsEmpty() || | 572 DCHECK(new_live_tiles_rect.IsEmpty() || |
566 TilingRect().Contains(new_live_tiles_rect)); | 573 TilingRect().Contains(new_live_tiles_rect)); |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
971 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); | 978 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); |
972 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); | 979 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); |
973 is_valid_ = true; | 980 is_valid_ = true; |
974 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && | 981 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && |
975 !(*tile_iterator_)->HasResources()) { | 982 !(*tile_iterator_)->HasResources()) { |
976 ++(*this); | 983 ++(*this); |
977 } | 984 } |
978 } | 985 } |
979 | 986 |
980 } // namespace cc | 987 } // namespace cc |
OLD | NEW |