| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 : max_tiles_for_interest_area_(max_tiles_for_interest_area), | 46 : max_tiles_for_interest_area_(max_tiles_for_interest_area), |
| 47 skewport_target_time_in_seconds_(skewport_target_time_in_seconds), | 47 skewport_target_time_in_seconds_(skewport_target_time_in_seconds), |
| 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::CopyTilingsFromPendingTwin( | 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 if (pending_twin_set->tilings_.empty()) { | 59 if (pending_twin_set->tilings_.empty()) { |
| 60 // 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 |
| 61 // 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 |
| 62 // leaving behind unshared tilings that are all non-ideal. | 62 // leaving behind unshared tilings that are all non-ideal. |
| 63 RemoveAllTilings(); | 63 RemoveAllTilings(); |
| 64 return; |
| 64 } | 65 } |
| 65 | 66 |
| 67 bool tiling_sort_required = false; |
| 66 for (PictureLayerTiling* pending_twin_tiling : pending_twin_set->tilings_) { | 68 for (PictureLayerTiling* pending_twin_tiling : pending_twin_set->tilings_) { |
| 67 float contents_scale = pending_twin_tiling->contents_scale(); | 69 float contents_scale = pending_twin_tiling->contents_scale(); |
| 68 PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale); | 70 PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale); |
| 69 if (!this_tiling) { | 71 if (!this_tiling) { |
| 70 scoped_ptr<PictureLayerTiling> new_tiling = PictureLayerTiling::Create( | 72 scoped_ptr<PictureLayerTiling> new_tiling = PictureLayerTiling::Create( |
| 71 contents_scale, raster_source, client_, max_tiles_for_interest_area_, | 73 contents_scale, raster_source, client_, max_tiles_for_interest_area_, |
| 72 skewport_target_time_in_seconds_, | 74 skewport_target_time_in_seconds_, |
| 73 skewport_extrapolation_limit_in_content_pixels_); | 75 skewport_extrapolation_limit_in_content_pixels_); |
| 74 tilings_.push_back(new_tiling.Pass()); | 76 tilings_.push_back(new_tiling.Pass()); |
| 75 this_tiling = tilings_.back(); | 77 this_tiling = tilings_.back(); |
| 78 tiling_sort_required = true; |
| 76 } | 79 } |
| 77 this_tiling->CloneTilesAndPropertiesFrom(*pending_twin_tiling); | 80 this_tiling->CloneTilesAndPropertiesFrom(*pending_twin_tiling); |
| 78 } | 81 } |
| 82 |
| 83 if (tiling_sort_required) |
| 84 tilings_.sort(LargestToSmallestScaleFunctor()); |
| 79 } | 85 } |
| 80 | 86 |
| 81 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSource( | 87 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSourceForActivation( |
| 82 scoped_refptr<RasterSource> raster_source, | 88 scoped_refptr<RasterSource> raster_source, |
| 83 const PictureLayerTilingSet* pending_twin_set, | 89 const PictureLayerTilingSet* pending_twin_set, |
| 84 const Region& layer_invalidation, | 90 const Region& layer_invalidation) { |
| 85 float minimum_contents_scale, | 91 // Copy over tilings that are shared with the |pending_twin_set| tiling set. |
| 86 float maximum_contents_scale) { | 92 // Also, copy all of the properties from twin tilings. |
| 87 RemoveTilingsBelowScale(minimum_contents_scale); | 93 CopyTilingsAndPropertiesFromPendingTwin(pending_twin_set, raster_source); |
| 88 RemoveTilingsAboveScale(maximum_contents_scale); | |
| 89 | 94 |
| 90 // Copy over tilings that are shared with the |pending_twin_set| tiling set | 95 // If the tiling is not shared (FindTilingWithScale returns nullptr), then |
| 91 // (if it exists). | 96 // invalidate tiles and update them to the new raster source. |
| 92 if (pending_twin_set) | |
| 93 CopyTilingsFromPendingTwin(pending_twin_set, raster_source); | |
| 94 | |
| 95 // If the tiling is not shared (FindTilingWithScale returns nullptr) or if | |
| 96 // |this| is the sync set (pending_twin_set is nullptr), then invalidate | |
| 97 // tiles and update them to the new raster source. | |
| 98 for (PictureLayerTiling* tiling : tilings_) { | 97 for (PictureLayerTiling* tiling : tilings_) { |
| 99 if (pending_twin_set && | 98 if (pending_twin_set->FindTilingWithScale(tiling->contents_scale())) |
| 100 pending_twin_set->FindTilingWithScale(tiling->contents_scale())) { | |
| 101 continue; | 99 continue; |
| 102 } | |
| 103 | 100 |
| 104 tiling->SetRasterSourceAndResize(raster_source); | 101 tiling->SetRasterSourceAndResize(raster_source); |
| 105 tiling->Invalidate(layer_invalidation); | 102 tiling->Invalidate(layer_invalidation); |
| 106 tiling->SetRasterSourceOnTiles(); | 103 tiling->SetRasterSourceOnTiles(); |
| 107 // This is needed for cases where the live tiles rect didn't change but | 104 // This is needed for cases where the live tiles rect didn't change but |
| 108 // recordings exist in the raster source that did not exist on the last | 105 // recordings exist in the raster source that did not exist on the last |
| 109 // raster source. | 106 // raster source. |
| 110 tiling->CreateMissingTilesInLiveTilesRect(); | 107 tiling->CreateMissingTilesInLiveTilesRect(); |
| 111 | 108 |
| 112 // If |pending_twin_set| is present, then |this| is active and |tiling| is | 109 // |this| is active set and |tiling| is not in the pending set, which means |
| 113 // not in the pending set, which means it is now NON_IDEAL_RESOLUTION. | 110 // it is now NON_IDEAL_RESOLUTION. |
| 114 if (pending_twin_set) | 111 tiling->set_resolution(NON_IDEAL_RESOLUTION); |
| 115 tiling->set_resolution(NON_IDEAL_RESOLUTION); | |
| 116 } | 112 } |
| 117 | 113 |
| 118 tilings_.sort(LargestToSmallestScaleFunctor()); | 114 VerifyTilings(pending_twin_set); |
| 115 } |
| 119 | 116 |
| 117 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSourceForCommit( |
| 118 scoped_refptr<RasterSource> raster_source, |
| 119 const Region& layer_invalidation) { |
| 120 // Invalidate tiles and update them to the new raster source. |
| 121 for (PictureLayerTiling* tiling : tilings_) { |
| 122 tiling->SetRasterSourceAndResize(raster_source); |
| 123 tiling->Invalidate(layer_invalidation); |
| 124 tiling->SetRasterSourceOnTiles(); |
| 125 // This is needed for cases where the live tiles rect didn't change but |
| 126 // recordings exist in the raster source that did not exist on the last |
| 127 // raster source. |
| 128 tiling->CreateMissingTilesInLiveTilesRect(); |
| 129 } |
| 130 VerifyTilings(nullptr /* pending_twin_set */); |
| 131 } |
| 132 |
| 133 void PictureLayerTilingSet::UpdateRasterSourceDueToLCDChange( |
| 134 const scoped_refptr<RasterSource>& raster_source, |
| 135 const Region& layer_invalidation) { |
| 136 for (PictureLayerTiling* tiling : tilings_) { |
| 137 tiling->SetRasterSourceAndResize(raster_source); |
| 138 tiling->Invalidate(layer_invalidation); |
| 139 tiling->VerifyAllTilesHaveCurrentRasterSource(); |
| 140 } |
| 141 } |
| 142 |
| 143 void PictureLayerTilingSet::VerifyTilings( |
| 144 const PictureLayerTilingSet* pending_twin_set) const { |
| 120 #if DCHECK_IS_ON() | 145 #if DCHECK_IS_ON() |
| 121 for (PictureLayerTiling* tiling : tilings_) { | 146 for (PictureLayerTiling* tiling : tilings_) { |
| 122 DCHECK(tiling->tile_size() == | 147 DCHECK(tiling->tile_size() == |
| 123 client_->CalculateTileSize(tiling->tiling_size())) | 148 client_->CalculateTileSize(tiling->tiling_size())) |
| 124 << "tile_size: " << tiling->tile_size().ToString() | 149 << "tile_size: " << tiling->tile_size().ToString() |
| 125 << " tiling_size: " << tiling->tiling_size().ToString() | 150 << " tiling_size: " << tiling->tiling_size().ToString() |
| 126 << " CalculateTileSize: " | 151 << " CalculateTileSize: " |
| 127 << client_->CalculateTileSize(tiling->tiling_size()).ToString(); | 152 << client_->CalculateTileSize(tiling->tiling_size()).ToString(); |
| 128 } | 153 } |
| 129 | 154 |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 case LOWER_THAN_LOW_RES: | 574 case LOWER_THAN_LOW_RES: |
| 550 range = TilingRange(low_res_range.end, tilings_.size()); | 575 range = TilingRange(low_res_range.end, tilings_.size()); |
| 551 break; | 576 break; |
| 552 } | 577 } |
| 553 | 578 |
| 554 DCHECK_LE(range.start, range.end); | 579 DCHECK_LE(range.start, range.end); |
| 555 return range; | 580 return range; |
| 556 } | 581 } |
| 557 | 582 |
| 558 } // namespace cc | 583 } // namespace cc |
| OLD | NEW |