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 |
| 11 #include "cc/resources/active_picture_layer_tiling.h" |
| 12 #include "cc/resources/pending_picture_layer_tiling.h" |
| 13 |
11 namespace cc { | 14 namespace cc { |
12 | 15 |
13 namespace { | 16 namespace { |
14 | 17 |
15 class LargestToSmallestScaleFunctor { | 18 class LargestToSmallestScaleFunctor { |
16 public: | 19 public: |
17 bool operator() (PictureLayerTiling* left, PictureLayerTiling* right) { | 20 bool operator() (PictureLayerTiling* left, PictureLayerTiling* right) { |
18 return left->contents_scale() > right->contents_scale(); | 21 return left->contents_scale() > right->contents_scale(); |
19 } | 22 } |
20 }; | 23 }; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // If the twin (pending) tiling set is empty, it was not updated for the | 63 // 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 | 64 // current frame. So we drop tilings from our set as well, instead of |
62 // leaving behind unshared tilings that are all non-ideal. | 65 // leaving behind unshared tilings that are all non-ideal. |
63 RemoveAllTilings(); | 66 RemoveAllTilings(); |
64 } | 67 } |
65 | 68 |
66 for (PictureLayerTiling* pending_twin_tiling : pending_twin_set->tilings_) { | 69 for (PictureLayerTiling* pending_twin_tiling : pending_twin_set->tilings_) { |
67 float contents_scale = pending_twin_tiling->contents_scale(); | 70 float contents_scale = pending_twin_tiling->contents_scale(); |
68 PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale); | 71 PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale); |
69 if (!this_tiling) { | 72 if (!this_tiling) { |
70 scoped_ptr<PictureLayerTiling> new_tiling = PictureLayerTiling::Create( | 73 scoped_ptr<PictureLayerTiling> new_tiling = |
71 contents_scale, raster_source, client_, max_tiles_for_interest_area_, | 74 ActivePictureLayerTiling::Create( |
72 skewport_target_time_in_seconds_, | 75 contents_scale, raster_source, client_, |
73 skewport_extrapolation_limit_in_content_pixels_); | 76 max_tiles_for_interest_area_, skewport_target_time_in_seconds_, |
| 77 skewport_extrapolation_limit_in_content_pixels_); |
74 tilings_.push_back(new_tiling.Pass()); | 78 tilings_.push_back(new_tiling.Pass()); |
75 this_tiling = tilings_.back(); | 79 this_tiling = tilings_.back(); |
76 } | 80 } |
77 this_tiling->CloneTilesAndPropertiesFrom(*pending_twin_tiling); | 81 this_tiling->TakeTilesAndPropertiesFrom(pending_twin_tiling); |
78 } | 82 } |
79 } | 83 } |
80 | 84 |
81 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSource( | 85 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSource( |
82 scoped_refptr<RasterSource> raster_source, | 86 scoped_refptr<RasterSource> raster_source, |
83 const PictureLayerTilingSet* pending_twin_set, | 87 const PictureLayerTilingSet* pending_twin_set, |
84 const Region& layer_invalidation, | 88 const Region& layer_invalidation, |
85 float minimum_contents_scale, | 89 float minimum_contents_scale, |
86 float maximum_contents_scale) { | 90 float maximum_contents_scale) { |
87 RemoveTilingsBelowScale(minimum_contents_scale); | 91 RemoveTilingsBelowScale(minimum_contents_scale); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 } | 214 } |
211 | 215 |
212 PictureLayerTiling* PictureLayerTilingSet::AddTiling( | 216 PictureLayerTiling* PictureLayerTilingSet::AddTiling( |
213 float contents_scale, | 217 float contents_scale, |
214 scoped_refptr<RasterSource> raster_source) { | 218 scoped_refptr<RasterSource> raster_source) { |
215 for (size_t i = 0; i < tilings_.size(); ++i) { | 219 for (size_t i = 0; i < tilings_.size(); ++i) { |
216 DCHECK_NE(tilings_[i]->contents_scale(), contents_scale); | 220 DCHECK_NE(tilings_[i]->contents_scale(), contents_scale); |
217 DCHECK_EQ(tilings_[i]->raster_source(), raster_source.get()); | 221 DCHECK_EQ(tilings_[i]->raster_source(), raster_source.get()); |
218 } | 222 } |
219 | 223 |
220 tilings_.push_back(PictureLayerTiling::Create( | 224 if (client_->GetTree() == PENDING_TREE) { |
221 contents_scale, raster_source, client_, max_tiles_for_interest_area_, | 225 tilings_.push_back(PendingPictureLayerTiling::Create( |
222 skewport_target_time_in_seconds_, | 226 contents_scale, raster_source, client_, max_tiles_for_interest_area_, |
223 skewport_extrapolation_limit_in_content_pixels_)); | 227 skewport_target_time_in_seconds_, |
| 228 skewport_extrapolation_limit_in_content_pixels_)); |
| 229 } else { |
| 230 tilings_.push_back(ActivePictureLayerTiling::Create( |
| 231 contents_scale, raster_source, client_, max_tiles_for_interest_area_, |
| 232 skewport_target_time_in_seconds_, |
| 233 skewport_extrapolation_limit_in_content_pixels_)); |
| 234 } |
224 PictureLayerTiling* appended = tilings_.back(); | 235 PictureLayerTiling* appended = tilings_.back(); |
225 | 236 |
226 tilings_.sort(LargestToSmallestScaleFunctor()); | 237 tilings_.sort(LargestToSmallestScaleFunctor()); |
227 return appended; | 238 return appended; |
228 } | 239 } |
229 | 240 |
230 int PictureLayerTilingSet::NumHighResTilings() const { | 241 int PictureLayerTilingSet::NumHighResTilings() const { |
231 return std::count_if(tilings_.begin(), tilings_.end(), | 242 return std::count_if(tilings_.begin(), tilings_.end(), |
232 [](PictureLayerTiling* tiling) { | 243 [](PictureLayerTiling* tiling) { |
233 return tiling->resolution() == HIGH_RESOLUTION; | 244 return tiling->resolution() == HIGH_RESOLUTION; |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 case LOWER_THAN_LOW_RES: | 560 case LOWER_THAN_LOW_RES: |
550 range = TilingRange(low_res_range.end, tilings_.size()); | 561 range = TilingRange(low_res_range.end, tilings_.size()); |
551 break; | 562 break; |
552 } | 563 } |
553 | 564 |
554 DCHECK_LE(range.start, range.end); | 565 DCHECK_LE(range.start, range.end); |
555 return range; | 566 return range; |
556 } | 567 } |
557 | 568 |
558 } // namespace cc | 569 } // namespace cc |
OLD | NEW |