| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // Add any missing tilings from |other| that meet the minimum. | 64 // Add any missing tilings from |other| that meet the minimum. |
| 65 for (size_t i = 0; i < other.tilings_.size(); ++i) { | 65 for (size_t i = 0; i < other.tilings_.size(); ++i) { |
| 66 float contents_scale = other.tilings_[i]->contents_scale(); | 66 float contents_scale = other.tilings_[i]->contents_scale(); |
| 67 if (contents_scale < minimum_contents_scale) | 67 if (contents_scale < minimum_contents_scale) |
| 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 this_tiling->UpdateTilesToCurrentPile(layer_invalidation, | 72 this_tiling->UpdateTilesToCurrentPile(layer_invalidation, |
| 73 new_layer_bounds); | 73 new_layer_bounds); |
| 74 this_tiling->CreateMissingTilesInLiveTilesRect(); | |
| 75 if (this_tiling->resolution() == HIGH_RESOLUTION) | 74 if (this_tiling->resolution() == HIGH_RESOLUTION) |
| 76 have_high_res_tiling = true; | 75 have_high_res_tiling = true; |
| 77 | 76 |
| 78 DCHECK(this_tiling->tile_size() == | 77 DCHECK(this_tiling->tile_size() == |
| 79 client_->CalculateTileSize(this_tiling->TilingRect().size())); | 78 client_->CalculateTileSize(this_tiling->TilingRect().size())); |
| 80 continue; | 79 continue; |
| 81 } | 80 } |
| 82 scoped_ptr<PictureLayerTiling> new_tiling = PictureLayerTiling::Create( | 81 scoped_ptr<PictureLayerTiling> new_tiling = PictureLayerTiling::Create( |
| 83 contents_scale, | 82 contents_scale, |
| 84 new_layer_bounds, | 83 new_layer_bounds, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 return gfx::RectF(); | 189 return gfx::RectF(); |
| 191 return tiling_iter_.texture_rect(); | 190 return tiling_iter_.texture_rect(); |
| 192 } | 191 } |
| 193 | 192 |
| 194 gfx::Size PictureLayerTilingSet::CoverageIterator::texture_size() const { | 193 gfx::Size PictureLayerTilingSet::CoverageIterator::texture_size() const { |
| 195 if (!tiling_iter_) | 194 if (!tiling_iter_) |
| 196 return gfx::Size(); | 195 return gfx::Size(); |
| 197 return tiling_iter_.texture_size(); | 196 return tiling_iter_.texture_size(); |
| 198 } | 197 } |
| 199 | 198 |
| 199 TileResolution PictureLayerTilingSet::CoverageIterator::resolution() { |
| 200 PictureLayerTiling* tiling = CurrentTiling(); |
| 201 if (tiling) |
| 202 return tiling->resolution(); |
| 203 NOTREACHED(); |
| 204 return NON_IDEAL_RESOLUTION; |
| 205 } |
| 206 |
| 200 Tile* PictureLayerTilingSet::CoverageIterator::operator->() const { | 207 Tile* PictureLayerTilingSet::CoverageIterator::operator->() const { |
| 201 if (!tiling_iter_) | 208 if (!tiling_iter_) |
| 202 return NULL; | 209 return NULL; |
| 203 return *tiling_iter_; | 210 return *tiling_iter_; |
| 204 } | 211 } |
| 205 | 212 |
| 206 Tile* PictureLayerTilingSet::CoverageIterator::operator*() const { | 213 Tile* PictureLayerTilingSet::CoverageIterator::operator*() const { |
| 207 if (!tiling_iter_) | 214 if (!tiling_iter_) |
| 208 return NULL; | 215 return NULL; |
| 209 return *tiling_iter_; | 216 return *tiling_iter_; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 PictureLayerTilingSet::CoverageIterator::operator bool() const { | 303 PictureLayerTilingSet::CoverageIterator::operator bool() const { |
| 297 return current_tiling_ < static_cast<int>(set_->tilings_.size()) || | 304 return current_tiling_ < static_cast<int>(set_->tilings_.size()) || |
| 298 region_iter_.has_rect(); | 305 region_iter_.has_rect(); |
| 299 } | 306 } |
| 300 | 307 |
| 301 void PictureLayerTilingSet::DidBecomeActive() { | 308 void PictureLayerTilingSet::DidBecomeActive() { |
| 302 for (size_t i = 0; i < tilings_.size(); ++i) | 309 for (size_t i = 0; i < tilings_.size(); ++i) |
| 303 tilings_[i]->DidBecomeActive(); | 310 tilings_[i]->DidBecomeActive(); |
| 304 } | 311 } |
| 305 | 312 |
| 306 void PictureLayerTilingSet::DidBecomeRecycled() { | |
| 307 for (size_t i = 0; i < tilings_.size(); ++i) | |
| 308 tilings_[i]->DidBecomeRecycled(); | |
| 309 } | |
| 310 | |
| 311 scoped_ptr<base::Value> PictureLayerTilingSet::AsValue() const { | 313 scoped_ptr<base::Value> PictureLayerTilingSet::AsValue() const { |
| 312 scoped_ptr<base::ListValue> state(new base::ListValue()); | 314 scoped_ptr<base::ListValue> state(new base::ListValue()); |
| 313 for (size_t i = 0; i < tilings_.size(); ++i) | 315 for (size_t i = 0; i < tilings_.size(); ++i) |
| 314 state->Append(tilings_[i]->AsValue().release()); | 316 state->Append(tilings_[i]->AsValue().release()); |
| 315 return state.PassAs<base::Value>(); | 317 return state.PassAs<base::Value>(); |
| 316 } | 318 } |
| 317 | 319 |
| 318 size_t PictureLayerTilingSet::GPUMemoryUsageInBytes() const { | 320 size_t PictureLayerTilingSet::GPUMemoryUsageInBytes() const { |
| 319 size_t amount = 0; | 321 size_t amount = 0; |
| 320 for (size_t i = 0; i < tilings_.size(); ++i) | 322 for (size_t i = 0; i < tilings_.size(); ++i) |
| 321 amount += tilings_[i]->GPUMemoryUsageInBytes(); | 323 amount += tilings_[i]->GPUMemoryUsageInBytes(); |
| 322 return amount; | 324 return amount; |
| 323 } | 325 } |
| 324 | 326 |
| 325 } // namespace cc | 327 } // namespace cc |
| OLD | NEW |