| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 bool have_high_res_tiling = false; | 62 bool have_high_res_tiling = false; |
| 63 | 63 |
| 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 // These two calls must come before updating the pile, because they may | 72 this_tiling->UpdateTilesToCurrentPile(layer_invalidation, |
| 73 // destroy tiles that the new pile cannot raster. | 73 new_layer_bounds); |
| 74 this_tiling->SetLayerBounds(new_layer_bounds); | |
| 75 this_tiling->Invalidate(layer_invalidation); | |
| 76 | |
| 77 this_tiling->UpdateTilesToCurrentPile(); | |
| 78 this_tiling->CreateMissingTilesInLiveTilesRect(); | 74 this_tiling->CreateMissingTilesInLiveTilesRect(); |
| 79 if (this_tiling->resolution() == HIGH_RESOLUTION) | 75 if (this_tiling->resolution() == HIGH_RESOLUTION) |
| 80 have_high_res_tiling = true; | 76 have_high_res_tiling = true; |
| 81 | 77 |
| 82 DCHECK(this_tiling->tile_size() == | 78 DCHECK(this_tiling->tile_size() == |
| 83 client_->CalculateTileSize(this_tiling->TilingRect().size())); | 79 client_->CalculateTileSize(this_tiling->TilingRect().size())); |
| 84 continue; | 80 continue; |
| 85 } | 81 } |
| 86 scoped_ptr<PictureLayerTiling> new_tiling = PictureLayerTiling::Create( | 82 scoped_ptr<PictureLayerTiling> new_tiling = PictureLayerTiling::Create( |
| 87 contents_scale, | 83 contents_scale, |
| 88 new_layer_bounds, | 84 new_layer_bounds, |
| 89 client_); | 85 client_); |
| 90 new_tiling->set_resolution(other.tilings_[i]->resolution()); | 86 new_tiling->set_resolution(other.tilings_[i]->resolution()); |
| 91 if (new_tiling->resolution() == HIGH_RESOLUTION) | 87 if (new_tiling->resolution() == HIGH_RESOLUTION) |
| 92 have_high_res_tiling = true; | 88 have_high_res_tiling = true; |
| 93 tilings_.push_back(new_tiling.Pass()); | 89 tilings_.push_back(new_tiling.Pass()); |
| 94 } | 90 } |
| 95 tilings_.sort(LargestToSmallestScaleFunctor()); | 91 tilings_.sort(LargestToSmallestScaleFunctor()); |
| 96 | 92 |
| 97 layer_bounds_ = new_layer_bounds; | 93 layer_bounds_ = new_layer_bounds; |
| 98 return have_high_res_tiling; | 94 return have_high_res_tiling; |
| 99 } | 95 } |
| 100 | 96 |
| 101 void PictureLayerTilingSet::RemoveTilesInRegion(const Region& region) { | |
| 102 for (size_t i = 0; i < tilings_.size(); ++i) | |
| 103 tilings_[i]->RemoveTilesInRegion(region); | |
| 104 } | |
| 105 | |
| 106 PictureLayerTiling* PictureLayerTilingSet::AddTiling(float contents_scale) { | 97 PictureLayerTiling* PictureLayerTilingSet::AddTiling(float contents_scale) { |
| 107 for (size_t i = 0; i < tilings_.size(); ++i) | 98 for (size_t i = 0; i < tilings_.size(); ++i) |
| 108 DCHECK_NE(tilings_[i]->contents_scale(), contents_scale); | 99 DCHECK_NE(tilings_[i]->contents_scale(), contents_scale); |
| 109 | 100 |
| 110 tilings_.push_back(PictureLayerTiling::Create(contents_scale, | 101 tilings_.push_back(PictureLayerTiling::Create(contents_scale, |
| 111 layer_bounds_, | 102 layer_bounds_, |
| 112 client_)); | 103 client_)); |
| 113 PictureLayerTiling* appended = tilings_.back(); | 104 PictureLayerTiling* appended = tilings_.back(); |
| 114 | 105 |
| 115 tilings_.sort(LargestToSmallestScaleFunctor()); | 106 tilings_.sort(LargestToSmallestScaleFunctor()); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 } | 316 } |
| 326 | 317 |
| 327 size_t PictureLayerTilingSet::GPUMemoryUsageInBytes() const { | 318 size_t PictureLayerTilingSet::GPUMemoryUsageInBytes() const { |
| 328 size_t amount = 0; | 319 size_t amount = 0; |
| 329 for (size_t i = 0; i < tilings_.size(); ++i) | 320 for (size_t i = 0; i < tilings_.size(); ++i) |
| 330 amount += tilings_[i]->GPUMemoryUsageInBytes(); | 321 amount += tilings_[i]->GPUMemoryUsageInBytes(); |
| 331 return amount; | 322 return amount; |
| 332 } | 323 } |
| 333 | 324 |
| 334 } // namespace cc | 325 } // namespace cc |
| OLD | NEW |