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