Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: cc/resources/picture_layer_tiling.cc

Issue 640063010: cc: Don't swap PictureLayerTilingSet on activate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: noswap: RemoveLOGERRORs Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 PictureLayerTiling::PictureLayerTiling(float contents_scale, 68 PictureLayerTiling::PictureLayerTiling(float contents_scale,
69 const gfx::Size& layer_bounds, 69 const gfx::Size& layer_bounds,
70 PictureLayerTilingClient* client) 70 PictureLayerTilingClient* client)
71 : contents_scale_(contents_scale), 71 : contents_scale_(contents_scale),
72 layer_bounds_(layer_bounds), 72 layer_bounds_(layer_bounds),
73 resolution_(NON_IDEAL_RESOLUTION), 73 resolution_(NON_IDEAL_RESOLUTION),
74 client_(client), 74 client_(client),
75 tiling_data_(gfx::Size(), gfx::Size(), kBorderTexels), 75 tiling_data_(gfx::Size(), gfx::Size(), kBorderTexels),
76 last_impl_frame_time_in_seconds_(0.0), 76 last_impl_frame_time_in_seconds_(0.0),
77 content_to_screen_scale_(0.f),
78 can_require_tiles_for_activation_(false), 77 can_require_tiles_for_activation_(false),
78 current_content_to_screen_scale_(0.f),
79 has_visible_rect_tiles_(false), 79 has_visible_rect_tiles_(false),
80 has_skewport_rect_tiles_(false), 80 has_skewport_rect_tiles_(false),
81 has_soon_border_rect_tiles_(false), 81 has_soon_border_rect_tiles_(false),
82 has_eventually_rect_tiles_(false), 82 has_eventually_rect_tiles_(false),
83 eviction_tiles_cache_valid_(false), 83 eviction_tiles_cache_valid_(false),
84 eviction_cache_tree_priority_(SAME_PRIORITY_FOR_BOTH_TREES) { 84 eviction_cache_tree_priority_(SAME_PRIORITY_FOR_BOTH_TREES) {
85 gfx::Size content_bounds = 85 gfx::Size content_bounds =
86 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)); 86 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale));
87 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); 87 gfx::Size tile_size = client_->CalculateTileSize(content_bounds);
88 if (tile_size.IsEmpty()) { 88 if (tile_size.IsEmpty()) {
89 layer_bounds_ = gfx::Size(); 89 layer_bounds_ = gfx::Size();
90 content_bounds = gfx::Size(); 90 content_bounds = gfx::Size();
91 } 91 }
92 92
93 DCHECK(!gfx::ToFlooredSize( 93 DCHECK(!gfx::ToFlooredSize(
94 gfx::ScaleSize(layer_bounds, contents_scale)).IsEmpty()) << 94 gfx::ScaleSize(layer_bounds, contents_scale)).IsEmpty()) <<
95 "Tiling created with scale too small as contents become empty." << 95 "Tiling created with scale too small as contents become empty." <<
96 " Layer bounds: " << layer_bounds.ToString() << 96 " Layer bounds: " << layer_bounds.ToString() <<
97 " Contents scale: " << contents_scale; 97 " Contents scale: " << contents_scale;
98 98
99 tiling_data_.SetTilingSize(content_bounds); 99 tiling_data_.SetTilingSize(content_bounds);
100 tiling_data_.SetMaxTextureSize(tile_size); 100 tiling_data_.SetMaxTextureSize(tile_size);
101 } 101 }
102 102
103 PictureLayerTiling::~PictureLayerTiling() { 103 PictureLayerTiling::~PictureLayerTiling() {
104 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) 104 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
105 it->second->set_shared(false); 105 it->second->set_shared(false);
106 } 106 }
107 107
108 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) {
109 client_ = client;
110 }
111
112 Tile* PictureLayerTiling::CreateTile(int i, 108 Tile* PictureLayerTiling::CreateTile(int i,
113 int j, 109 int j,
114 const PictureLayerTiling* twin_tiling) { 110 const PictureLayerTiling* twin_tiling) {
115 TileMapKey key(i, j); 111 TileMapKey key(i, j);
116 DCHECK(tiles_.find(key) == tiles_.end()); 112 DCHECK(tiles_.find(key) == tiles_.end());
117 113
118 gfx::Rect paint_rect = tiling_data_.TileBoundsWithBorder(i, j); 114 gfx::Rect paint_rect = tiling_data_.TileBoundsWithBorder(i, j);
119 gfx::Rect tile_rect = paint_rect; 115 gfx::Rect tile_rect = paint_rect;
120 tile_rect.set_size(tiling_data_.max_texture_size()); 116 tile_rect.set_size(tiling_data_.max_texture_size());
121 117
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 TileMapKey key = iter.index(); 156 TileMapKey key = iter.index();
161 TileMap::iterator find = tiles_.find(key); 157 TileMap::iterator find = tiles_.find(key);
162 if (find != tiles_.end()) 158 if (find != tiles_.end())
163 continue; 159 continue;
164 CreateTile(key.first, key.second, twin_tiling); 160 CreateTile(key.first, key.second, twin_tiling);
165 } 161 }
166 162
167 VerifyLiveTilesRect(); 163 VerifyLiveTilesRect();
168 } 164 }
169 165
170 void PictureLayerTiling::UpdateTilesToCurrentRasterSource( 166 void PictureLayerTiling::CloneTilesAndPropertiesFrom(
171 RasterSource* raster_source, 167 const PictureLayerTiling& twin_tiling) {
172 const Region& layer_invalidation, 168 DCHECK_EQ(&twin_tiling, client_->GetPendingOrActiveTwinTiling(this));
173 const gfx::Size& new_layer_bounds) {
174 DCHECK(!new_layer_bounds.IsEmpty());
175 169
170 Resize(twin_tiling.layer_bounds_);
171 DCHECK_EQ(twin_tiling.contents_scale_, contents_scale_);
172 DCHECK_EQ(twin_tiling.layer_bounds().ToString(), layer_bounds().ToString());
173 DCHECK_EQ(twin_tiling.tile_size().ToString(), tile_size().ToString());
174
175 resolution_ = twin_tiling.resolution_;
176
177 SetLiveTilesRect(twin_tiling.live_tiles_rect());
178
179 // Recreate unshared tiles. The |recycled_twin| does not exist since there
180 // is a pending twin (which is |twin_tiling|).
181 PictureLayerTiling* recycled_twin = nullptr;
182 DCHECK_EQ(recycled_twin, client_->GetRecycledTwinTiling(this));
183 std::vector<TileMapKey> to_remove;
184 for (auto tile_map_pair : tiles_) {
vmpstr 2014/12/09 00:10:19 nit: const auto&
danakj 2014/12/09 18:20:23 Done.
185 TileMapKey key = tile_map_pair.first;
186 Tile* tile = tile_map_pair.second.get();
187 if (!tile->is_shared())
188 to_remove.push_back(key);
189 }
190 for (auto key : to_remove) {
vmpstr 2014/12/09 00:10:19 nit: const auto&
danakj 2014/12/09 18:20:23 Done.
191 RemoveTileAt(key.first, key.second, recycled_twin);
192 CreateTile(key.first, key.second, &twin_tiling);
193 }
194
195 DCHECK_EQ(twin_tiling.tiles_.size(), tiles_.size());
196 #if DCHECK_IS_ON
197 for (auto tile_map_pair : tiles_)
198 DCHECK(tile_map_pair.second->is_shared());
199 #endif
200
201 UpdateTilePriorityRects(twin_tiling.current_content_to_screen_scale_,
202 twin_tiling.current_visible_rect_,
203 twin_tiling.current_skewport_rect_,
204 twin_tiling.current_soon_border_rect_,
205 twin_tiling.current_eventually_rect_,
206 twin_tiling.current_occlusion_in_layer_space_);
207 }
208
209 void PictureLayerTiling::Resize(const gfx::Size& new_layer_bounds) {
210 gfx::Size layer_bounds = new_layer_bounds;
176 gfx::Size content_bounds = 211 gfx::Size content_bounds =
177 gfx::ToCeiledSize(gfx::ScaleSize(new_layer_bounds, contents_scale_)); 212 gfx::ToCeiledSize(gfx::ScaleSize(new_layer_bounds, contents_scale_));
178 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); 213 gfx::Size tile_size = client_->CalculateTileSize(content_bounds);
179 214
180 if (new_layer_bounds != layer_bounds_) { 215 if (tile_size.IsEmpty()) {
181 if (tile_size.IsEmpty()) { 216 layer_bounds = gfx::Size();
182 layer_bounds_ = gfx::Size(); 217 content_bounds = gfx::Size();
183 content_bounds = gfx::Size();
184 } else {
185 layer_bounds_ = new_layer_bounds;
186 }
187
188 // The SetLiveTilesRect() method would drop tiles outside the new bounds,
189 // but may do so incorrectly if resizing the tiling causes the number of
190 // tiles in the tiling_data_ to change.
191 gfx::Rect content_rect(content_bounds);
192 int before_left = tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.x());
193 int before_top = tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.y());
194 int before_right =
195 tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.right() - 1);
196 int before_bottom =
197 tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.bottom() - 1);
198
199 // The live_tiles_rect_ is clamped to stay within the tiling size as we
200 // change it.
201 live_tiles_rect_.Intersect(content_rect);
202 tiling_data_.SetTilingSize(content_bounds);
203
204 int after_right = -1;
205 int after_bottom = -1;
206 if (!live_tiles_rect_.IsEmpty()) {
207 after_right =
208 tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.right() - 1);
209 after_bottom =
210 tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.bottom() - 1);
211 }
212
213 // There is no recycled twin since this is run on the pending tiling.
214 PictureLayerTiling* recycled_twin = NULL;
215 DCHECK_EQ(recycled_twin, client_->GetRecycledTwinTiling(this));
216 DCHECK_EQ(PENDING_TREE, client_->GetTree());
217
218 // Drop tiles outside the new layer bounds if the layer shrank.
219 for (int i = after_right + 1; i <= before_right; ++i) {
220 for (int j = before_top; j <= before_bottom; ++j)
221 RemoveTileAt(i, j, recycled_twin);
222 }
223 for (int i = before_left; i <= after_right; ++i) {
224 for (int j = after_bottom + 1; j <= before_bottom; ++j)
225 RemoveTileAt(i, j, recycled_twin);
226 }
227
228 // If the layer grew, the live_tiles_rect_ is not changed, but a new row
229 // and/or column of tiles may now exist inside the same live_tiles_rect_.
230 const PictureLayerTiling* twin_tiling =
231 client_->GetPendingOrActiveTwinTiling(this);
232 if (after_right > before_right) {
233 DCHECK_EQ(after_right, before_right + 1);
234 for (int j = before_top; j <= after_bottom; ++j)
235 CreateTile(after_right, j, twin_tiling);
236 }
237 if (after_bottom > before_bottom) {
238 DCHECK_EQ(after_bottom, before_bottom + 1);
239 for (int i = before_left; i <= before_right; ++i)
240 CreateTile(i, after_bottom, twin_tiling);
241 }
242 } 218 }
243 219
220 // The layer bounds are only allowed to be empty when the tile size is empty.
221 // Otherwise we should not have such a tiling in the first place.
222 DCHECK_IMPLIES(!tile_size.IsEmpty(), !layer_bounds_.IsEmpty());
223
224 bool resized = layer_bounds != layer_bounds_;
225 layer_bounds_ = layer_bounds;
226
244 if (tile_size != tiling_data_.max_texture_size()) { 227 if (tile_size != tiling_data_.max_texture_size()) {
228 tiling_data_.SetTilingSize(content_bounds);
245 tiling_data_.SetMaxTextureSize(tile_size); 229 tiling_data_.SetMaxTextureSize(tile_size);
246 // When the tile size changes, the TilingData positions no longer work 230 // When the tile size changes, the TilingData positions no longer work
247 // as valid keys to the TileMap, so just drop all tiles. 231 // as valid keys to the TileMap, so just drop all tiles and clear the live
232 // tiles rect.
248 Reset(); 233 Reset();
249 } else { 234 return;
250 Invalidate(layer_invalidation);
251 } 235 }
252 236
253 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) 237 if (!resized)
vmpstr 2014/12/09 00:10:19 Can this be done early on? Or is the tile size che
danakj 2014/12/09 18:20:23 Right, if the tile size changes we have to do that
254 it->second->set_raster_source(raster_source); 238 return;
255 VerifyLiveTilesRect(); 239
240 // The SetLiveTilesRect() method would drop tiles outside the new bounds,
241 // but may do so incorrectly if resizing the tiling causes the number of
242 // tiles in the tiling_data_ to change.
243 gfx::Rect content_rect(content_bounds);
244 int before_left = tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.x());
245 int before_top = tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.y());
246 int before_right =
247 tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.right() - 1);
248 int before_bottom =
249 tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.bottom() - 1);
250
251 // The live_tiles_rect_ is clamped to stay within the tiling size as we
252 // change it.
253 live_tiles_rect_.Intersect(content_rect);
254 tiling_data_.SetTilingSize(content_bounds);
255
256 int after_right = -1;
257 int after_bottom = -1;
258 if (!live_tiles_rect_.IsEmpty()) {
259 after_right =
260 tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.right() - 1);
261 after_bottom =
262 tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.bottom() - 1);
263 }
264
265 // There is no recycled twin since this is run on the pending tiling
266 // during commit, and on the active tree during activate.
267 PictureLayerTiling* recycled_twin = NULL;
268 DCHECK_EQ(recycled_twin, client_->GetRecycledTwinTiling(this));
269
270 // Drop tiles outside the new layer bounds if the layer shrank.
271 for (int i = after_right + 1; i <= before_right; ++i) {
272 for (int j = before_top; j <= before_bottom; ++j)
273 RemoveTileAt(i, j, recycled_twin);
274 }
275 for (int i = before_left; i <= after_right; ++i) {
276 for (int j = after_bottom + 1; j <= before_bottom; ++j)
277 RemoveTileAt(i, j, recycled_twin);
278 }
279
280 // If the layer grew, the live_tiles_rect_ is not changed, but a new row
281 // and/or column of tiles may now exist inside the same live_tiles_rect_.
282 const PictureLayerTiling* twin_tiling =
283 client_->GetPendingOrActiveTwinTiling(this);
284 if (after_right > before_right) {
285 DCHECK_EQ(after_right, before_right + 1);
286 for (int j = before_top; j <= after_bottom; ++j)
287 CreateTile(after_right, j, twin_tiling);
288 }
289 if (after_bottom > before_bottom) {
290 DCHECK_EQ(after_bottom, before_bottom + 1);
291 for (int i = before_left; i <= before_right; ++i)
292 CreateTile(i, after_bottom, twin_tiling);
293 }
256 } 294 }
257 295
258 void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_region) { 296 void PictureLayerTiling::Invalidate(const Region& layer_invalidation) {
259 bool recreate_invalidated_tiles = false; 297 if (live_tiles_rect_.IsEmpty())
260 DoInvalidate(layer_region, recreate_invalidated_tiles); 298 return;
261 }
262
263 void PictureLayerTiling::Invalidate(const Region& layer_region) {
264 bool recreate_invalidated_tiles = true;
265 DoInvalidate(layer_region, recreate_invalidated_tiles);
266 }
267
268 void PictureLayerTiling::DoInvalidate(const Region& layer_region,
269 bool recreate_invalidated_tiles) {
270 std::vector<TileMapKey> new_tile_keys; 299 std::vector<TileMapKey> new_tile_keys;
271 gfx::Rect expanded_live_tiles_rect = 300 gfx::Rect expanded_live_tiles_rect =
272 tiling_data_.ExpandRectIgnoringBordersToTileBounds(live_tiles_rect_); 301 tiling_data_.ExpandRectIgnoringBordersToTileBounds(live_tiles_rect_);
273 for (Region::Iterator iter(layer_region); iter.has_rect(); iter.next()) { 302 for (Region::Iterator iter(layer_invalidation); iter.has_rect();
303 iter.next()) {
274 gfx::Rect layer_rect = iter.rect(); 304 gfx::Rect layer_rect = iter.rect();
275 gfx::Rect content_rect = 305 gfx::Rect content_rect =
276 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_); 306 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_);
277 // Consider tiles inside the live tiles rect even if only their border 307 // Consider tiles inside the live tiles rect even if only their border
278 // pixels intersect the invalidation. But don't consider tiles outside 308 // pixels intersect the invalidation. But don't consider tiles outside
279 // the live tiles rect with the same conditions, as they won't exist. 309 // the live tiles rect with the same conditions, as they won't exist.
280 int border_pixels = tiling_data_.border_texels(); 310 int border_pixels = tiling_data_.border_texels();
281 content_rect.Inset(-border_pixels, -border_pixels); 311 content_rect.Inset(-border_pixels, -border_pixels);
282 // Avoid needless work by not bothering to invalidate where there aren't 312 // Avoid needless work by not bothering to invalidate where there aren't
283 // tiles. 313 // tiles.
284 content_rect.Intersect(expanded_live_tiles_rect); 314 content_rect.Intersect(expanded_live_tiles_rect);
285 if (content_rect.IsEmpty()) 315 if (content_rect.IsEmpty())
286 continue; 316 continue;
287 // Since the content_rect includes border pixels already, don't include 317 // Since the content_rect includes border pixels already, don't include
288 // borders when iterating to avoid double counting them. 318 // borders when iterating to avoid double counting them.
289 bool include_borders = false; 319 bool include_borders = false;
290 for (TilingData::Iterator iter( 320 for (TilingData::Iterator iter(
291 &tiling_data_, content_rect, include_borders); 321 &tiling_data_, content_rect, include_borders);
292 iter; 322 iter;
293 ++iter) { 323 ++iter) {
294 // There is no recycled twin since this is run on the pending tiling. 324 // There is no recycled twin for the peding tree during commit, or for the
325 // active tree during activation.
295 PictureLayerTiling* recycled_twin = NULL; 326 PictureLayerTiling* recycled_twin = NULL;
296 DCHECK_EQ(recycled_twin, client_->GetRecycledTwinTiling(this)); 327 DCHECK_EQ(recycled_twin, client_->GetRecycledTwinTiling(this));
297 DCHECK_EQ(PENDING_TREE, client_->GetTree());
298 if (RemoveTileAt(iter.index_x(), iter.index_y(), recycled_twin)) 328 if (RemoveTileAt(iter.index_x(), iter.index_y(), recycled_twin))
299 new_tile_keys.push_back(iter.index()); 329 new_tile_keys.push_back(iter.index());
300 } 330 }
301 } 331 }
302 332
303 if (recreate_invalidated_tiles && !new_tile_keys.empty()) { 333 if (!new_tile_keys.empty()) {
334 // During commit to the pending tree, invalidations can never be shared with
335 // the active tree since the active tree has different content there.
336 // However, during activation, invalidations on the active tree can be
337 // shared with the pending tree always.
338 const PictureLayerTiling* twin_tiling = nullptr;
339 if (client_->GetTree() == ACTIVE_TREE)
340 twin_tiling = client_->GetPendingOrActiveTwinTiling(this);
304 for (size_t i = 0; i < new_tile_keys.size(); ++i) { 341 for (size_t i = 0; i < new_tile_keys.size(); ++i) {
305 // Don't try to share a tile with the twin layer, it's been invalidated so
306 // we have to make our own tile here.
307 const PictureLayerTiling* twin_tiling = NULL;
308 CreateTile(new_tile_keys[i].first, new_tile_keys[i].second, twin_tiling); 342 CreateTile(new_tile_keys[i].first, new_tile_keys[i].second, twin_tiling);
309 } 343 }
310 } 344 }
311 } 345 }
312 346
347 void PictureLayerTiling::SetRasterSource(
348 scoped_refptr<RasterSource> raster_source) {
349 // Shared (ie. non-invalidated) tiles on the pending tree are updated to use
350 // the new raster source. When this raster source is activated, the raster
351 // source will remain valid for shared tiles in the active tree.
352 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
353 it->second->set_raster_source(raster_source);
354 VerifyLiveTilesRect();
355 }
356
313 PictureLayerTiling::CoverageIterator::CoverageIterator() 357 PictureLayerTiling::CoverageIterator::CoverageIterator()
314 : tiling_(NULL), 358 : tiling_(NULL),
315 current_tile_(NULL), 359 current_tile_(NULL),
316 tile_i_(0), 360 tile_i_(0),
317 tile_j_(0), 361 tile_j_(0),
318 left_(0), 362 left_(0),
319 top_(0), 363 top_(0),
320 right_(-1), 364 right_(-1),
321 bottom_(-1) { 365 bottom_(-1) {
322 } 366 }
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 eventually_rect_area, 619 eventually_rect_area,
576 gfx::Rect(tiling_size()), 620 gfx::Rect(tiling_size()),
577 &expansion_cache_); 621 &expansion_cache_);
578 622
579 DCHECK(eventually_rect.IsEmpty() || 623 DCHECK(eventually_rect.IsEmpty() ||
580 gfx::Rect(tiling_size()).Contains(eventually_rect)) 624 gfx::Rect(tiling_size()).Contains(eventually_rect))
581 << "tiling_size: " << tiling_size().ToString() 625 << "tiling_size: " << tiling_size().ToString()
582 << " eventually_rect: " << eventually_rect.ToString(); 626 << " eventually_rect: " << eventually_rect.ToString();
583 627
584 // Calculate the soon border rect. 628 // Calculate the soon border rect.
585 content_to_screen_scale_ = ideal_contents_scale / contents_scale_; 629 float content_to_screen_scale = ideal_contents_scale / contents_scale_;
586 gfx::Rect soon_border_rect = visible_rect_in_content_space; 630 gfx::Rect soon_border_rect = visible_rect_in_content_space;
587 float border = kSoonBorderDistanceInScreenPixels / content_to_screen_scale_; 631 float border = kSoonBorderDistanceInScreenPixels / content_to_screen_scale;
588 soon_border_rect.Inset(-border, -border, -border, -border); 632 soon_border_rect.Inset(-border, -border, -border, -border);
589 633
590 // Update the tiling state.
591 SetLiveTilesRect(eventually_rect);
592
593 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds; 634 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds;
594 last_viewport_in_layer_space_ = viewport_in_layer_space; 635 last_viewport_in_layer_space_ = viewport_in_layer_space;
595 last_visible_rect_in_content_space_ = visible_rect_in_content_space; 636 last_visible_rect_in_content_space_ = visible_rect_in_content_space;
596 637
597 eviction_tiles_cache_valid_ = false; 638 SetLiveTilesRect(eventually_rect);
639 UpdateTilePriorityRects(
640 content_to_screen_scale, visible_rect_in_content_space, skewport,
641 soon_border_rect, eventually_rect, occlusion_in_layer_space);
642 }
598 643
644 void PictureLayerTiling::UpdateTilePriorityRects(
645 float content_to_screen_scale,
646 const gfx::Rect& visible_rect_in_content_space,
647 const gfx::Rect& skewport,
648 const gfx::Rect& soon_border_rect,
649 const gfx::Rect& eventually_rect,
650 const Occlusion& occlusion_in_layer_space) {
599 current_visible_rect_ = visible_rect_in_content_space; 651 current_visible_rect_ = visible_rect_in_content_space;
600 current_skewport_rect_ = skewport; 652 current_skewport_rect_ = skewport;
601 current_soon_border_rect_ = soon_border_rect; 653 current_soon_border_rect_ = soon_border_rect;
602 current_eventually_rect_ = eventually_rect; 654 current_eventually_rect_ = eventually_rect;
603 current_occlusion_in_layer_space_ = occlusion_in_layer_space; 655 current_occlusion_in_layer_space_ = occlusion_in_layer_space;
656 current_content_to_screen_scale_ = content_to_screen_scale;
604 657
605 // Update has_*_tiles state.
606 gfx::Rect tiling_rect(tiling_size()); 658 gfx::Rect tiling_rect(tiling_size());
607
608 has_visible_rect_tiles_ = tiling_rect.Intersects(current_visible_rect_); 659 has_visible_rect_tiles_ = tiling_rect.Intersects(current_visible_rect_);
609 has_skewport_rect_tiles_ = tiling_rect.Intersects(current_skewport_rect_); 660 has_skewport_rect_tiles_ = tiling_rect.Intersects(current_skewport_rect_);
610 has_soon_border_rect_tiles_ = 661 has_soon_border_rect_tiles_ =
611 tiling_rect.Intersects(current_soon_border_rect_); 662 tiling_rect.Intersects(current_soon_border_rect_);
612 has_eventually_rect_tiles_ = tiling_rect.Intersects(current_eventually_rect_); 663 has_eventually_rect_tiles_ = tiling_rect.Intersects(current_eventually_rect_);
664
665 eviction_tiles_cache_valid_ = false;
613 } 666 }
614 667
615 void PictureLayerTiling::SetLiveTilesRect( 668 void PictureLayerTiling::SetLiveTilesRect(
616 const gfx::Rect& new_live_tiles_rect) { 669 const gfx::Rect& new_live_tiles_rect) {
617 DCHECK(new_live_tiles_rect.IsEmpty() || 670 DCHECK(new_live_tiles_rect.IsEmpty() ||
618 gfx::Rect(tiling_size()).Contains(new_live_tiles_rect)) 671 gfx::Rect(tiling_size()).Contains(new_live_tiles_rect))
619 << "tiling_size: " << tiling_size().ToString() 672 << "tiling_size: " << tiling_size().ToString()
620 << " new_live_tiles_rect: " << new_live_tiles_rect.ToString(); 673 << " new_live_tiles_rect: " << new_live_tiles_rect.ToString();
621 if (live_tiles_rect_ == new_live_tiles_rect) 674 if (live_tiles_rect_ == new_live_tiles_rect)
622 return; 675 return;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 tile->set_is_occluded(tree, IsTileOccluded(tile)); 851 tile->set_is_occluded(tree, IsTileOccluded(tile));
799 return; 852 return;
800 } 853 }
801 854
802 if (tree == PENDING_TREE) 855 if (tree == PENDING_TREE)
803 tile->set_required_for_activation(false); 856 tile->set_required_for_activation(false);
804 else 857 else
805 tile->set_required_for_draw(false); 858 tile->set_required_for_draw(false);
806 tile->set_is_occluded(tree, false); 859 tile->set_is_occluded(tree, false);
807 860
808 DCHECK_GT(content_to_screen_scale_, 0.f); 861 DCHECK_GT(current_content_to_screen_scale_, 0.f);
809 float distance_to_visible = 862 float distance_to_visible =
810 current_visible_rect_.ManhattanInternalDistance(tile_bounds) * 863 current_visible_rect_.ManhattanInternalDistance(tile_bounds) *
811 content_to_screen_scale_; 864 current_content_to_screen_scale_;
812 865
813 if (max_tile_priority_bin <= TilePriority::SOON && 866 if (max_tile_priority_bin <= TilePriority::SOON &&
814 (current_soon_border_rect_.Intersects(tile_bounds) || 867 (current_soon_border_rect_.Intersects(tile_bounds) ||
815 current_skewport_rect_.Intersects(tile_bounds))) { 868 current_skewport_rect_.Intersects(tile_bounds))) {
816 tile->SetPriority( 869 tile->SetPriority(
817 tree, 870 tree,
818 TilePriority(resolution_, TilePriority::SOON, distance_to_visible)); 871 TilePriority(resolution_, TilePriority::SOON, distance_to_visible));
819 return; 872 return;
820 } 873 }
821 874
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 } 1263 }
1211 current_tile_ = tiling_->TileAt(next_index.first, next_index.second); 1264 current_tile_ = tiling_->TileAt(next_index.first, next_index.second);
1212 } 1265 }
1213 1266
1214 if (current_tile_) 1267 if (current_tile_)
1215 tiling_->UpdateTileAndTwinPriority(current_tile_); 1268 tiling_->UpdateTileAndTwinPriority(current_tile_);
1216 return *this; 1269 return *this;
1217 } 1270 }
1218 1271
1219 } // namespace cc 1272 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698