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 #include <set> | 10 #include <set> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 last_impl_frame_time_in_seconds_(0.0), | 84 last_impl_frame_time_in_seconds_(0.0), |
85 has_visible_rect_tiles_(false), | 85 has_visible_rect_tiles_(false), |
86 has_skewport_rect_tiles_(false), | 86 has_skewport_rect_tiles_(false), |
87 has_soon_border_rect_tiles_(false), | 87 has_soon_border_rect_tiles_(false), |
88 has_eventually_rect_tiles_(false), | 88 has_eventually_rect_tiles_(false), |
89 eviction_tiles_cache_valid_(false), | 89 eviction_tiles_cache_valid_(false), |
90 eviction_cache_tree_priority_(SAME_PRIORITY_FOR_BOTH_TREES) { | 90 eviction_cache_tree_priority_(SAME_PRIORITY_FOR_BOTH_TREES) { |
91 gfx::Size content_bounds = | 91 gfx::Size content_bounds = |
92 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)); | 92 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)); |
93 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); | 93 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); |
| 94 if (tile_size.IsEmpty()) { |
| 95 layer_bounds_ = gfx::Size(); |
| 96 content_bounds = gfx::Size(); |
| 97 } |
94 | 98 |
95 DCHECK(!gfx::ToFlooredSize( | 99 DCHECK(!gfx::ToFlooredSize( |
96 gfx::ScaleSize(layer_bounds, contents_scale)).IsEmpty()) << | 100 gfx::ScaleSize(layer_bounds, contents_scale)).IsEmpty()) << |
97 "Tiling created with scale too small as contents become empty." << | 101 "Tiling created with scale too small as contents become empty." << |
98 " Layer bounds: " << layer_bounds.ToString() << | 102 " Layer bounds: " << layer_bounds.ToString() << |
99 " Contents scale: " << contents_scale; | 103 " Contents scale: " << contents_scale; |
100 | 104 |
101 tiling_data_.SetTilingSize(content_bounds); | 105 tiling_data_.SetTilingSize(content_bounds); |
102 tiling_data_.SetMaxTextureSize(tile_size); | 106 tiling_data_.SetMaxTextureSize(tile_size); |
103 } | 107 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 165 } |
162 | 166 |
163 VerifyLiveTilesRect(); | 167 VerifyLiveTilesRect(); |
164 } | 168 } |
165 | 169 |
166 void PictureLayerTiling::UpdateTilesToCurrentPile( | 170 void PictureLayerTiling::UpdateTilesToCurrentPile( |
167 const Region& layer_invalidation, | 171 const Region& layer_invalidation, |
168 const gfx::Size& new_layer_bounds) { | 172 const gfx::Size& new_layer_bounds) { |
169 DCHECK(!new_layer_bounds.IsEmpty()); | 173 DCHECK(!new_layer_bounds.IsEmpty()); |
170 | 174 |
171 gfx::Size old_layer_bounds = layer_bounds_; | |
172 layer_bounds_ = new_layer_bounds; | |
173 | |
174 gfx::Size content_bounds = | |
175 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds_, contents_scale_)); | |
176 gfx::Size tile_size = tiling_data_.max_texture_size(); | 175 gfx::Size tile_size = tiling_data_.max_texture_size(); |
177 | 176 |
178 if (layer_bounds_ != old_layer_bounds) { | 177 if (new_layer_bounds != layer_bounds_) { |
| 178 gfx::Size content_bounds = |
| 179 gfx::ToCeiledSize(gfx::ScaleSize(new_layer_bounds, contents_scale_)); |
| 180 |
| 181 tile_size = client_->CalculateTileSize(content_bounds); |
| 182 if (tile_size.IsEmpty()) { |
| 183 layer_bounds_ = gfx::Size(); |
| 184 content_bounds = gfx::Size(); |
| 185 } else { |
| 186 layer_bounds_ = new_layer_bounds; |
| 187 } |
| 188 |
179 // The SetLiveTilesRect() method would drop tiles outside the new bounds, | 189 // The SetLiveTilesRect() method would drop tiles outside the new bounds, |
180 // but may do so incorrectly if resizing the tiling causes the number of | 190 // but may do so incorrectly if resizing the tiling causes the number of |
181 // tiles in the tiling_data_ to change. | 191 // tiles in the tiling_data_ to change. |
182 gfx::Rect content_rect(content_bounds); | 192 gfx::Rect content_rect(content_bounds); |
183 int before_left = tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.x()); | 193 int before_left = tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.x()); |
184 int before_top = tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.y()); | 194 int before_top = tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.y()); |
185 int before_right = | 195 int before_right = |
186 tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.right() - 1); | 196 tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.right() - 1); |
187 int before_bottom = | 197 int before_bottom = |
188 tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.bottom() - 1); | 198 tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.bottom() - 1); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 if (after_right > before_right) { | 232 if (after_right > before_right) { |
223 DCHECK_EQ(after_right, before_right + 1); | 233 DCHECK_EQ(after_right, before_right + 1); |
224 for (int j = before_top; j <= after_bottom; ++j) | 234 for (int j = before_top; j <= after_bottom; ++j) |
225 CreateTile(after_right, j, twin_tiling); | 235 CreateTile(after_right, j, twin_tiling); |
226 } | 236 } |
227 if (after_bottom > before_bottom) { | 237 if (after_bottom > before_bottom) { |
228 DCHECK_EQ(after_bottom, before_bottom + 1); | 238 DCHECK_EQ(after_bottom, before_bottom + 1); |
229 for (int i = before_left; i <= before_right; ++i) | 239 for (int i = before_left; i <= before_right; ++i) |
230 CreateTile(i, after_bottom, twin_tiling); | 240 CreateTile(i, after_bottom, twin_tiling); |
231 } | 241 } |
232 | |
233 tile_size = client_->CalculateTileSize(content_bounds); | |
234 } | 242 } |
235 | 243 |
236 if (tile_size != tiling_data_.max_texture_size()) { | 244 if (tile_size != tiling_data_.max_texture_size()) { |
237 tiling_data_.SetMaxTextureSize(tile_size); | 245 tiling_data_.SetMaxTextureSize(tile_size); |
238 // When the tile size changes, the TilingData positions no longer work | 246 // When the tile size changes, the TilingData positions no longer work |
239 // as valid keys to the TileMap, so just drop all tiles. | 247 // as valid keys to the TileMap, so just drop all tiles. |
240 Reset(); | 248 Reset(); |
241 } else { | 249 } else { |
242 Invalidate(layer_invalidation); | 250 Invalidate(layer_invalidation); |
243 } | 251 } |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 DCHECK(*this); | 1198 DCHECK(*this); |
1191 do { | 1199 do { |
1192 ++current_eviction_tiles_index_; | 1200 ++current_eviction_tiles_index_; |
1193 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && | 1201 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && |
1194 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); | 1202 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); |
1195 | 1203 |
1196 return *this; | 1204 return *this; |
1197 } | 1205 } |
1198 | 1206 |
1199 } // namespace cc | 1207 } // namespace cc |
OLD | NEW |