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