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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <set> | 10 #include <set> |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 // If the twin (pending) tiling set is empty, it was not updated for the | 74 // If the twin (pending) tiling set is empty, it was not updated for the |
75 // current frame. So we drop tilings from our set as well, instead of | 75 // current frame. So we drop tilings from our set as well, instead of |
76 // leaving behind unshared tilings that are all non-ideal. | 76 // leaving behind unshared tilings that are all non-ideal. |
77 RemoveAllTilings(); | 77 RemoveAllTilings(); |
78 return; | 78 return; |
79 } | 79 } |
80 | 80 |
81 bool tiling_sort_required = false; | 81 bool tiling_sort_required = false; |
82 for (const auto& pending_twin_tiling : pending_twin_set->tilings_) { | 82 for (const auto& pending_twin_tiling : pending_twin_set->tilings_) { |
83 float contents_scale = pending_twin_tiling->contents_scale(); | 83 float contents_scale = pending_twin_tiling->contents_scale(); |
84 gfx::Vector2dF contents_translation = | |
85 pending_twin_tiling->contents_translation(); | |
84 PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale); | 86 PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale); |
enne (OOO)
2016/08/22 22:57:39
What if there are multiple tilings with the same s
trchen
2016/08/29 10:14:48
Currently the easiest thing to do is to replace. I
| |
85 if (!this_tiling) { | 87 if (!this_tiling) { |
86 std::unique_ptr<PictureLayerTiling> new_tiling(new PictureLayerTiling( | 88 std::unique_ptr<PictureLayerTiling> new_tiling( |
87 tree_, contents_scale, raster_source_, client_)); | 89 new PictureLayerTiling(tree_, contents_scale, contents_translation, |
90 raster_source_, client_)); | |
88 tilings_.push_back(std::move(new_tiling)); | 91 tilings_.push_back(std::move(new_tiling)); |
89 this_tiling = tilings_.back().get(); | 92 this_tiling = tilings_.back().get(); |
90 tiling_sort_required = true; | 93 tiling_sort_required = true; |
91 state_since_last_tile_priority_update_.added_tilings = true; | 94 state_since_last_tile_priority_update_.added_tilings = true; |
92 } | 95 } |
93 this_tiling->TakeTilesAndPropertiesFrom(pending_twin_tiling.get(), | 96 this_tiling->TakeTilesAndPropertiesFrom(pending_twin_tiling.get(), |
94 layer_invalidation); | 97 layer_invalidation); |
95 } | 98 } |
96 | 99 |
97 if (tiling_sort_required) { | 100 if (tiling_sort_required) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 tilings_.erase(to_remove, tilings_.end()); | 258 tilings_.erase(to_remove, tilings_.end()); |
256 } | 259 } |
257 | 260 |
258 void PictureLayerTilingSet::MarkAllTilingsNonIdeal() { | 261 void PictureLayerTilingSet::MarkAllTilingsNonIdeal() { |
259 for (const auto& tiling : tilings_) | 262 for (const auto& tiling : tilings_) |
260 tiling->set_resolution(NON_IDEAL_RESOLUTION); | 263 tiling->set_resolution(NON_IDEAL_RESOLUTION); |
261 } | 264 } |
262 | 265 |
263 PictureLayerTiling* PictureLayerTilingSet::AddTiling( | 266 PictureLayerTiling* PictureLayerTilingSet::AddTiling( |
264 float contents_scale, | 267 float contents_scale, |
268 const gfx::Vector2dF& contents_translation, | |
265 scoped_refptr<RasterSource> raster_source) { | 269 scoped_refptr<RasterSource> raster_source) { |
266 if (!raster_source_) | 270 if (!raster_source_) |
267 raster_source_ = raster_source; | 271 raster_source_ = raster_source; |
268 | 272 |
269 for (size_t i = 0; i < tilings_.size(); ++i) { | 273 for (size_t i = 0; i < tilings_.size(); ++i) { |
270 DCHECK_NE(tilings_[i]->contents_scale(), contents_scale); | 274 DCHECK_NE(tilings_[i]->contents_scale(), contents_scale); |
271 DCHECK_EQ(tilings_[i]->raster_source(), raster_source.get()); | 275 DCHECK_EQ(tilings_[i]->raster_source(), raster_source.get()); |
272 } | 276 } |
273 | 277 |
274 tilings_.push_back(base::WrapUnique( | 278 tilings_.push_back(base::WrapUnique(new PictureLayerTiling( |
275 new PictureLayerTiling(tree_, contents_scale, raster_source, client_))); | 279 tree_, contents_scale, contents_translation, raster_source, client_))); |
276 PictureLayerTiling* appended = tilings_.back().get(); | 280 PictureLayerTiling* appended = tilings_.back().get(); |
277 state_since_last_tile_priority_update_.added_tilings = true; | 281 state_since_last_tile_priority_update_.added_tilings = true; |
278 | 282 |
279 std::sort(tilings_.begin(), tilings_.end(), LargestToSmallestScaleFunctor()); | 283 std::sort(tilings_.begin(), tilings_.end(), LargestToSmallestScaleFunctor()); |
280 return appended; | 284 return appended; |
281 } | 285 } |
282 | 286 |
283 int PictureLayerTilingSet::NumHighResTilings() const { | 287 int PictureLayerTilingSet::NumHighResTilings() const { |
284 return std::count_if(tilings_.begin(), tilings_.end(), | 288 return std::count_if(tilings_.begin(), tilings_.end(), |
285 [](const std::unique_ptr<PictureLayerTiling>& tiling) { | 289 [](const std::unique_ptr<PictureLayerTiling>& tiling) { |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
748 case LOWER_THAN_LOW_RES: | 752 case LOWER_THAN_LOW_RES: |
749 range = TilingRange(low_res_range.end, tilings_size); | 753 range = TilingRange(low_res_range.end, tilings_size); |
750 break; | 754 break; |
751 } | 755 } |
752 | 756 |
753 DCHECK_LE(range.start, range.end); | 757 DCHECK_LE(range.start, range.end); |
754 return range; | 758 return range; |
755 } | 759 } |
756 | 760 |
757 } // namespace cc | 761 } // namespace cc |
OLD | NEW |