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 | 8 |
9 namespace cc { | 9 namespace cc { |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 continue; | 68 continue; |
69 if (PictureLayerTiling* this_tiling = TilingAtScale(contents_scale)) { | 69 if (PictureLayerTiling* this_tiling = TilingAtScale(contents_scale)) { |
70 this_tiling->set_resolution(other.tilings_[i]->resolution()); | 70 this_tiling->set_resolution(other.tilings_[i]->resolution()); |
71 | 71 |
72 // These two calls must come before updating the pile, because they may | 72 // These two calls must come before updating the pile, because they may |
73 // destroy tiles that the new pile cannot raster. | 73 // destroy tiles that the new pile cannot raster. |
74 this_tiling->SetLayerBounds(new_layer_bounds); | 74 this_tiling->SetLayerBounds(new_layer_bounds); |
75 this_tiling->Invalidate(layer_invalidation); | 75 this_tiling->Invalidate(layer_invalidation); |
76 | 76 |
77 this_tiling->UpdateTilesToCurrentPile(); | 77 this_tiling->UpdateTilesToCurrentPile(); |
78 this_tiling->CreateMissingTilesInLiveTilesRect(); | |
79 if (this_tiling->resolution() == HIGH_RESOLUTION) | 78 if (this_tiling->resolution() == HIGH_RESOLUTION) |
80 have_high_res_tiling = true; | 79 have_high_res_tiling = true; |
81 | 80 |
82 DCHECK(this_tiling->tile_size() == | 81 DCHECK(this_tiling->tile_size() == |
83 client_->CalculateTileSize(this_tiling->TilingRect().size())); | 82 client_->CalculateTileSize(this_tiling->TilingRect().size())); |
84 continue; | 83 continue; |
85 } | 84 } |
86 scoped_ptr<PictureLayerTiling> new_tiling = PictureLayerTiling::Create( | 85 scoped_ptr<PictureLayerTiling> new_tiling = PictureLayerTiling::Create( |
87 contents_scale, | 86 contents_scale, |
88 new_layer_bounds, | 87 new_layer_bounds, |
89 client_); | 88 client_); |
90 new_tiling->set_resolution(other.tilings_[i]->resolution()); | 89 new_tiling->set_resolution(other.tilings_[i]->resolution()); |
91 if (new_tiling->resolution() == HIGH_RESOLUTION) | 90 if (new_tiling->resolution() == HIGH_RESOLUTION) |
92 have_high_res_tiling = true; | 91 have_high_res_tiling = true; |
93 tilings_.push_back(new_tiling.Pass()); | 92 tilings_.push_back(new_tiling.Pass()); |
94 } | 93 } |
95 tilings_.sort(LargestToSmallestScaleFunctor()); | 94 tilings_.sort(LargestToSmallestScaleFunctor()); |
96 | 95 |
97 layer_bounds_ = new_layer_bounds; | 96 layer_bounds_ = new_layer_bounds; |
98 return have_high_res_tiling; | 97 return have_high_res_tiling; |
99 } | 98 } |
100 | 99 |
101 void PictureLayerTilingSet::RemoveTilesInRegion(const Region& region) { | 100 void PictureLayerTilingSet::RemoveTilesInRegion(const Region& region) { |
102 for (size_t i = 0; i < tilings_.size(); ++i) | 101 for (size_t i = 0; i < tilings_.size(); ++i) |
103 tilings_[i]->RemoveTilesInRegion(region); | 102 tilings_[i]->Invalidate(region); |
104 } | 103 } |
105 | 104 |
106 PictureLayerTiling* PictureLayerTilingSet::AddTiling(float contents_scale) { | 105 PictureLayerTiling* PictureLayerTilingSet::AddTiling(float contents_scale) { |
107 for (size_t i = 0; i < tilings_.size(); ++i) | 106 for (size_t i = 0; i < tilings_.size(); ++i) |
108 DCHECK_NE(tilings_[i]->contents_scale(), contents_scale); | 107 DCHECK_NE(tilings_[i]->contents_scale(), contents_scale); |
109 | 108 |
110 tilings_.push_back(PictureLayerTiling::Create(contents_scale, | 109 tilings_.push_back(PictureLayerTiling::Create(contents_scale, |
111 layer_bounds_, | 110 layer_bounds_, |
112 client_)); | 111 client_)); |
113 PictureLayerTiling* appended = tilings_.back(); | 112 PictureLayerTiling* appended = tilings_.back(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 return gfx::RectF(); | 198 return gfx::RectF(); |
200 return tiling_iter_.texture_rect(); | 199 return tiling_iter_.texture_rect(); |
201 } | 200 } |
202 | 201 |
203 gfx::Size PictureLayerTilingSet::CoverageIterator::texture_size() const { | 202 gfx::Size PictureLayerTilingSet::CoverageIterator::texture_size() const { |
204 if (!tiling_iter_) | 203 if (!tiling_iter_) |
205 return gfx::Size(); | 204 return gfx::Size(); |
206 return tiling_iter_.texture_size(); | 205 return tiling_iter_.texture_size(); |
207 } | 206 } |
208 | 207 |
| 208 TileResolution PictureLayerTilingSet::CoverageIterator::resolution() { |
| 209 PictureLayerTiling* tiling = CurrentTiling(); |
| 210 if (tiling) |
| 211 return tiling->resolution(); |
| 212 NOTREACHED(); |
| 213 return NON_IDEAL_RESOLUTION; |
| 214 } |
| 215 |
209 Tile* PictureLayerTilingSet::CoverageIterator::operator->() const { | 216 Tile* PictureLayerTilingSet::CoverageIterator::operator->() const { |
210 if (!tiling_iter_) | 217 if (!tiling_iter_) |
211 return NULL; | 218 return NULL; |
212 return *tiling_iter_; | 219 return *tiling_iter_; |
213 } | 220 } |
214 | 221 |
215 Tile* PictureLayerTilingSet::CoverageIterator::operator*() const { | 222 Tile* PictureLayerTilingSet::CoverageIterator::operator*() const { |
216 if (!tiling_iter_) | 223 if (!tiling_iter_) |
217 return NULL; | 224 return NULL; |
218 return *tiling_iter_; | 225 return *tiling_iter_; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 PictureLayerTilingSet::CoverageIterator::operator bool() const { | 312 PictureLayerTilingSet::CoverageIterator::operator bool() const { |
306 return current_tiling_ < static_cast<int>(set_->tilings_.size()) || | 313 return current_tiling_ < static_cast<int>(set_->tilings_.size()) || |
307 region_iter_.has_rect(); | 314 region_iter_.has_rect(); |
308 } | 315 } |
309 | 316 |
310 void PictureLayerTilingSet::DidBecomeActive() { | 317 void PictureLayerTilingSet::DidBecomeActive() { |
311 for (size_t i = 0; i < tilings_.size(); ++i) | 318 for (size_t i = 0; i < tilings_.size(); ++i) |
312 tilings_[i]->DidBecomeActive(); | 319 tilings_[i]->DidBecomeActive(); |
313 } | 320 } |
314 | 321 |
315 void PictureLayerTilingSet::DidBecomeRecycled() { | |
316 for (size_t i = 0; i < tilings_.size(); ++i) | |
317 tilings_[i]->DidBecomeRecycled(); | |
318 } | |
319 | |
320 scoped_ptr<base::Value> PictureLayerTilingSet::AsValue() const { | 322 scoped_ptr<base::Value> PictureLayerTilingSet::AsValue() const { |
321 scoped_ptr<base::ListValue> state(new base::ListValue()); | 323 scoped_ptr<base::ListValue> state(new base::ListValue()); |
322 for (size_t i = 0; i < tilings_.size(); ++i) | 324 for (size_t i = 0; i < tilings_.size(); ++i) |
323 state->Append(tilings_[i]->AsValue().release()); | 325 state->Append(tilings_[i]->AsValue().release()); |
324 return state.PassAs<base::Value>(); | 326 return state.PassAs<base::Value>(); |
325 } | 327 } |
326 | 328 |
327 size_t PictureLayerTilingSet::GPUMemoryUsageInBytes() const { | 329 size_t PictureLayerTilingSet::GPUMemoryUsageInBytes() const { |
328 size_t amount = 0; | 330 size_t amount = 0; |
329 for (size_t i = 0; i < tilings_.size(); ++i) | 331 for (size_t i = 0; i < tilings_.size(); ++i) |
330 amount += tilings_[i]->GPUMemoryUsageInBytes(); | 332 amount += tilings_[i]->GPUMemoryUsageInBytes(); |
331 return amount; | 333 return amount; |
332 } | 334 } |
333 | 335 |
334 } // namespace cc | 336 } // namespace cc |
OLD | NEW |