| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "cc/playback/display_list_raster_source.h" | 13 #include "cc/playback/raster_source.h" |
| 14 | 14 |
| 15 namespace cc { | 15 namespace cc { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 class LargestToSmallestScaleFunctor { | 19 class LargestToSmallestScaleFunctor { |
| 20 public: | 20 public: |
| 21 bool operator()(const scoped_ptr<PictureLayerTiling>& left, | 21 bool operator()(const scoped_ptr<PictureLayerTiling>& left, |
| 22 const scoped_ptr<PictureLayerTiling>& right) { | 22 const scoped_ptr<PictureLayerTiling>& right) { |
| 23 return left->contents_scale() > right->contents_scale(); | 23 return left->contents_scale() > right->contents_scale(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 skewport_extrapolation_limit_in_content_pixels_( | 56 skewport_extrapolation_limit_in_content_pixels_( |
| 57 skewport_extrapolation_limit_in_content_pixels), | 57 skewport_extrapolation_limit_in_content_pixels), |
| 58 tree_(tree), | 58 tree_(tree), |
| 59 client_(client) {} | 59 client_(client) {} |
| 60 | 60 |
| 61 PictureLayerTilingSet::~PictureLayerTilingSet() { | 61 PictureLayerTilingSet::~PictureLayerTilingSet() { |
| 62 } | 62 } |
| 63 | 63 |
| 64 void PictureLayerTilingSet::CopyTilingsAndPropertiesFromPendingTwin( | 64 void PictureLayerTilingSet::CopyTilingsAndPropertiesFromPendingTwin( |
| 65 const PictureLayerTilingSet* pending_twin_set, | 65 const PictureLayerTilingSet* pending_twin_set, |
| 66 scoped_refptr<DisplayListRasterSource> raster_source, | 66 scoped_refptr<RasterSource> raster_source, |
| 67 const Region& layer_invalidation) { | 67 const Region& layer_invalidation) { |
| 68 if (pending_twin_set->tilings_.empty()) { | 68 if (pending_twin_set->tilings_.empty()) { |
| 69 // If the twin (pending) tiling set is empty, it was not updated for the | 69 // If the twin (pending) tiling set is empty, it was not updated for the |
| 70 // current frame. So we drop tilings from our set as well, instead of | 70 // current frame. So we drop tilings from our set as well, instead of |
| 71 // leaving behind unshared tilings that are all non-ideal. | 71 // leaving behind unshared tilings that are all non-ideal. |
| 72 RemoveAllTilings(); | 72 RemoveAllTilings(); |
| 73 return; | 73 return; |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool tiling_sort_required = false; | 76 bool tiling_sort_required = false; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 90 layer_invalidation); | 90 layer_invalidation); |
| 91 } | 91 } |
| 92 | 92 |
| 93 if (tiling_sort_required) { | 93 if (tiling_sort_required) { |
| 94 std::sort(tilings_.begin(), tilings_.end(), | 94 std::sort(tilings_.begin(), tilings_.end(), |
| 95 LargestToSmallestScaleFunctor()); | 95 LargestToSmallestScaleFunctor()); |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSourceForActivation( | 99 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSourceForActivation( |
| 100 scoped_refptr<DisplayListRasterSource> raster_source, | 100 scoped_refptr<RasterSource> raster_source, |
| 101 const PictureLayerTilingSet* pending_twin_set, | 101 const PictureLayerTilingSet* pending_twin_set, |
| 102 const Region& layer_invalidation, | 102 const Region& layer_invalidation, |
| 103 float minimum_contents_scale, | 103 float minimum_contents_scale, |
| 104 float maximum_contents_scale) { | 104 float maximum_contents_scale) { |
| 105 RemoveTilingsBelowScale(minimum_contents_scale); | 105 RemoveTilingsBelowScale(minimum_contents_scale); |
| 106 RemoveTilingsAboveScale(maximum_contents_scale); | 106 RemoveTilingsAboveScale(maximum_contents_scale); |
| 107 | 107 |
| 108 // Copy over tilings that are shared with the |pending_twin_set| tiling set. | 108 // Copy over tilings that are shared with the |pending_twin_set| tiling set. |
| 109 // Also, copy all of the properties from twin tilings. | 109 // Also, copy all of the properties from twin tilings. |
| 110 CopyTilingsAndPropertiesFromPendingTwin(pending_twin_set, raster_source, | 110 CopyTilingsAndPropertiesFromPendingTwin(pending_twin_set, raster_source, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 129 // Since the pending tree does not have them, we should just leave them as | 129 // Since the pending tree does not have them, we should just leave them as |
| 130 // low resolution to not lose them. | 130 // low resolution to not lose them. |
| 131 if (tiling->resolution() != LOW_RESOLUTION) | 131 if (tiling->resolution() != LOW_RESOLUTION) |
| 132 tiling->set_resolution(NON_IDEAL_RESOLUTION); | 132 tiling->set_resolution(NON_IDEAL_RESOLUTION); |
| 133 } | 133 } |
| 134 | 134 |
| 135 VerifyTilings(pending_twin_set); | 135 VerifyTilings(pending_twin_set); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSourceForCommit( | 138 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSourceForCommit( |
| 139 scoped_refptr<DisplayListRasterSource> raster_source, | 139 scoped_refptr<RasterSource> raster_source, |
| 140 const Region& layer_invalidation, | 140 const Region& layer_invalidation, |
| 141 float minimum_contents_scale, | 141 float minimum_contents_scale, |
| 142 float maximum_contents_scale) { | 142 float maximum_contents_scale) { |
| 143 RemoveTilingsBelowScale(minimum_contents_scale); | 143 RemoveTilingsBelowScale(minimum_contents_scale); |
| 144 RemoveTilingsAboveScale(maximum_contents_scale); | 144 RemoveTilingsAboveScale(maximum_contents_scale); |
| 145 | 145 |
| 146 // Invalidate tiles and update them to the new raster source. | 146 // Invalidate tiles and update them to the new raster source. |
| 147 for (const scoped_ptr<PictureLayerTiling>& tiling : tilings_) { | 147 for (const scoped_ptr<PictureLayerTiling>& tiling : tilings_) { |
| 148 DCHECK(tree_ != PENDING_TREE || !tiling->has_tiles()); | 148 DCHECK(tree_ != PENDING_TREE || !tiling->has_tiles()); |
| 149 tiling->SetRasterSourceAndResize(raster_source); | 149 tiling->SetRasterSourceAndResize(raster_source); |
| 150 | 150 |
| 151 // We can commit on either active or pending trees, but only active one can | 151 // We can commit on either active or pending trees, but only active one can |
| 152 // have tiles at this point. | 152 // have tiles at this point. |
| 153 if (tree_ == ACTIVE_TREE) | 153 if (tree_ == ACTIVE_TREE) |
| 154 tiling->Invalidate(layer_invalidation); | 154 tiling->Invalidate(layer_invalidation); |
| 155 | 155 |
| 156 // This is needed for cases where the live tiles rect didn't change but | 156 // This is needed for cases where the live tiles rect didn't change but |
| 157 // recordings exist in the raster source that did not exist on the last | 157 // recordings exist in the raster source that did not exist on the last |
| 158 // raster source. | 158 // raster source. |
| 159 tiling->CreateMissingTilesInLiveTilesRect(); | 159 tiling->CreateMissingTilesInLiveTilesRect(); |
| 160 } | 160 } |
| 161 VerifyTilings(nullptr /* pending_twin_set */); | 161 VerifyTilings(nullptr /* pending_twin_set */); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void PictureLayerTilingSet::UpdateRasterSourceDueToLCDChange( | 164 void PictureLayerTilingSet::UpdateRasterSourceDueToLCDChange( |
| 165 scoped_refptr<DisplayListRasterSource> raster_source, | 165 scoped_refptr<RasterSource> raster_source, |
| 166 const Region& layer_invalidation) { | 166 const Region& layer_invalidation) { |
| 167 for (const auto& tiling : tilings_) { | 167 for (const auto& tiling : tilings_) { |
| 168 tiling->SetRasterSourceAndResize(raster_source); | 168 tiling->SetRasterSourceAndResize(raster_source); |
| 169 tiling->Invalidate(layer_invalidation); | 169 tiling->Invalidate(layer_invalidation); |
| 170 // Since the invalidation changed, we need to create any missing tiles in | 170 // Since the invalidation changed, we need to create any missing tiles in |
| 171 // the live tiles rect again. | 171 // the live tiles rect again. |
| 172 tiling->CreateMissingTilesInLiveTilesRect(); | 172 tiling->CreateMissingTilesInLiveTilesRect(); |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 tilings_.erase(to_remove, tilings_.end()); | 242 tilings_.erase(to_remove, tilings_.end()); |
| 243 } | 243 } |
| 244 | 244 |
| 245 void PictureLayerTilingSet::MarkAllTilingsNonIdeal() { | 245 void PictureLayerTilingSet::MarkAllTilingsNonIdeal() { |
| 246 for (const auto& tiling : tilings_) | 246 for (const auto& tiling : tilings_) |
| 247 tiling->set_resolution(NON_IDEAL_RESOLUTION); | 247 tiling->set_resolution(NON_IDEAL_RESOLUTION); |
| 248 } | 248 } |
| 249 | 249 |
| 250 PictureLayerTiling* PictureLayerTilingSet::AddTiling( | 250 PictureLayerTiling* PictureLayerTilingSet::AddTiling( |
| 251 float contents_scale, | 251 float contents_scale, |
| 252 scoped_refptr<DisplayListRasterSource> raster_source) { | 252 scoped_refptr<RasterSource> raster_source) { |
| 253 for (size_t i = 0; i < tilings_.size(); ++i) { | 253 for (size_t i = 0; i < tilings_.size(); ++i) { |
| 254 DCHECK_NE(tilings_[i]->contents_scale(), contents_scale); | 254 DCHECK_NE(tilings_[i]->contents_scale(), contents_scale); |
| 255 DCHECK_EQ(tilings_[i]->raster_source(), raster_source.get()); | 255 DCHECK_EQ(tilings_[i]->raster_source(), raster_source.get()); |
| 256 } | 256 } |
| 257 | 257 |
| 258 tilings_.push_back(PictureLayerTiling::Create( | 258 tilings_.push_back(PictureLayerTiling::Create( |
| 259 tree_, contents_scale, raster_source, client_, | 259 tree_, contents_scale, raster_source, client_, |
| 260 tiling_interest_area_padding_, skewport_target_time_in_seconds_, | 260 tiling_interest_area_padding_, skewport_target_time_in_seconds_, |
| 261 skewport_extrapolation_limit_in_content_pixels_)); | 261 skewport_extrapolation_limit_in_content_pixels_)); |
| 262 PictureLayerTiling* appended = tilings_.back().get(); | 262 PictureLayerTiling* appended = tilings_.back().get(); |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 case LOWER_THAN_LOW_RES: | 586 case LOWER_THAN_LOW_RES: |
| 587 range = TilingRange(low_res_range.end, tilings_size); | 587 range = TilingRange(low_res_range.end, tilings_size); |
| 588 break; | 588 break; |
| 589 } | 589 } |
| 590 | 590 |
| 591 DCHECK_LE(range.start, range.end); | 591 DCHECK_LE(range.start, range.end); |
| 592 return range; | 592 return range; |
| 593 } | 593 } |
| 594 | 594 |
| 595 } // namespace cc | 595 } // namespace cc |
| OLD | NEW |