| 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 // Aggressively remove any tilings that are not seen to save memory. Note | 415 // Aggressively remove any tilings that are not seen to save memory. Note |
| 416 // that this is at the expense of doing cause more frequent re-painting. A | 416 // that this is at the expense of doing cause more frequent re-painting. A |
| 417 // better scheme would be to maintain a tighter visible_content_rect for the | 417 // better scheme would be to maintain a tighter visible_content_rect for the |
| 418 // finer tilings. | 418 // finer tilings. |
| 419 CleanUpTilingsOnActiveLayer(seen_tilings); | 419 CleanUpTilingsOnActiveLayer(seen_tilings); |
| 420 } | 420 } |
| 421 | 421 |
| 422 void PictureLayerImpl::UpdateTiles( | 422 void PictureLayerImpl::UpdateTiles( |
| 423 const Occlusion& occlusion_in_content_space) { | 423 const Occlusion& occlusion_in_content_space) { |
| 424 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTiles"); | 424 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTiles"); |
| 425 DCHECK_EQ(1.f, contents_scale_x()); |
| 426 DCHECK_EQ(1.f, contents_scale_y()); |
| 425 | 427 |
| 426 DoPostCommitInitializationIfNeeded(); | 428 DoPostCommitInitializationIfNeeded(); |
| 427 | 429 |
| 428 visible_rect_for_tile_priority_ = visible_content_rect(); | 430 visible_rect_for_tile_priority_ = visible_content_rect(); |
| 429 viewport_rect_for_tile_priority_ = | 431 viewport_rect_for_tile_priority_ = |
| 430 layer_tree_impl()->ViewportRectForTilePriority(); | 432 layer_tree_impl()->ViewportRectForTilePriority(); |
| 431 screen_space_transform_for_tile_priority_ = screen_space_transform(); | 433 screen_space_transform_for_tile_priority_ = screen_space_transform(); |
| 432 | 434 |
| 433 if (!CanHaveTilings()) { | 435 if (!CanHaveTilings()) { |
| 434 ideal_page_scale_ = 0.f; | 436 ideal_page_scale_ = 0.f; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 479 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| 478 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( | 480 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( |
| 479 current_frame_time_in_seconds)) { | 481 current_frame_time_in_seconds)) { |
| 480 tiling_needs_update = true; | 482 tiling_needs_update = true; |
| 481 break; | 483 break; |
| 482 } | 484 } |
| 483 } | 485 } |
| 484 if (!tiling_needs_update) | 486 if (!tiling_needs_update) |
| 485 return; | 487 return; |
| 486 | 488 |
| 487 gfx::Rect visible_rect_in_content_space( | 489 gfx::Rect visible_layer_rect = GetViewportForTilePriorityInContentSpace(); |
| 488 GetViewportForTilePriorityInContentSpace()); | |
| 489 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( | |
| 490 visible_rect_in_content_space, 1.f / contents_scale_x()); | |
| 491 WhichTree tree = | 490 WhichTree tree = |
| 492 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 491 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
| 493 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 492 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| 493 // Pass |occlusion_in_content_space| for |occlusion_in_layer_space| since |
| 494 // they are the same space in picture lbayer, as contents scale is always 1. |
| 494 tilings_->tiling_at(i)->UpdateTilePriorities(tree, | 495 tilings_->tiling_at(i)->UpdateTilePriorities(tree, |
| 495 visible_layer_rect, | 496 visible_layer_rect, |
| 496 ideal_contents_scale_, | 497 ideal_contents_scale_, |
| 497 current_frame_time_in_seconds, | 498 current_frame_time_in_seconds, |
| 498 occlusion_in_content_space); | 499 occlusion_in_content_space); |
| 499 } | 500 } |
| 500 | 501 |
| 501 // Tile priorities were modified. | 502 // Tile priorities were modified. |
| 502 layer_tree_impl()->DidModifyTilePriorities(); | 503 layer_tree_impl()->DidModifyTilePriorities(); |
| 503 } | 504 } |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 // TODO(danakj): Add a DCHECK() that we are not using occlusion tracking | 748 // TODO(danakj): Add a DCHECK() that we are not using occlusion tracking |
| 748 // when we stop using the pending tree in the browser compositor. If we want | 749 // when we stop using the pending tree in the browser compositor. If we want |
| 749 // to support occlusion tracking here, we need to dirty the draw properties | 750 // to support occlusion tracking here, we need to dirty the draw properties |
| 750 // or save occlusion as a draw property. | 751 // or save occlusion as a draw property. |
| 751 UpdateTilePriorities(Occlusion()); | 752 UpdateTilePriorities(Occlusion()); |
| 752 } | 753 } |
| 753 } | 754 } |
| 754 | 755 |
| 755 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { | 756 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { |
| 756 gfx::Rect content_rect(content_bounds()); | 757 gfx::Rect content_rect(content_bounds()); |
| 757 float scale = MaximumTilingContentsScale(); | |
| 758 PictureLayerTilingSet::CoverageIterator iter( | 758 PictureLayerTilingSet::CoverageIterator iter( |
| 759 tilings_.get(), scale, content_rect, ideal_contents_scale_); | 759 tilings_.get(), 1.f, content_rect, ideal_contents_scale_); |
| 760 | 760 |
| 761 // Mask resource not ready yet. | 761 // Mask resource not ready yet. |
| 762 if (!iter || !*iter) | 762 if (!iter || !*iter) |
| 763 return 0; | 763 return 0; |
| 764 | 764 |
| 765 // Masks only supported if they fit on exactly one tile. | 765 // Masks only supported if they fit on exactly one tile. |
| 766 DCHECK(iter.geometry_rect() == content_rect) | 766 DCHECK(iter.geometry_rect() == content_rect) |
| 767 << "iter rect " << iter.geometry_rect().ToString() << " content rect " | 767 << "iter rect " << iter.geometry_rect().ToString() << " content rect " |
| 768 << content_rect.ToString(); | 768 << content_rect.ToString(); |
| 769 | 769 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 DCHECK(!low_res) << "There can only be one low res tiling"; | 824 DCHECK(!low_res) << "There can only be one low res tiling"; |
| 825 low_res = tiling; | 825 low_res = tiling; |
| 826 } | 826 } |
| 827 if (tiling->contents_scale() < min_acceptable_scale) | 827 if (tiling->contents_scale() < min_acceptable_scale) |
| 828 continue; | 828 continue; |
| 829 if (tiling->resolution() == HIGH_RESOLUTION) { | 829 if (tiling->resolution() == HIGH_RESOLUTION) { |
| 830 DCHECK(!high_res) << "There can only be one high res tiling"; | 830 DCHECK(!high_res) << "There can only be one high res tiling"; |
| 831 high_res = tiling; | 831 high_res = tiling; |
| 832 continue; | 832 continue; |
| 833 } | 833 } |
| 834 for (PictureLayerTiling::CoverageIterator iter(tiling, | 834 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, rect); iter; |
| 835 contents_scale_x(), | |
| 836 rect); | |
| 837 iter; | |
| 838 ++iter) { | 835 ++iter) { |
| 839 if (!*iter || !iter->IsReadyToDraw()) | 836 if (!*iter || !iter->IsReadyToDraw()) |
| 840 continue; | 837 continue; |
| 841 | 838 |
| 842 missing_region.Subtract(iter.geometry_rect()); | 839 missing_region.Subtract(iter.geometry_rect()); |
| 843 iter->MarkRequiredForActivation(); | 840 iter->MarkRequiredForActivation(); |
| 844 } | 841 } |
| 845 } | 842 } |
| 846 DCHECK(high_res) << "There must be one high res tiling"; | 843 DCHECK(high_res) << "There must be one high res tiling"; |
| 847 | 844 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 872 draw_properties().screen_space_transform != | 869 draw_properties().screen_space_transform != |
| 873 twin_layer_->draw_properties().screen_space_transform) { | 870 twin_layer_->draw_properties().screen_space_transform) { |
| 874 twin_high_res = NULL; | 871 twin_high_res = NULL; |
| 875 twin_low_res = NULL; | 872 twin_low_res = NULL; |
| 876 } | 873 } |
| 877 } | 874 } |
| 878 | 875 |
| 879 // As a second pass, mark as required any visible high res tiles not filled in | 876 // As a second pass, mark as required any visible high res tiles not filled in |
| 880 // by acceptable non-ideal tiles from the first pass. | 877 // by acceptable non-ideal tiles from the first pass. |
| 881 if (MarkVisibleTilesAsRequired( | 878 if (MarkVisibleTilesAsRequired( |
| 882 high_res, twin_high_res, contents_scale_x(), rect, missing_region)) { | 879 high_res, twin_high_res, rect, missing_region)) { |
| 883 // As an optional third pass, if a high res tile was skipped because its | 880 // As an optional third pass, if a high res tile was skipped because its |
| 884 // twin was also missing, then fall back to mark low res tiles as required | 881 // twin was also missing, then fall back to mark low res tiles as required |
| 885 // in case the active twin is substituting those for missing high res | 882 // in case the active twin is substituting those for missing high res |
| 886 // content. Only suitable, when low res is enabled. | 883 // content. Only suitable, when low res is enabled. |
| 887 if (low_res) { | 884 if (low_res) { |
| 888 MarkVisibleTilesAsRequired( | 885 MarkVisibleTilesAsRequired(low_res, twin_low_res, rect, missing_region); |
| 889 low_res, twin_low_res, contents_scale_x(), rect, missing_region); | |
| 890 } | 886 } |
| 891 } | 887 } |
| 892 } | 888 } |
| 893 | 889 |
| 894 bool PictureLayerImpl::MarkVisibleTilesAsRequired( | 890 bool PictureLayerImpl::MarkVisibleTilesAsRequired( |
| 895 PictureLayerTiling* tiling, | 891 PictureLayerTiling* tiling, |
| 896 const PictureLayerTiling* optional_twin_tiling, | 892 const PictureLayerTiling* optional_twin_tiling, |
| 897 float contents_scale, | |
| 898 const gfx::Rect& rect, | 893 const gfx::Rect& rect, |
| 899 const Region& missing_region) const { | 894 const Region& missing_region) const { |
| 900 bool twin_had_missing_tile = false; | 895 bool twin_had_missing_tile = false; |
| 901 for (PictureLayerTiling::CoverageIterator iter(tiling, | 896 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, rect); iter; |
| 902 contents_scale, | |
| 903 rect); | |
| 904 iter; | |
| 905 ++iter) { | 897 ++iter) { |
| 906 Tile* tile = *iter; | 898 Tile* tile = *iter; |
| 907 // A null tile (i.e. missing recording) can just be skipped. | 899 // A null tile (i.e. missing recording) can just be skipped. |
| 908 if (!tile) | 900 if (!tile) |
| 909 continue; | 901 continue; |
| 910 | 902 |
| 911 // If the tile is occluded, don't mark it as required for activation. | 903 // If the tile is occluded, don't mark it as required for activation. |
| 912 if (tile->is_occluded(PENDING_TREE)) | 904 if (tile->is_occluded(PENDING_TREE)) |
| 913 continue; | 905 continue; |
| 914 | 906 |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1412 state->BeginArray("pictures"); | 1404 state->BeginArray("pictures"); |
| 1413 pile_->AsValueInto(state); | 1405 pile_->AsValueInto(state); |
| 1414 state->EndArray(); | 1406 state->EndArray(); |
| 1415 | 1407 |
| 1416 state->BeginArray("invalidation"); | 1408 state->BeginArray("invalidation"); |
| 1417 invalidation_.AsValueInto(state); | 1409 invalidation_.AsValueInto(state); |
| 1418 state->EndArray(); | 1410 state->EndArray(); |
| 1419 | 1411 |
| 1420 state->BeginArray("coverage_tiles"); | 1412 state->BeginArray("coverage_tiles"); |
| 1421 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), | 1413 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), |
| 1422 contents_scale_x(), | 1414 1.f, |
| 1423 gfx::Rect(content_bounds()), | 1415 gfx::Rect(content_bounds()), |
| 1424 ideal_contents_scale_); | 1416 ideal_contents_scale_); |
| 1425 iter; | 1417 iter; |
| 1426 ++iter) { | 1418 ++iter) { |
| 1427 state->BeginDictionary(); | 1419 state->BeginDictionary(); |
| 1428 | 1420 |
| 1429 state->BeginArray("geometry_rect"); | 1421 state->BeginArray("geometry_rect"); |
| 1430 MathUtil::AddToTracedValue(iter.geometry_rect(), state); | 1422 MathUtil::AddToTracedValue(iter.geometry_rect(), state); |
| 1431 state->EndArray(); | 1423 state->EndArray(); |
| 1432 | 1424 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1472 if (visible_content_rect().IsEmpty()) | 1464 if (visible_content_rect().IsEmpty()) |
| 1473 return true; | 1465 return true; |
| 1474 | 1466 |
| 1475 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 1467 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| 1476 PictureLayerTiling* tiling = tilings_->tiling_at(i); | 1468 PictureLayerTiling* tiling = tilings_->tiling_at(i); |
| 1477 if (tiling->resolution() != HIGH_RESOLUTION && | 1469 if (tiling->resolution() != HIGH_RESOLUTION && |
| 1478 tiling->resolution() != LOW_RESOLUTION) | 1470 tiling->resolution() != LOW_RESOLUTION) |
| 1479 continue; | 1471 continue; |
| 1480 | 1472 |
| 1481 gfx::Rect rect(visible_content_rect()); | 1473 gfx::Rect rect(visible_content_rect()); |
| 1482 for (PictureLayerTiling::CoverageIterator iter( | 1474 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, rect); iter; |
| 1483 tiling, contents_scale_x(), rect); | |
| 1484 iter; | |
| 1485 ++iter) { | 1475 ++iter) { |
| 1486 const Tile* tile = *iter; | 1476 const Tile* tile = *iter; |
| 1487 // A null tile (i.e. missing recording) can just be skipped. | 1477 // A null tile (i.e. missing recording) can just be skipped. |
| 1488 if (!tile) | 1478 if (!tile) |
| 1489 continue; | 1479 continue; |
| 1490 | 1480 |
| 1491 if (tile->required_for_activation() && !tile->IsReadyToDraw()) | 1481 if (tile->required_for_activation() && !tile->IsReadyToDraw()) |
| 1492 return false; | 1482 return false; |
| 1493 } | 1483 } |
| 1494 } | 1484 } |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1764 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1754 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
| 1765 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1755 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
| 1766 return tiling_range.end - 1 - current_tiling_range_offset; | 1756 return tiling_range.end - 1 - current_tiling_range_offset; |
| 1767 } | 1757 } |
| 1768 } | 1758 } |
| 1769 NOTREACHED(); | 1759 NOTREACHED(); |
| 1770 return 0; | 1760 return 0; |
| 1771 } | 1761 } |
| 1772 | 1762 |
| 1773 } // namespace cc | 1763 } // namespace cc |
| OLD | NEW |