| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 skewport_extrapolation_limit_in_content_pixels_( | 48 skewport_extrapolation_limit_in_content_pixels_( |
| 49 skewport_extrapolation_limit_in_content_pixels), | 49 skewport_extrapolation_limit_in_content_pixels), |
| 50 client_(client) { | 50 client_(client) { |
| 51 } | 51 } |
| 52 | 52 |
| 53 PictureLayerTilingSet::~PictureLayerTilingSet() { | 53 PictureLayerTilingSet::~PictureLayerTilingSet() { |
| 54 } | 54 } |
| 55 | 55 |
| 56 void PictureLayerTilingSet::CopyTilingsAndPropertiesFromPendingTwin( | 56 void PictureLayerTilingSet::CopyTilingsAndPropertiesFromPendingTwin( |
| 57 const PictureLayerTilingSet* pending_twin_set, | 57 const PictureLayerTilingSet* pending_twin_set, |
| 58 const scoped_refptr<RasterSource>& raster_source, | 58 const scoped_refptr<RasterSource>& raster_source) { |
| 59 const Region& layer_invalidation) { | |
| 60 if (pending_twin_set->tilings_.empty()) { | 59 if (pending_twin_set->tilings_.empty()) { |
| 61 // If the twin (pending) tiling set is empty, it was not updated for the | 60 // If the twin (pending) tiling set is empty, it was not updated for the |
| 62 // current frame. So we drop tilings from our set as well, instead of | 61 // current frame. So we drop tilings from our set as well, instead of |
| 63 // leaving behind unshared tilings that are all non-ideal. | 62 // leaving behind unshared tilings that are all non-ideal. |
| 64 RemoveAllTilings(); | 63 RemoveAllTilings(); |
| 65 return; | 64 return; |
| 66 } | 65 } |
| 67 | 66 |
| 68 bool tiling_sort_required = false; | 67 bool tiling_sort_required = false; |
| 69 for (PictureLayerTiling* pending_twin_tiling : pending_twin_set->tilings_) { | 68 for (PictureLayerTiling* pending_twin_tiling : pending_twin_set->tilings_) { |
| 70 float contents_scale = pending_twin_tiling->contents_scale(); | 69 float contents_scale = pending_twin_tiling->contents_scale(); |
| 71 PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale); | 70 PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale); |
| 72 if (!this_tiling) { | 71 if (!this_tiling) { |
| 73 scoped_ptr<PictureLayerTiling> new_tiling = PictureLayerTiling::Create( | 72 scoped_ptr<PictureLayerTiling> new_tiling = PictureLayerTiling::Create( |
| 74 contents_scale, raster_source, client_, max_tiles_for_interest_area_, | 73 contents_scale, raster_source, client_, max_tiles_for_interest_area_, |
| 75 skewport_target_time_in_seconds_, | 74 skewport_target_time_in_seconds_, |
| 76 skewport_extrapolation_limit_in_content_pixels_); | 75 skewport_extrapolation_limit_in_content_pixels_); |
| 77 tilings_.push_back(new_tiling.Pass()); | 76 tilings_.push_back(new_tiling.Pass()); |
| 78 this_tiling = tilings_.back(); | 77 this_tiling = tilings_.back(); |
| 79 tiling_sort_required = true; | 78 tiling_sort_required = true; |
| 80 } | 79 } |
| 81 this_tiling->TakeTilesAndPropertiesFrom(pending_twin_tiling, | 80 this_tiling->CloneTilesAndPropertiesFrom(*pending_twin_tiling); |
| 82 layer_invalidation); | |
| 83 } | 81 } |
| 84 | 82 |
| 85 if (tiling_sort_required) | 83 if (tiling_sort_required) |
| 86 tilings_.sort(LargestToSmallestScaleFunctor()); | 84 tilings_.sort(LargestToSmallestScaleFunctor()); |
| 87 } | 85 } |
| 88 | 86 |
| 89 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSourceForActivation( | 87 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSourceForActivation( |
| 90 scoped_refptr<RasterSource> raster_source, | 88 scoped_refptr<RasterSource> raster_source, |
| 91 const PictureLayerTilingSet* pending_twin_set, | 89 const PictureLayerTilingSet* pending_twin_set, |
| 92 const Region& layer_invalidation, | 90 const Region& layer_invalidation, |
| 93 float minimum_contents_scale, | 91 float minimum_contents_scale, |
| 94 float maximum_contents_scale) { | 92 float maximum_contents_scale) { |
| 95 RemoveTilingsBelowScale(minimum_contents_scale); | 93 RemoveTilingsBelowScale(minimum_contents_scale); |
| 96 RemoveTilingsAboveScale(maximum_contents_scale); | 94 RemoveTilingsAboveScale(maximum_contents_scale); |
| 97 | 95 |
| 98 // 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. |
| 99 // Also, copy all of the properties from twin tilings. | 97 // Also, copy all of the properties from twin tilings. |
| 100 CopyTilingsAndPropertiesFromPendingTwin(pending_twin_set, raster_source, | 98 CopyTilingsAndPropertiesFromPendingTwin(pending_twin_set, raster_source); |
| 101 layer_invalidation); | |
| 102 | 99 |
| 103 // If the tiling is not shared (FindTilingWithScale returns nullptr), then | 100 // If the tiling is not shared (FindTilingWithScale returns nullptr), then |
| 104 // invalidate tiles and update them to the new raster source. | 101 // invalidate tiles and update them to the new raster source. |
| 105 for (PictureLayerTiling* tiling : tilings_) { | 102 for (PictureLayerTiling* tiling : tilings_) { |
| 106 if (pending_twin_set->FindTilingWithScale(tiling->contents_scale())) | 103 if (pending_twin_set->FindTilingWithScale(tiling->contents_scale())) |
| 107 continue; | 104 continue; |
| 108 | 105 |
| 109 tiling->SetRasterSourceAndResize(raster_source); | 106 tiling->SetRasterSourceAndResize(raster_source); |
| 110 tiling->Invalidate(layer_invalidation); | 107 tiling->Invalidate(layer_invalidation); |
| 111 tiling->SetRasterSourceOnTiles(); | 108 tiling->SetRasterSourceOnTiles(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 142 } | 139 } |
| 143 VerifyTilings(nullptr /* pending_twin_set */); | 140 VerifyTilings(nullptr /* pending_twin_set */); |
| 144 } | 141 } |
| 145 | 142 |
| 146 void PictureLayerTilingSet::UpdateRasterSourceDueToLCDChange( | 143 void PictureLayerTilingSet::UpdateRasterSourceDueToLCDChange( |
| 147 const scoped_refptr<RasterSource>& raster_source, | 144 const scoped_refptr<RasterSource>& raster_source, |
| 148 const Region& layer_invalidation) { | 145 const Region& layer_invalidation) { |
| 149 for (PictureLayerTiling* tiling : tilings_) { | 146 for (PictureLayerTiling* tiling : tilings_) { |
| 150 tiling->SetRasterSourceAndResize(raster_source); | 147 tiling->SetRasterSourceAndResize(raster_source); |
| 151 tiling->Invalidate(layer_invalidation); | 148 tiling->Invalidate(layer_invalidation); |
| 152 // Since the invalidation changed, we need to create any missing tiles in | |
| 153 // the live tiles rect again. | |
| 154 tiling->CreateMissingTilesInLiveTilesRect(); | |
| 155 tiling->VerifyAllTilesHaveCurrentRasterSource(); | 149 tiling->VerifyAllTilesHaveCurrentRasterSource(); |
| 156 } | 150 } |
| 157 } | 151 } |
| 158 | 152 |
| 159 void PictureLayerTilingSet::VerifyTilings( | 153 void PictureLayerTilingSet::VerifyTilings( |
| 160 const PictureLayerTilingSet* pending_twin_set) const { | 154 const PictureLayerTilingSet* pending_twin_set) const { |
| 161 #if DCHECK_IS_ON() | 155 #if DCHECK_IS_ON() |
| 162 for (PictureLayerTiling* tiling : tilings_) { | 156 for (PictureLayerTiling* tiling : tilings_) { |
| 163 DCHECK(tiling->tile_size() == | 157 DCHECK(tiling->tile_size() == |
| 164 client_->CalculateTileSize(tiling->tiling_size())) | 158 client_->CalculateTileSize(tiling->tiling_size())) |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 case LOWER_THAN_LOW_RES: | 584 case LOWER_THAN_LOW_RES: |
| 591 range = TilingRange(low_res_range.end, tilings_.size()); | 585 range = TilingRange(low_res_range.end, tilings_.size()); |
| 592 break; | 586 break; |
| 593 } | 587 } |
| 594 | 588 |
| 595 DCHECK_LE(range.start, range.end); | 589 DCHECK_LE(range.start, range.end); |
| 596 return range; | 590 return range; |
| 597 } | 591 } |
| 598 | 592 |
| 599 } // namespace cc | 593 } // namespace cc |
| OLD | NEW |