| 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_set.h" | 5 #include "cc/tiles/picture_layer_tiling_set.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 const float kMaxSoonBorderDistanceInScreenPixels = 312.f; | 36 const float kMaxSoonBorderDistanceInScreenPixels = 312.f; |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 // static | 40 // static |
| 41 std::unique_ptr<PictureLayerTilingSet> PictureLayerTilingSet::Create( | 41 std::unique_ptr<PictureLayerTilingSet> PictureLayerTilingSet::Create( |
| 42 WhichTree tree, | 42 WhichTree tree, |
| 43 PictureLayerTilingClient* client, | 43 PictureLayerTilingClient* client, |
| 44 int tiling_interest_area_padding, | 44 int tiling_interest_area_padding, |
| 45 float skewport_target_time_in_seconds, | 45 float skewport_target_time_in_seconds, |
| 46 int skewport_extrapolation_limit_in_screen_pixels) { | 46 int skewport_extrapolation_limit_in_screen_pixels, |
| 47 return base::WrapUnique( | 47 float max_preraster_distance) { |
| 48 new PictureLayerTilingSet(tree, client, tiling_interest_area_padding, | 48 return base::WrapUnique(new PictureLayerTilingSet( |
| 49 skewport_target_time_in_seconds, | 49 tree, client, tiling_interest_area_padding, |
| 50 skewport_extrapolation_limit_in_screen_pixels)); | 50 skewport_target_time_in_seconds, |
| 51 skewport_extrapolation_limit_in_screen_pixels, max_preraster_distance)); |
| 51 } | 52 } |
| 52 | 53 |
| 53 PictureLayerTilingSet::PictureLayerTilingSet( | 54 PictureLayerTilingSet::PictureLayerTilingSet( |
| 54 WhichTree tree, | 55 WhichTree tree, |
| 55 PictureLayerTilingClient* client, | 56 PictureLayerTilingClient* client, |
| 56 int tiling_interest_area_padding, | 57 int tiling_interest_area_padding, |
| 57 float skewport_target_time_in_seconds, | 58 float skewport_target_time_in_seconds, |
| 58 int skewport_extrapolation_limit_in_screen_pixels) | 59 int skewport_extrapolation_limit_in_screen_pixels, |
| 60 float max_preraster_distance) |
| 59 : tiling_interest_area_padding_(tiling_interest_area_padding), | 61 : tiling_interest_area_padding_(tiling_interest_area_padding), |
| 60 skewport_target_time_in_seconds_(skewport_target_time_in_seconds), | 62 skewport_target_time_in_seconds_(skewport_target_time_in_seconds), |
| 61 skewport_extrapolation_limit_in_screen_pixels_( | 63 skewport_extrapolation_limit_in_screen_pixels_( |
| 62 skewport_extrapolation_limit_in_screen_pixels), | 64 skewport_extrapolation_limit_in_screen_pixels), |
| 63 tree_(tree), | 65 tree_(tree), |
| 64 client_(client) {} | 66 client_(client), |
| 67 max_preraster_distance_(max_preraster_distance) {} |
| 65 | 68 |
| 66 PictureLayerTilingSet::~PictureLayerTilingSet() { | 69 PictureLayerTilingSet::~PictureLayerTilingSet() { |
| 67 } | 70 } |
| 68 | 71 |
| 69 void PictureLayerTilingSet::CopyTilingsAndPropertiesFromPendingTwin( | 72 void PictureLayerTilingSet::CopyTilingsAndPropertiesFromPendingTwin( |
| 70 const PictureLayerTilingSet* pending_twin_set, | 73 const PictureLayerTilingSet* pending_twin_set, |
| 71 scoped_refptr<RasterSource> raster_source, | 74 scoped_refptr<RasterSource> raster_source, |
| 72 const Region& layer_invalidation) { | 75 const Region& layer_invalidation) { |
| 73 if (pending_twin_set->tilings_.empty()) { | 76 if (pending_twin_set->tilings_.empty()) { |
| 74 // If the twin (pending) tiling set is empty, it was not updated for the | 77 // If the twin (pending) tiling set is empty, it was not updated for the |
| 75 // current frame. So we drop tilings from our set as well, instead of | 78 // current frame. So we drop tilings from our set as well, instead of |
| 76 // leaving behind unshared tilings that are all non-ideal. | 79 // leaving behind unshared tilings that are all non-ideal. |
| 77 RemoveAllTilings(); | 80 RemoveAllTilings(); |
| 78 return; | 81 return; |
| 79 } | 82 } |
| 80 | 83 |
| 81 bool tiling_sort_required = false; | 84 bool tiling_sort_required = false; |
| 82 for (const auto& pending_twin_tiling : pending_twin_set->tilings_) { | 85 for (const auto& pending_twin_tiling : pending_twin_set->tilings_) { |
| 83 float contents_scale = pending_twin_tiling->contents_scale(); | 86 float contents_scale = pending_twin_tiling->contents_scale(); |
| 84 PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale); | 87 PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale); |
| 85 if (!this_tiling) { | 88 if (!this_tiling) { |
| 86 std::unique_ptr<PictureLayerTiling> new_tiling(new PictureLayerTiling( | 89 std::unique_ptr<PictureLayerTiling> new_tiling(new PictureLayerTiling( |
| 87 tree_, contents_scale, raster_source_, client_)); | 90 tree_, contents_scale, raster_source_, client_, |
| 91 kMaxSoonBorderDistanceInScreenPixels, max_preraster_distance_)); |
| 88 tilings_.push_back(std::move(new_tiling)); | 92 tilings_.push_back(std::move(new_tiling)); |
| 89 this_tiling = tilings_.back().get(); | 93 this_tiling = tilings_.back().get(); |
| 90 tiling_sort_required = true; | 94 tiling_sort_required = true; |
| 91 state_since_last_tile_priority_update_.added_tilings = true; | 95 state_since_last_tile_priority_update_.added_tilings = true; |
| 92 } | 96 } |
| 93 this_tiling->TakeTilesAndPropertiesFrom(pending_twin_tiling.get(), | 97 this_tiling->TakeTilesAndPropertiesFrom(pending_twin_tiling.get(), |
| 94 layer_invalidation); | 98 layer_invalidation); |
| 95 } | 99 } |
| 96 | 100 |
| 97 if (tiling_sort_required) { | 101 if (tiling_sort_required) { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 scoped_refptr<RasterSource> raster_source) { | 269 scoped_refptr<RasterSource> raster_source) { |
| 266 if (!raster_source_) | 270 if (!raster_source_) |
| 267 raster_source_ = raster_source; | 271 raster_source_ = raster_source; |
| 268 | 272 |
| 269 for (size_t i = 0; i < tilings_.size(); ++i) { | 273 for (size_t i = 0; i < tilings_.size(); ++i) { |
| 270 DCHECK_NE(tilings_[i]->contents_scale(), contents_scale); | 274 DCHECK_NE(tilings_[i]->contents_scale(), contents_scale); |
| 271 DCHECK_EQ(tilings_[i]->raster_source(), raster_source.get()); | 275 DCHECK_EQ(tilings_[i]->raster_source(), raster_source.get()); |
| 272 } | 276 } |
| 273 | 277 |
| 274 tilings_.push_back(base::MakeUnique<PictureLayerTiling>( | 278 tilings_.push_back(base::MakeUnique<PictureLayerTiling>( |
| 275 tree_, contents_scale, raster_source, client_)); | 279 tree_, contents_scale, raster_source, client_, |
| 280 kMaxSoonBorderDistanceInScreenPixels, max_preraster_distance_)); |
| 276 PictureLayerTiling* appended = tilings_.back().get(); | 281 PictureLayerTiling* appended = tilings_.back().get(); |
| 277 state_since_last_tile_priority_update_.added_tilings = true; | 282 state_since_last_tile_priority_update_.added_tilings = true; |
| 278 | 283 |
| 279 std::sort(tilings_.begin(), tilings_.end(), LargestToSmallestScaleFunctor()); | 284 std::sort(tilings_.begin(), tilings_.end(), LargestToSmallestScaleFunctor()); |
| 280 return appended; | 285 return appended; |
| 281 } | 286 } |
| 282 | 287 |
| 283 int PictureLayerTilingSet::NumHighResTilings() const { | 288 int PictureLayerTilingSet::NumHighResTilings() const { |
| 284 return std::count_if(tilings_.begin(), tilings_.end(), | 289 return std::count_if(tilings_.begin(), tilings_.end(), |
| 285 [](const std::unique_ptr<PictureLayerTiling>& tiling) { | 290 [](const std::unique_ptr<PictureLayerTiling>& tiling) { |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 case LOWER_THAN_LOW_RES: | 753 case LOWER_THAN_LOW_RES: |
| 749 range = TilingRange(low_res_range.end, tilings_size); | 754 range = TilingRange(low_res_range.end, tilings_size); |
| 750 break; | 755 break; |
| 751 } | 756 } |
| 752 | 757 |
| 753 DCHECK_LE(range.start, range.end); | 758 DCHECK_LE(range.start, range.end); |
| 754 return range; | 759 return range; |
| 755 } | 760 } |
| 756 | 761 |
| 757 } // namespace cc | 762 } // namespace cc |
| OLD | NEW |