| 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/resources/picture_layer_tiling_set.h" | 5 #include "cc/resources/picture_layer_tiling_set.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale); | 70 PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale); |
| 71 if (!this_tiling) { | 71 if (!this_tiling) { |
| 72 scoped_ptr<PictureLayerTiling> new_tiling = PictureLayerTiling::Create( | 72 scoped_ptr<PictureLayerTiling> new_tiling = PictureLayerTiling::Create( |
| 73 contents_scale, raster_source, client_, max_tiles_for_interest_area_, | 73 contents_scale, raster_source, client_, max_tiles_for_interest_area_, |
| 74 skewport_target_time_in_seconds_, | 74 skewport_target_time_in_seconds_, |
| 75 skewport_extrapolation_limit_in_content_pixels_); | 75 skewport_extrapolation_limit_in_content_pixels_); |
| 76 tilings_.push_back(new_tiling.Pass()); | 76 tilings_.push_back(new_tiling.Pass()); |
| 77 this_tiling = tilings_.back(); | 77 this_tiling = tilings_.back(); |
| 78 tiling_sort_required = true; | 78 tiling_sort_required = true; |
| 79 } | 79 } |
| 80 this_tiling->CloneTilesAndPropertiesFrom(*pending_twin_tiling); | 80 this_tiling->TakeTilesAndPropertiesFrom(pending_twin_tiling); |
| 81 } | 81 } |
| 82 | 82 |
| 83 if (tiling_sort_required) | 83 if (tiling_sort_required) |
| 84 tilings_.sort(LargestToSmallestScaleFunctor()); | 84 tilings_.sort(LargestToSmallestScaleFunctor()); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSourceForActivation( | 87 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSourceForActivation( |
| 88 scoped_refptr<RasterSource> raster_source, | 88 scoped_refptr<RasterSource> raster_source, |
| 89 const PictureLayerTilingSet* pending_twin_set, | 89 const PictureLayerTilingSet* pending_twin_set, |
| 90 const Region& layer_invalidation, | 90 const Region& layer_invalidation, |
| 91 float minimum_contents_scale, | 91 float minimum_contents_scale, |
| 92 float maximum_contents_scale) { | 92 float maximum_contents_scale) { |
| 93 RemoveTilingsBelowScale(minimum_contents_scale); | 93 RemoveTilingsBelowScale(minimum_contents_scale); |
| 94 RemoveTilingsAboveScale(maximum_contents_scale); | 94 RemoveTilingsAboveScale(maximum_contents_scale); |
| 95 | 95 |
| 96 // Copy over tilings that are shared with the |pending_twin_set| tiling set. | 96 // Copy over tilings that are shared with the |pending_twin_set| tiling set. |
| 97 // Also, copy all of the properties from twin tilings. | 97 // Also, copy all of the properties from twin tilings. |
| 98 CopyTilingsAndPropertiesFromPendingTwin(pending_twin_set, raster_source); | 98 CopyTilingsAndPropertiesFromPendingTwin(pending_twin_set, raster_source); |
| 99 | 99 |
| 100 // If the tiling is not shared (FindTilingWithScale returns nullptr), then | 100 // If the tiling is not shared (FindTilingWithScale returns nullptr), then |
| 101 // invalidate tiles and update them to the new raster source. | 101 // invalidate tiles and update them to the new raster source. |
| 102 for (PictureLayerTiling* tiling : tilings_) { | 102 for (PictureLayerTiling* tiling : tilings_) { |
| 103 if (pending_twin_set->FindTilingWithScale(tiling->contents_scale())) | 103 if (pending_twin_set->FindTilingWithScale(tiling->contents_scale())) |
| 104 continue; | 104 continue; |
| 105 | 105 |
| 106 tiling->SetRasterSourceAndResize(raster_source); | 106 tiling->SetRasterSourceAndResize(raster_source); |
| 107 tiling->Invalidate(layer_invalidation); | 107 tiling->Invalidate(layer_invalidation); |
| 108 tiling->SetRasterSourceOnTiles(); | |
| 109 // This is needed for cases where the live tiles rect didn't change but | 108 // This is needed for cases where the live tiles rect didn't change but |
| 110 // recordings exist in the raster source that did not exist on the last | 109 // recordings exist in the raster source that did not exist on the last |
| 111 // raster source. | 110 // raster source. |
| 112 tiling->CreateMissingTilesInLiveTilesRect(); | 111 tiling->CreateMissingTilesInLiveTilesRect(); |
| 113 | 112 |
| 114 // |this| is active set and |tiling| is not in the pending set, which means | 113 // |this| is active set and |tiling| is not in the pending set, which means |
| 115 // it is now NON_IDEAL_RESOLUTION. | 114 // it is now NON_IDEAL_RESOLUTION. |
| 116 tiling->set_resolution(NON_IDEAL_RESOLUTION); | 115 tiling->set_resolution(NON_IDEAL_RESOLUTION); |
| 117 } | 116 } |
| 118 | 117 |
| 119 VerifyTilings(pending_twin_set); | 118 VerifyTilings(pending_twin_set); |
| 120 } | 119 } |
| 121 | 120 |
| 122 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSourceForCommit( | 121 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSourceForCommit( |
| 123 scoped_refptr<RasterSource> raster_source, | 122 scoped_refptr<RasterSource> raster_source, |
| 124 const Region& layer_invalidation, | 123 const Region& layer_invalidation, |
| 125 float minimum_contents_scale, | 124 float minimum_contents_scale, |
| 126 float maximum_contents_scale) { | 125 float maximum_contents_scale) { |
| 127 RemoveTilingsBelowScale(minimum_contents_scale); | 126 RemoveTilingsBelowScale(minimum_contents_scale); |
| 128 RemoveTilingsAboveScale(maximum_contents_scale); | 127 RemoveTilingsAboveScale(maximum_contents_scale); |
| 129 | 128 |
| 130 // Invalidate tiles and update them to the new raster source. | 129 // Invalidate tiles and update them to the new raster source. |
| 131 for (PictureLayerTiling* tiling : tilings_) { | 130 for (PictureLayerTiling* tiling : tilings_) { |
| 132 tiling->SetRasterSourceAndResize(raster_source); | 131 tiling->SetRasterSourceAndResize(raster_source); |
| 133 tiling->Invalidate(layer_invalidation); | 132 tiling->Invalidate(layer_invalidation); |
| 134 tiling->SetRasterSourceOnTiles(); | |
| 135 // This is needed for cases where the live tiles rect didn't change but | 133 // This is needed for cases where the live tiles rect didn't change but |
| 136 // recordings exist in the raster source that did not exist on the last | 134 // recordings exist in the raster source that did not exist on the last |
| 137 // raster source. | 135 // raster source. |
| 138 tiling->CreateMissingTilesInLiveTilesRect(); | 136 tiling->CreateMissingTilesInLiveTilesRect(); |
| 139 } | 137 } |
| 140 VerifyTilings(nullptr /* pending_twin_set */); | 138 VerifyTilings(nullptr /* pending_twin_set */); |
| 141 } | 139 } |
| 142 | 140 |
| 143 void PictureLayerTilingSet::UpdateRasterSourceDueToLCDChange( | 141 void PictureLayerTilingSet::UpdateRasterSourceDueToLCDChange( |
| 144 const scoped_refptr<RasterSource>& raster_source, | 142 const scoped_refptr<RasterSource>& raster_source, |
| 145 const Region& layer_invalidation) { | 143 const Region& layer_invalidation) { |
| 146 for (PictureLayerTiling* tiling : tilings_) { | 144 for (PictureLayerTiling* tiling : tilings_) { |
| 147 tiling->SetRasterSourceAndResize(raster_source); | 145 tiling->SetRasterSourceAndResize(raster_source); |
| 148 tiling->Invalidate(layer_invalidation); | 146 tiling->Invalidate(layer_invalidation); |
| 147 // Since the invalidation changed, we need to create any missing tiles in |
| 148 // the live tiles rect again. |
| 149 tiling->CreateMissingTilesInLiveTilesRect(); |
| 149 tiling->VerifyAllTilesHaveCurrentRasterSource(); | 150 tiling->VerifyAllTilesHaveCurrentRasterSource(); |
| 150 } | 151 } |
| 151 } | 152 } |
| 152 | 153 |
| 153 void PictureLayerTilingSet::VerifyTilings( | 154 void PictureLayerTilingSet::VerifyTilings( |
| 154 const PictureLayerTilingSet* pending_twin_set) const { | 155 const PictureLayerTilingSet* pending_twin_set) const { |
| 155 #if DCHECK_IS_ON() | 156 #if DCHECK_IS_ON() |
| 156 for (PictureLayerTiling* tiling : tilings_) { | 157 for (PictureLayerTiling* tiling : tilings_) { |
| 157 DCHECK(tiling->tile_size() == | 158 DCHECK(tiling->tile_size() == |
| 158 client_->CalculateTileSize(tiling->tiling_size())) | 159 client_->CalculateTileSize(tiling->tiling_size())) |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 case LOWER_THAN_LOW_RES: | 585 case LOWER_THAN_LOW_RES: |
| 585 range = TilingRange(low_res_range.end, tilings_.size()); | 586 range = TilingRange(low_res_range.end, tilings_.size()); |
| 586 break; | 587 break; |
| 587 } | 588 } |
| 588 | 589 |
| 589 DCHECK_LE(range.start, range.end); | 590 DCHECK_LE(range.start, range.end); |
| 590 return range; | 591 return range; |
| 591 } | 592 } |
| 592 | 593 |
| 593 } // namespace cc | 594 } // namespace cc |
| OLD | NEW |