| 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.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 DoInvalidate(layer_region, false /* recreate_tiles */); | 182 DoInvalidate(layer_region, false /* recreate_tiles */); |
| 183 } | 183 } |
| 184 | 184 |
| 185 void PictureLayerTiling::Invalidate(const Region& layer_region) { | 185 void PictureLayerTiling::Invalidate(const Region& layer_region) { |
| 186 DoInvalidate(layer_region, true /* recreate_tiles */); | 186 DoInvalidate(layer_region, true /* recreate_tiles */); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void PictureLayerTiling::DoInvalidate(const Region& layer_region, | 189 void PictureLayerTiling::DoInvalidate(const Region& layer_region, |
| 190 bool recreate_tiles) { | 190 bool recreate_tiles) { |
| 191 std::vector<TileMapKey> new_tile_keys; | 191 std::vector<TileMapKey> new_tile_keys; |
| 192 gfx::Rect expanded_live_tiles_rect( |
| 193 tiling_data_.ExpandRectToTileBoundsWithBorders(live_tiles_rect_)); |
| 192 for (Region::Iterator iter(layer_region); iter.has_rect(); iter.next()) { | 194 for (Region::Iterator iter(layer_region); iter.has_rect(); iter.next()) { |
| 193 gfx::Rect layer_rect = iter.rect(); | 195 gfx::Rect layer_rect = iter.rect(); |
| 194 gfx::Rect content_rect = | 196 gfx::Rect content_rect = |
| 195 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_); | 197 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_); |
| 196 content_rect.Intersect(live_tiles_rect_); | 198 // Avoid needless work by not bothering to invalidate where there aren't |
| 199 // tiles. |
| 200 content_rect.Intersect(expanded_live_tiles_rect); |
| 197 if (content_rect.IsEmpty()) | 201 if (content_rect.IsEmpty()) |
| 198 continue; | 202 continue; |
| 199 bool include_borders = true; | 203 bool include_borders = true; |
| 200 for (TilingData::Iterator iter( | 204 for (TilingData::Iterator iter( |
| 201 &tiling_data_, content_rect, include_borders); | 205 &tiling_data_, content_rect, include_borders); |
| 202 iter; | 206 iter; |
| 203 ++iter) { | 207 ++iter) { |
| 204 TileMapKey key(iter.index()); | 208 TileMapKey key(iter.index()); |
| 205 TileMap::iterator find = tiles_.find(key); | 209 TileMap::iterator find = tiles_.find(key); |
| 206 if (find == tiles_.end()) | 210 if (find == tiles_.end()) |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); | 927 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); |
| 924 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); | 928 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); |
| 925 is_valid_ = true; | 929 is_valid_ = true; |
| 926 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && | 930 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && |
| 927 !(*tile_iterator_)->HasResources()) { | 931 !(*tile_iterator_)->HasResources()) { |
| 928 ++(*this); | 932 ++(*this); |
| 929 } | 933 } |
| 930 } | 934 } |
| 931 | 935 |
| 932 } // namespace cc | 936 } // namespace cc |
| OLD | NEW |