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 float minimum_contents_scale, |
86 float maximum_contents_scale) { | 92 float maximum_contents_scale) { |
87 RemoveTilingsBelowScale(minimum_contents_scale); | 93 RemoveTilingsBelowScale(minimum_contents_scale); |
88 RemoveTilingsAboveScale(maximum_contents_scale); | 94 RemoveTilingsAboveScale(maximum_contents_scale); |
89 | 95 |
90 // 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. |
91 // (if it exists). | 97 // Also, copy all of the properties from twin tilings. |
92 if (pending_twin_set) | 98 CopyTilingsAndPropertiesFromPendingTwin(pending_twin_set, raster_source); |
93 CopyTilingsFromPendingTwin(pending_twin_set, raster_source); | |
94 | 99 |
95 // If the tiling is not shared (FindTilingWithScale returns nullptr) or if | 100 // If the tiling is not shared (FindTilingWithScale returns nullptr), then |
96 // |this| is the sync set (pending_twin_set is nullptr), then invalidate | 101 // invalidate tiles and update them to the new raster source. |
97 // tiles and update them to the new raster source. | |
98 for (PictureLayerTiling* tiling : tilings_) { | 102 for (PictureLayerTiling* tiling : tilings_) { |
99 if (pending_twin_set && | 103 if (pending_twin_set->FindTilingWithScale(tiling->contents_scale())) |
100 pending_twin_set->FindTilingWithScale(tiling->contents_scale())) { | |
101 continue; | 104 continue; |
102 } | |
103 | 105 |
104 tiling->SetRasterSourceAndResize(raster_source); | 106 tiling->SetRasterSourceAndResize(raster_source); |
105 tiling->Invalidate(layer_invalidation); | 107 tiling->Invalidate(layer_invalidation); |
106 tiling->SetRasterSourceOnTiles(); | 108 tiling->SetRasterSourceOnTiles(); |
107 // This is needed for cases where the live tiles rect didn't change but | 109 // 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 | 110 // recordings exist in the raster source that did not exist on the last |
109 // raster source. | 111 // raster source. |
110 tiling->CreateMissingTilesInLiveTilesRect(); | 112 tiling->CreateMissingTilesInLiveTilesRect(); |
111 | 113 |
112 // If |pending_twin_set| is present, then |this| is active and |tiling| is | 114 // |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. | 115 // it is now NON_IDEAL_RESOLUTION. |
114 if (pending_twin_set) | 116 tiling->set_resolution(NON_IDEAL_RESOLUTION); |
115 tiling->set_resolution(NON_IDEAL_RESOLUTION); | |
116 } | 117 } |
117 | 118 |
118 tilings_.sort(LargestToSmallestScaleFunctor()); | 119 VerifyTilings(pending_twin_set); |
| 120 } |
119 | 121 |
| 122 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSourceForCommit( |
| 123 scoped_refptr<RasterSource> raster_source, |
| 124 const Region& layer_invalidation, |
| 125 float minimum_contents_scale, |
| 126 float maximum_contents_scale) { |
| 127 RemoveTilingsBelowScale(minimum_contents_scale); |
| 128 RemoveTilingsAboveScale(maximum_contents_scale); |
| 129 |
| 130 // Invalidate tiles and update them to the new raster source. |
| 131 for (PictureLayerTiling* tiling : tilings_) { |
| 132 tiling->SetRasterSourceAndResize(raster_source); |
| 133 tiling->Invalidate(layer_invalidation); |
| 134 tiling->SetRasterSourceOnTiles(); |
| 135 // 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 |
| 137 // raster source. |
| 138 tiling->CreateMissingTilesInLiveTilesRect(); |
| 139 } |
| 140 VerifyTilings(nullptr /* pending_twin_set */); |
| 141 } |
| 142 |
| 143 void PictureLayerTilingSet::UpdateRasterSourceDueToLCDChange( |
| 144 const scoped_refptr<RasterSource>& raster_source, |
| 145 const Region& layer_invalidation) { |
| 146 for (PictureLayerTiling* tiling : tilings_) { |
| 147 tiling->SetRasterSourceAndResize(raster_source); |
| 148 tiling->Invalidate(layer_invalidation); |
| 149 tiling->VerifyAllTilesHaveCurrentRasterSource(); |
| 150 } |
| 151 } |
| 152 |
| 153 void PictureLayerTilingSet::VerifyTilings( |
| 154 const PictureLayerTilingSet* pending_twin_set) const { |
120 #if DCHECK_IS_ON() | 155 #if DCHECK_IS_ON() |
121 for (PictureLayerTiling* tiling : tilings_) { | 156 for (PictureLayerTiling* tiling : tilings_) { |
122 DCHECK(tiling->tile_size() == | 157 DCHECK(tiling->tile_size() == |
123 client_->CalculateTileSize(tiling->tiling_size())) | 158 client_->CalculateTileSize(tiling->tiling_size())) |
124 << "tile_size: " << tiling->tile_size().ToString() | 159 << "tile_size: " << tiling->tile_size().ToString() |
125 << " tiling_size: " << tiling->tiling_size().ToString() | 160 << " tiling_size: " << tiling->tiling_size().ToString() |
126 << " CalculateTileSize: " | 161 << " CalculateTileSize: " |
127 << client_->CalculateTileSize(tiling->tiling_size()).ToString(); | 162 << client_->CalculateTileSize(tiling->tiling_size()).ToString(); |
128 } | 163 } |
129 | 164 |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 case LOWER_THAN_LOW_RES: | 584 case LOWER_THAN_LOW_RES: |
550 range = TilingRange(low_res_range.end, tilings_.size()); | 585 range = TilingRange(low_res_range.end, tilings_.size()); |
551 break; | 586 break; |
552 } | 587 } |
553 | 588 |
554 DCHECK_LE(range.start, range.end); | 589 DCHECK_LE(range.start, range.end); |
555 return range; | 590 return range; |
556 } | 591 } |
557 | 592 |
558 } // namespace cc | 593 } // namespace cc |
OLD | NEW |