| 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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 on_demand_missing_tile_count); | 434 on_demand_missing_tile_count); |
| 435 } | 435 } |
| 436 | 436 |
| 437 // Aggressively remove any tilings that are not seen to save memory. Note | 437 // Aggressively remove any tilings that are not seen to save memory. Note |
| 438 // that this is at the expense of doing cause more frequent re-painting. A | 438 // that this is at the expense of doing cause more frequent re-painting. A |
| 439 // better scheme would be to maintain a tighter visible_content_rect for the | 439 // better scheme would be to maintain a tighter visible_content_rect for the |
| 440 // finer tilings. | 440 // finer tilings. |
| 441 CleanUpTilingsOnActiveLayer(seen_tilings); | 441 CleanUpTilingsOnActiveLayer(seen_tilings); |
| 442 } | 442 } |
| 443 | 443 |
| 444 void PictureLayerImpl::UpdateTiles( | 444 void PictureLayerImpl::UpdateTiles(const Occlusion& occlusion_in_content_space, |
| 445 const Occlusion& occlusion_in_content_space) { | 445 bool resourceless_software_draw) { |
| 446 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTiles"); | 446 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTiles"); |
| 447 DCHECK_EQ(1.f, contents_scale_x()); | 447 DCHECK_EQ(1.f, contents_scale_x()); |
| 448 DCHECK_EQ(1.f, contents_scale_y()); | 448 DCHECK_EQ(1.f, contents_scale_y()); |
| 449 | 449 |
| 450 DoPostCommitInitializationIfNeeded(); | 450 DoPostCommitInitializationIfNeeded(); |
| 451 | 451 |
| 452 visible_rect_for_tile_priority_ = visible_content_rect(); | 452 // Any draw properties derived from |transform|, |viewport|, and |clip| |
| 453 // parameters in LayerTreeHostImpl::SetExternalDrawConstraints are not valid |
| 454 // for prioritizing tiles during resourceless software draws. This is because |
| 455 // resourceless software draws can have wildly different transforms/viewports |
| 456 // from regular draws. |
| 457 if (!resourceless_software_draw) { |
| 458 visible_rect_for_tile_priority_ = visible_content_rect(); |
| 459 } |
| 453 viewport_rect_for_tile_priority_ = | 460 viewport_rect_for_tile_priority_ = |
| 454 layer_tree_impl()->ViewportRectForTilePriority(); | 461 layer_tree_impl()->ViewportRectForTilePriority(); |
| 455 screen_space_transform_for_tile_priority_ = screen_space_transform(); | 462 screen_space_transform_for_tile_priority_ = screen_space_transform(); |
| 456 | 463 |
| 457 if (!CanHaveTilings()) { | 464 if (!CanHaveTilings()) { |
| 458 ideal_page_scale_ = 0.f; | 465 ideal_page_scale_ = 0.f; |
| 459 ideal_device_scale_ = 0.f; | 466 ideal_device_scale_ = 0.f; |
| 460 ideal_contents_scale_ = 0.f; | 467 ideal_contents_scale_ = 0.f; |
| 461 ideal_source_scale_ = 0.f; | 468 ideal_source_scale_ = 0.f; |
| 462 SanityCheckTilingState(); | 469 SanityCheckTilingState(); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 void PictureLayerImpl::MarkVisibleResourcesAsRequired() const { | 806 void PictureLayerImpl::MarkVisibleResourcesAsRequired() const { |
| 800 DCHECK(layer_tree_impl()->IsPendingTree()); | 807 DCHECK(layer_tree_impl()->IsPendingTree()); |
| 801 DCHECK(ideal_contents_scale_); | 808 DCHECK(ideal_contents_scale_); |
| 802 DCHECK_GT(tilings_->num_tilings(), 0u); | 809 DCHECK_GT(tilings_->num_tilings(), 0u); |
| 803 | 810 |
| 804 // The goal of this function is to find the minimum set of tiles that need to | 811 // The goal of this function is to find the minimum set of tiles that need to |
| 805 // be ready to draw in order to activate without flashing content from a | 812 // be ready to draw in order to activate without flashing content from a |
| 806 // higher res on the active tree to a lower res on the pending tree. | 813 // higher res on the active tree to a lower res on the pending tree. |
| 807 | 814 |
| 808 // First, early out for layers with no visible content. | 815 // First, early out for layers with no visible content. |
| 809 if (visible_content_rect().IsEmpty()) | 816 if (visible_rect_for_tile_priority_.IsEmpty()) |
| 810 return; | 817 return; |
| 811 | 818 |
| 812 // Only mark tiles inside the viewport for tile priority as required for | 819 // Only mark tiles inside the viewport for tile priority as required for |
| 813 // activation. This viewport is normally the same as the draw viewport but | 820 // activation. This viewport is normally the same as the draw viewport but |
| 814 // can be independently overridden by embedders like Android WebView with | 821 // can be independently overridden by embedders like Android WebView with |
| 815 // SetExternalDrawConstraints. | 822 // SetExternalDrawConstraints. |
| 816 gfx::Rect rect = GetViewportForTilePriorityInContentSpace(); | 823 gfx::Rect rect = GetViewportForTilePriorityInContentSpace(); |
| 817 rect.Intersect(visible_content_rect()); | 824 rect.Intersect(visible_rect_for_tile_priority_); |
| 818 | 825 |
| 819 float min_acceptable_scale = | 826 float min_acceptable_scale = |
| 820 std::min(raster_contents_scale_, ideal_contents_scale_); | 827 std::min(raster_contents_scale_, ideal_contents_scale_); |
| 821 | 828 |
| 822 if (PictureLayerImpl* twin = twin_layer_) { | 829 if (PictureLayerImpl* twin = twin_layer_) { |
| 823 float twin_min_acceptable_scale = | 830 float twin_min_acceptable_scale = |
| 824 std::min(twin->ideal_contents_scale_, twin->raster_contents_scale_); | 831 std::min(twin->ideal_contents_scale_, twin->raster_contents_scale_); |
| 825 // Ignore 0 scale in case CalculateContentsScale() has never been | 832 // Ignore 0 scale in case CalculateContentsScale() has never been |
| 826 // called for active twin. | 833 // called for active twin. |
| 827 if (twin_min_acceptable_scale != 0.0f) { | 834 if (twin_min_acceptable_scale != 0.0f) { |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 bool PictureLayerImpl::AllTilesRequiredForActivationAreReadyToDraw() const { | 1492 bool PictureLayerImpl::AllTilesRequiredForActivationAreReadyToDraw() const { |
| 1486 if (!layer_tree_impl()->IsPendingTree()) | 1493 if (!layer_tree_impl()->IsPendingTree()) |
| 1487 return true; | 1494 return true; |
| 1488 | 1495 |
| 1489 if (!HasValidTilePriorities()) | 1496 if (!HasValidTilePriorities()) |
| 1490 return true; | 1497 return true; |
| 1491 | 1498 |
| 1492 if (!tilings_) | 1499 if (!tilings_) |
| 1493 return true; | 1500 return true; |
| 1494 | 1501 |
| 1495 if (visible_content_rect().IsEmpty()) | 1502 if (visible_rect_for_tile_priority_.IsEmpty()) |
| 1496 return true; | 1503 return true; |
| 1497 | 1504 |
| 1505 gfx::Rect rect = GetViewportForTilePriorityInContentSpace(); |
| 1506 rect.Intersect(visible_rect_for_tile_priority_); |
| 1507 |
| 1498 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 1508 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| 1499 PictureLayerTiling* tiling = tilings_->tiling_at(i); | 1509 PictureLayerTiling* tiling = tilings_->tiling_at(i); |
| 1500 if (tiling->resolution() != HIGH_RESOLUTION && | 1510 if (tiling->resolution() != HIGH_RESOLUTION && |
| 1501 tiling->resolution() != LOW_RESOLUTION) | 1511 tiling->resolution() != LOW_RESOLUTION) |
| 1502 continue; | 1512 continue; |
| 1503 | 1513 |
| 1504 gfx::Rect rect(visible_content_rect()); | |
| 1505 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, rect); iter; | 1514 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, rect); iter; |
| 1506 ++iter) { | 1515 ++iter) { |
| 1507 const Tile* tile = *iter; | 1516 const Tile* tile = *iter; |
| 1508 // A null tile (i.e. missing recording) can just be skipped. | 1517 // A null tile (i.e. missing recording) can just be skipped. |
| 1509 if (!tile) | 1518 if (!tile) |
| 1510 continue; | 1519 continue; |
| 1511 | 1520 |
| 1512 if (tile->required_for_activation() && !tile->IsReadyToDraw()) | 1521 if (tile->required_for_activation() && !tile->IsReadyToDraw()) |
| 1513 return false; | 1522 return false; |
| 1514 } | 1523 } |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1785 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1794 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
| 1786 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1795 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
| 1787 return tiling_range.end - 1 - current_tiling_range_offset; | 1796 return tiling_range.end - 1 - current_tiling_range_offset; |
| 1788 } | 1797 } |
| 1789 } | 1798 } |
| 1790 NOTREACHED(); | 1799 NOTREACHED(); |
| 1791 return 0; | 1800 return 0; |
| 1792 } | 1801 } |
| 1793 | 1802 |
| 1794 } // namespace cc | 1803 } // namespace cc |
| OLD | NEW |