Chromium Code Reviews| 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/tiles/picture_layer_tiling.h" | 5 #include "cc/tiles/picture_layer_tiling.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 #include "ui/gfx/geometry/rect_f.h" | 27 #include "ui/gfx/geometry/rect_f.h" |
| 28 #include "ui/gfx/geometry/safe_integer_conversions.h" | 28 #include "ui/gfx/geometry/safe_integer_conversions.h" |
| 29 #include "ui/gfx/geometry/size_conversions.h" | 29 #include "ui/gfx/geometry/size_conversions.h" |
| 30 | 30 |
| 31 namespace cc { | 31 namespace cc { |
| 32 | 32 |
| 33 PictureLayerTiling::PictureLayerTiling( | 33 PictureLayerTiling::PictureLayerTiling( |
| 34 WhichTree tree, | 34 WhichTree tree, |
| 35 float contents_scale, | 35 float contents_scale, |
| 36 scoped_refptr<RasterSource> raster_source, | 36 scoped_refptr<RasterSource> raster_source, |
| 37 PictureLayerTilingClient* client) | 37 PictureLayerTilingClient* client, |
| 38 float min_preraster_distance, | |
| 39 float max_preraster_distance) | |
| 38 : contents_scale_(contents_scale), | 40 : contents_scale_(contents_scale), |
| 39 client_(client), | 41 client_(client), |
| 40 tree_(tree), | 42 tree_(tree), |
| 41 raster_source_(raster_source), | 43 raster_source_(raster_source), |
| 44 min_preraster_distance_(min_preraster_distance), | |
| 45 max_preraster_distance_(max_preraster_distance), | |
| 42 resolution_(NON_IDEAL_RESOLUTION), | 46 resolution_(NON_IDEAL_RESOLUTION), |
| 43 may_contain_low_resolution_tiles_(false), | 47 may_contain_low_resolution_tiles_(false), |
| 44 tiling_data_(gfx::Size(), gfx::Size(), kBorderTexels), | 48 tiling_data_(gfx::Size(), gfx::Size(), kBorderTexels), |
| 45 can_require_tiles_for_activation_(false), | 49 can_require_tiles_for_activation_(false), |
| 46 current_content_to_screen_scale_(0.f), | 50 current_content_to_screen_scale_(0.f), |
| 51 max_skewport_extent_(0.f), | |
| 47 has_visible_rect_tiles_(false), | 52 has_visible_rect_tiles_(false), |
| 48 has_skewport_rect_tiles_(false), | 53 has_skewport_rect_tiles_(false), |
| 49 has_soon_border_rect_tiles_(false), | 54 has_soon_border_rect_tiles_(false), |
| 50 has_eventually_rect_tiles_(false), | 55 has_eventually_rect_tiles_(false), |
| 51 all_tiles_done_(true) { | 56 all_tiles_done_(true) { |
| 52 DCHECK(!raster_source->IsSolidColor()); | 57 DCHECK(!raster_source->IsSolidColor()); |
| 53 gfx::Size content_bounds = | 58 gfx::Size content_bounds = |
| 54 gfx::ScaleToCeiledSize(raster_source_->GetSize(), contents_scale); | 59 gfx::ScaleToCeiledSize(raster_source_->GetSize(), contents_scale); |
| 55 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); | 60 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); |
| 56 | 61 |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 582 current_eventually_rect_ = eventually_rect; | 587 current_eventually_rect_ = eventually_rect; |
| 583 current_occlusion_in_layer_space_ = occlusion_in_layer_space; | 588 current_occlusion_in_layer_space_ = occlusion_in_layer_space; |
| 584 current_content_to_screen_scale_ = content_to_screen_scale; | 589 current_content_to_screen_scale_ = content_to_screen_scale; |
| 585 | 590 |
| 586 gfx::Rect tiling_rect(tiling_size()); | 591 gfx::Rect tiling_rect(tiling_size()); |
| 587 has_visible_rect_tiles_ = tiling_rect.Intersects(current_visible_rect_); | 592 has_visible_rect_tiles_ = tiling_rect.Intersects(current_visible_rect_); |
| 588 has_skewport_rect_tiles_ = tiling_rect.Intersects(current_skewport_rect_); | 593 has_skewport_rect_tiles_ = tiling_rect.Intersects(current_skewport_rect_); |
| 589 has_soon_border_rect_tiles_ = | 594 has_soon_border_rect_tiles_ = |
| 590 tiling_rect.Intersects(current_soon_border_rect_); | 595 tiling_rect.Intersects(current_soon_border_rect_); |
| 591 has_eventually_rect_tiles_ = tiling_rect.Intersects(current_eventually_rect_); | 596 has_eventually_rect_tiles_ = tiling_rect.Intersects(current_eventually_rect_); |
| 597 | |
| 598 // Note that we use the largest skewport extent from the viewport as the | |
| 599 // "skewport extent". Also note that this math can't produce negative numbers, | |
| 600 // since skewport.Contains(visible_rect) is always true. | |
| 601 max_skewport_extent_ = | |
| 602 current_content_to_screen_scale_ * | |
| 603 std::max(std::max(current_visible_rect_.x() - current_skewport_rect_.x(), | |
| 604 current_skewport_rect_.right() - | |
| 605 current_visible_rect_.right()), | |
| 606 std::max(current_visible_rect_.y() - current_skewport_rect_.y(), | |
| 607 current_skewport_rect_.bottom() - | |
| 608 current_visible_rect_.bottom())); | |
| 592 } | 609 } |
| 593 | 610 |
| 594 void PictureLayerTiling::SetLiveTilesRect( | 611 void PictureLayerTiling::SetLiveTilesRect( |
| 595 const gfx::Rect& new_live_tiles_rect) { | 612 const gfx::Rect& new_live_tiles_rect) { |
| 596 DCHECK(new_live_tiles_rect.IsEmpty() || | 613 DCHECK(new_live_tiles_rect.IsEmpty() || |
| 597 gfx::Rect(tiling_size()).Contains(new_live_tiles_rect)) | 614 gfx::Rect(tiling_size()).Contains(new_live_tiles_rect)) |
| 598 << "tiling_size: " << tiling_size().ToString() | 615 << "tiling_size: " << tiling_size().ToString() |
| 599 << " new_live_tiles_rect: " << new_live_tiles_rect.ToString(); | 616 << " new_live_tiles_rect: " << new_live_tiles_rect.ToString(); |
| 600 if (live_tiles_rect_ == new_live_tiles_rect) | 617 if (live_tiles_rect_ == new_live_tiles_rect) |
| 601 return; | 618 return; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 771 PrioritizedTile PictureLayerTiling::MakePrioritizedTile( | 788 PrioritizedTile PictureLayerTiling::MakePrioritizedTile( |
| 772 Tile* tile, | 789 Tile* tile, |
| 773 PriorityRectType priority_rect_type) const { | 790 PriorityRectType priority_rect_type) const { |
| 774 DCHECK(tile); | 791 DCHECK(tile); |
| 775 DCHECK(raster_source()->CoversRect(tile->enclosing_layer_rect())) | 792 DCHECK(raster_source()->CoversRect(tile->enclosing_layer_rect())) |
| 776 << "Recording rect: " | 793 << "Recording rect: " |
| 777 << gfx::ScaleToEnclosingRect(tile->content_rect(), | 794 << gfx::ScaleToEnclosingRect(tile->content_rect(), |
| 778 1.f / tile->contents_scale()) | 795 1.f / tile->contents_scale()) |
| 779 .ToString(); | 796 .ToString(); |
| 780 | 797 |
| 781 return PrioritizedTile(tile, this, | 798 const auto& tile_priority = ComputePriorityForTile(tile, priority_rect_type); |
| 782 ComputePriorityForTile(tile, priority_rect_type), | 799 // Note that TileManager will consider this flag but may rasterize the tile |
| 783 IsTileOccluded(tile)); | 800 // anyway (if tile is required for activation for example). We should process |
| 801 // the tile for images only if it's further than half of the skewport extent. | |
| 802 bool process_for_images_only = | |
| 803 tile_priority.distance_to_visible > min_preraster_distance_ && | |
| 804 (tile_priority.distance_to_visible > max_preraster_distance_ || | |
| 805 tile_priority.distance_to_visible > 0.5f * max_skewport_extent_); | |
|
enne (OOO)
2016/09/07 22:03:20
distance_to_visible is in screen space, but max sk
vmpstr
2016/09/07 22:06:40
max skewport extent is in screen space as well (it
enne (OOO)
2016/09/07 22:13:03
Oh right, I see that now. More descriptive variab
vmpstr
2016/09/07 22:48:28
Done.
| |
| 806 return PrioritizedTile(tile, this, tile_priority, IsTileOccluded(tile), | |
| 807 process_for_images_only); | |
| 784 } | 808 } |
| 785 | 809 |
| 786 std::map<const Tile*, PrioritizedTile> | 810 std::map<const Tile*, PrioritizedTile> |
| 787 PictureLayerTiling::UpdateAndGetAllPrioritizedTilesForTesting() const { | 811 PictureLayerTiling::UpdateAndGetAllPrioritizedTilesForTesting() const { |
| 788 std::map<const Tile*, PrioritizedTile> result; | 812 std::map<const Tile*, PrioritizedTile> result; |
| 789 for (const auto& key_tile_pair : tiles_) { | 813 for (const auto& key_tile_pair : tiles_) { |
| 790 Tile* tile = key_tile_pair.second.get(); | 814 Tile* tile = key_tile_pair.second.get(); |
| 791 UpdateRequiredStatesOnTile(tile); | 815 UpdateRequiredStatesOnTile(tile); |
| 792 PrioritizedTile prioritized_tile = | 816 PrioritizedTile prioritized_tile = |
| 793 MakePrioritizedTile(tile, ComputePriorityRectTypeForTile(tile)); | 817 MakePrioritizedTile(tile, ComputePriorityRectTypeForTile(tile)); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 879 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { | 903 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { |
| 880 size_t amount = 0; | 904 size_t amount = 0; |
| 881 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 905 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| 882 const Tile* tile = it->second.get(); | 906 const Tile* tile = it->second.get(); |
| 883 amount += tile->GPUMemoryUsageInBytes(); | 907 amount += tile->GPUMemoryUsageInBytes(); |
| 884 } | 908 } |
| 885 return amount; | 909 return amount; |
| 886 } | 910 } |
| 887 | 911 |
| 888 } // namespace cc | 912 } // namespace cc |
| OLD | NEW |