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

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: rebase 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
« no previous file with comments | « cc/resources/picture_layer_tiling.h ('k') | cc/resources/picture_layer_tiling_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
180 std::vector<TileMapKey> to_remove;
181 for (const auto& tile_map_pair : tiles_) {
182 TileMapKey key = tile_map_pair.first;
183 Tile* tile = tile_map_pair.second.get();
184 if (!tile->is_shared())
185 to_remove.push_back(key);
186 }
187 // The recycled twin does not exist since there is a pending twin (which is
188 // |twin_tiling|).
189 PictureLayerTiling* null_recycled_twin = nullptr;
190 DCHECK_EQ(null_recycled_twin, client_->GetRecycledTwinTiling(this));
191 for (const auto& key : to_remove) {
192 RemoveTileAt(key.first, key.second, null_recycled_twin);
193 CreateTile(key.first, key.second, &twin_tiling);
194 }
195
196 DCHECK_EQ(twin_tiling.tiles_.size(), tiles_.size());
197 #if DCHECK_IS_ON
198 for (const auto& tile_map_pair : tiles_)
199 DCHECK(tile_map_pair.second->is_shared());
200 #endif
201
202 UpdateTilePriorityRects(twin_tiling.current_content_to_screen_scale_,
203 twin_tiling.current_visible_rect_,
204 twin_tiling.current_skewport_rect_,
205 twin_tiling.current_soon_border_rect_,
206 twin_tiling.current_eventually_rect_,
207 twin_tiling.current_occlusion_in_layer_space_);
208 }
209
210 void PictureLayerTiling::Resize(const gfx::Size& new_layer_bounds) {
211 gfx::Size layer_bounds = new_layer_bounds;
176 gfx::Size content_bounds = 212 gfx::Size content_bounds =
177 gfx::ToCeiledSize(gfx::ScaleSize(new_layer_bounds, contents_scale_)); 213 gfx::ToCeiledSize(gfx::ScaleSize(new_layer_bounds, contents_scale_));
178 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); 214 gfx::Size tile_size = client_->CalculateTileSize(content_bounds);
179 215
180 if (new_layer_bounds != layer_bounds_) { 216 if (tile_size.IsEmpty()) {
181 if (tile_size.IsEmpty()) { 217 layer_bounds = gfx::Size();
182 layer_bounds_ = gfx::Size(); 218 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 } 219 }
243 220
221 // The layer bounds are only allowed to be empty when the tile size is empty.
222 // Otherwise we should not have such a tiling in the first place.
223 DCHECK_IMPLIES(!tile_size.IsEmpty(), !layer_bounds_.IsEmpty());
224
225 bool resized = layer_bounds != layer_bounds_;
226 layer_bounds_ = layer_bounds;
227
244 if (tile_size != tiling_data_.max_texture_size()) { 228 if (tile_size != tiling_data_.max_texture_size()) {
229 tiling_data_.SetTilingSize(content_bounds);
245 tiling_data_.SetMaxTextureSize(tile_size); 230 tiling_data_.SetMaxTextureSize(tile_size);
246 // When the tile size changes, the TilingData positions no longer work 231 // When the tile size changes, the TilingData positions no longer work
247 // as valid keys to the TileMap, so just drop all tiles. 232 // as valid keys to the TileMap, so just drop all tiles and clear the live
233 // tiles rect.
248 Reset(); 234 Reset();
249 } else { 235 return;
250 Invalidate(layer_invalidation);
251 } 236 }
252 237
253 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) 238 if (!resized)
254 it->second->set_raster_source(raster_source); 239 return;
255 VerifyLiveTilesRect(); 240
241 // The SetLiveTilesRect() method would drop tiles outside the new bounds,
242 // but may do so incorrectly if resizing the tiling causes the number of
243 // tiles in the tiling_data_ to change.
244 gfx::Rect content_rect(content_bounds);
245 int before_left = tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.x());
246 int before_top = tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.y());
247 int before_right =
248 tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.right() - 1);
249 int before_bottom =
250 tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.bottom() - 1);
251
252 // The live_tiles_rect_ is clamped to stay within the tiling size as we
253 // change it.
254 live_tiles_rect_.Intersect(content_rect);
255 tiling_data_.SetTilingSize(content_bounds);
256
257 int after_right = -1;
258 int after_bottom = -1;
259 if (!live_tiles_rect_.IsEmpty()) {
260 after_right =
261 tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.right() - 1);
262 after_bottom =
263 tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.bottom() - 1);
264 }
265
266 // There is no recycled twin since this is run on the pending tiling
267 // during commit, and on the active tree during activate.
268 PictureLayerTiling* recycled_twin = NULL;
269 DCHECK_EQ(recycled_twin, client_->GetRecycledTwinTiling(this));
270
271 // Drop tiles outside the new layer bounds if the layer shrank.
272 for (int i = after_right + 1; i <= before_right; ++i) {
273 for (int j = before_top; j <= before_bottom; ++j)
274 RemoveTileAt(i, j, recycled_twin);
275 }
276 for (int i = before_left; i <= after_right; ++i) {
277 for (int j = after_bottom + 1; j <= before_bottom; ++j)
278 RemoveTileAt(i, j, recycled_twin);
279 }
280
281 // If the layer grew, the live_tiles_rect_ is not changed, but a new row
282 // and/or column of tiles may now exist inside the same live_tiles_rect_.
283 const PictureLayerTiling* twin_tiling =
284 client_->GetPendingOrActiveTwinTiling(this);
285 if (after_right > before_right) {
286 DCHECK_EQ(after_right, before_right + 1);
287 for (int j = before_top; j <= after_bottom; ++j)
288 CreateTile(after_right, j, twin_tiling);
289 }
290 if (after_bottom > before_bottom) {
291 DCHECK_EQ(after_bottom, before_bottom + 1);
292 for (int i = before_left; i <= before_right; ++i)
293 CreateTile(i, after_bottom, twin_tiling);
294 }
256 } 295 }
257 296
258 void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_region) { 297 void PictureLayerTiling::Invalidate(const Region& layer_invalidation) {
259 bool recreate_invalidated_tiles = false; 298 if (live_tiles_rect_.IsEmpty())
260 DoInvalidate(layer_region, recreate_invalidated_tiles); 299 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; 300 std::vector<TileMapKey> new_tile_keys;
271 gfx::Rect expanded_live_tiles_rect = 301 gfx::Rect expanded_live_tiles_rect =
272 tiling_data_.ExpandRectIgnoringBordersToTileBounds(live_tiles_rect_); 302 tiling_data_.ExpandRectIgnoringBordersToTileBounds(live_tiles_rect_);
273 for (Region::Iterator iter(layer_region); iter.has_rect(); iter.next()) { 303 for (Region::Iterator iter(layer_invalidation); iter.has_rect();
304 iter.next()) {
274 gfx::Rect layer_rect = iter.rect(); 305 gfx::Rect layer_rect = iter.rect();
275 gfx::Rect content_rect = 306 gfx::Rect content_rect =
276 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_); 307 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_);
277 // Consider tiles inside the live tiles rect even if only their border 308 // Consider tiles inside the live tiles rect even if only their border
278 // pixels intersect the invalidation. But don't consider tiles outside 309 // pixels intersect the invalidation. But don't consider tiles outside
279 // the live tiles rect with the same conditions, as they won't exist. 310 // the live tiles rect with the same conditions, as they won't exist.
280 int border_pixels = tiling_data_.border_texels(); 311 int border_pixels = tiling_data_.border_texels();
281 content_rect.Inset(-border_pixels, -border_pixels); 312 content_rect.Inset(-border_pixels, -border_pixels);
282 // Avoid needless work by not bothering to invalidate where there aren't 313 // Avoid needless work by not bothering to invalidate where there aren't
283 // tiles. 314 // tiles.
284 content_rect.Intersect(expanded_live_tiles_rect); 315 content_rect.Intersect(expanded_live_tiles_rect);
285 if (content_rect.IsEmpty()) 316 if (content_rect.IsEmpty())
286 continue; 317 continue;
287 // Since the content_rect includes border pixels already, don't include 318 // Since the content_rect includes border pixels already, don't include
288 // borders when iterating to avoid double counting them. 319 // borders when iterating to avoid double counting them.
289 bool include_borders = false; 320 bool include_borders = false;
290 for (TilingData::Iterator iter( 321 for (TilingData::Iterator iter(
291 &tiling_data_, content_rect, include_borders); 322 &tiling_data_, content_rect, include_borders);
292 iter; 323 iter;
293 ++iter) { 324 ++iter) {
294 // There is no recycled twin since this is run on the pending tiling. 325 // There is no recycled twin for the pending tree during commit, or for
295 PictureLayerTiling* recycled_twin = NULL; 326 // the active tree during activation.
296 DCHECK_EQ(recycled_twin, client_->GetRecycledTwinTiling(this)); 327 PictureLayerTiling* null_recycled_twin = NULL;
297 DCHECK_EQ(PENDING_TREE, client_->GetTree()); 328 DCHECK_EQ(null_recycled_twin, client_->GetRecycledTwinTiling(this));
298 if (RemoveTileAt(iter.index_x(), iter.index_y(), recycled_twin)) 329 if (RemoveTileAt(iter.index_x(), iter.index_y(), null_recycled_twin))
299 new_tile_keys.push_back(iter.index()); 330 new_tile_keys.push_back(iter.index());
300 } 331 }
301 } 332 }
302 333
303 if (recreate_invalidated_tiles && !new_tile_keys.empty()) { 334 if (!new_tile_keys.empty()) {
335 // During commit from the main thread, invalidations can never be shared
336 // with the active tree since the active tree has different content there.
337 const PictureLayerTiling* twin_tiling = nullptr;
304 for (size_t i = 0; i < new_tile_keys.size(); ++i) { 338 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); 339 CreateTile(new_tile_keys[i].first, new_tile_keys[i].second, twin_tiling);
309 } 340 }
310 } 341 }
311 } 342 }
312 343
344 void PictureLayerTiling::SetRasterSource(
345 scoped_refptr<RasterSource> raster_source) {
346 // Shared (ie. non-invalidated) tiles on the pending tree are updated to use
347 // the new raster source. When this raster source is activated, the raster
348 // source will remain valid for shared tiles in the active tree.
349 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
350 it->second->set_raster_source(raster_source);
351 VerifyLiveTilesRect();
352 }
353
313 PictureLayerTiling::CoverageIterator::CoverageIterator() 354 PictureLayerTiling::CoverageIterator::CoverageIterator()
314 : tiling_(NULL), 355 : tiling_(NULL),
315 current_tile_(NULL), 356 current_tile_(NULL),
316 tile_i_(0), 357 tile_i_(0),
317 tile_j_(0), 358 tile_j_(0),
318 left_(0), 359 left_(0),
319 top_(0), 360 top_(0),
320 right_(-1), 361 right_(-1),
321 bottom_(-1) { 362 bottom_(-1) {
322 } 363 }
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 eventually_rect_area, 616 eventually_rect_area,
576 gfx::Rect(tiling_size()), 617 gfx::Rect(tiling_size()),
577 &expansion_cache_); 618 &expansion_cache_);
578 619
579 DCHECK(eventually_rect.IsEmpty() || 620 DCHECK(eventually_rect.IsEmpty() ||
580 gfx::Rect(tiling_size()).Contains(eventually_rect)) 621 gfx::Rect(tiling_size()).Contains(eventually_rect))
581 << "tiling_size: " << tiling_size().ToString() 622 << "tiling_size: " << tiling_size().ToString()
582 << " eventually_rect: " << eventually_rect.ToString(); 623 << " eventually_rect: " << eventually_rect.ToString();
583 624
584 // Calculate the soon border rect. 625 // Calculate the soon border rect.
585 content_to_screen_scale_ = ideal_contents_scale / contents_scale_; 626 float content_to_screen_scale = ideal_contents_scale / contents_scale_;
586 gfx::Rect soon_border_rect = visible_rect_in_content_space; 627 gfx::Rect soon_border_rect = visible_rect_in_content_space;
587 float border = kSoonBorderDistanceInScreenPixels / content_to_screen_scale_; 628 float border = kSoonBorderDistanceInScreenPixels / content_to_screen_scale;
588 soon_border_rect.Inset(-border, -border, -border, -border); 629 soon_border_rect.Inset(-border, -border, -border, -border);
589 630
590 // Update the tiling state.
591 SetLiveTilesRect(eventually_rect);
592
593 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds; 631 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds;
594 last_viewport_in_layer_space_ = viewport_in_layer_space; 632 last_viewport_in_layer_space_ = viewport_in_layer_space;
595 last_visible_rect_in_content_space_ = visible_rect_in_content_space; 633 last_visible_rect_in_content_space_ = visible_rect_in_content_space;
596 634
597 eviction_tiles_cache_valid_ = false; 635 SetLiveTilesRect(eventually_rect);
636 UpdateTilePriorityRects(
637 content_to_screen_scale, visible_rect_in_content_space, skewport,
638 soon_border_rect, eventually_rect, occlusion_in_layer_space);
639 }
598 640
641 void PictureLayerTiling::UpdateTilePriorityRects(
642 float content_to_screen_scale,
643 const gfx::Rect& visible_rect_in_content_space,
644 const gfx::Rect& skewport,
645 const gfx::Rect& soon_border_rect,
646 const gfx::Rect& eventually_rect,
647 const Occlusion& occlusion_in_layer_space) {
599 current_visible_rect_ = visible_rect_in_content_space; 648 current_visible_rect_ = visible_rect_in_content_space;
600 current_skewport_rect_ = skewport; 649 current_skewport_rect_ = skewport;
601 current_soon_border_rect_ = soon_border_rect; 650 current_soon_border_rect_ = soon_border_rect;
602 current_eventually_rect_ = eventually_rect; 651 current_eventually_rect_ = eventually_rect;
603 current_occlusion_in_layer_space_ = occlusion_in_layer_space; 652 current_occlusion_in_layer_space_ = occlusion_in_layer_space;
653 current_content_to_screen_scale_ = content_to_screen_scale;
604 654
605 // Update has_*_tiles state.
606 gfx::Rect tiling_rect(tiling_size()); 655 gfx::Rect tiling_rect(tiling_size());
607
608 has_visible_rect_tiles_ = tiling_rect.Intersects(current_visible_rect_); 656 has_visible_rect_tiles_ = tiling_rect.Intersects(current_visible_rect_);
609 has_skewport_rect_tiles_ = tiling_rect.Intersects(current_skewport_rect_); 657 has_skewport_rect_tiles_ = tiling_rect.Intersects(current_skewport_rect_);
610 has_soon_border_rect_tiles_ = 658 has_soon_border_rect_tiles_ =
611 tiling_rect.Intersects(current_soon_border_rect_); 659 tiling_rect.Intersects(current_soon_border_rect_);
612 has_eventually_rect_tiles_ = tiling_rect.Intersects(current_eventually_rect_); 660 has_eventually_rect_tiles_ = tiling_rect.Intersects(current_eventually_rect_);
661
662 eviction_tiles_cache_valid_ = false;
613 } 663 }
614 664
615 void PictureLayerTiling::SetLiveTilesRect( 665 void PictureLayerTiling::SetLiveTilesRect(
616 const gfx::Rect& new_live_tiles_rect) { 666 const gfx::Rect& new_live_tiles_rect) {
617 DCHECK(new_live_tiles_rect.IsEmpty() || 667 DCHECK(new_live_tiles_rect.IsEmpty() ||
618 gfx::Rect(tiling_size()).Contains(new_live_tiles_rect)) 668 gfx::Rect(tiling_size()).Contains(new_live_tiles_rect))
619 << "tiling_size: " << tiling_size().ToString() 669 << "tiling_size: " << tiling_size().ToString()
620 << " new_live_tiles_rect: " << new_live_tiles_rect.ToString(); 670 << " new_live_tiles_rect: " << new_live_tiles_rect.ToString();
621 if (live_tiles_rect_ == new_live_tiles_rect) 671 if (live_tiles_rect_ == new_live_tiles_rect)
622 return; 672 return;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 tile->set_is_occluded(tree, IsTileOccluded(tile)); 848 tile->set_is_occluded(tree, IsTileOccluded(tile));
799 return; 849 return;
800 } 850 }
801 851
802 if (tree == PENDING_TREE) 852 if (tree == PENDING_TREE)
803 tile->set_required_for_activation(false); 853 tile->set_required_for_activation(false);
804 else 854 else
805 tile->set_required_for_draw(false); 855 tile->set_required_for_draw(false);
806 tile->set_is_occluded(tree, false); 856 tile->set_is_occluded(tree, false);
807 857
808 DCHECK_GT(content_to_screen_scale_, 0.f); 858 DCHECK_GT(current_content_to_screen_scale_, 0.f);
809 float distance_to_visible = 859 float distance_to_visible =
810 current_visible_rect_.ManhattanInternalDistance(tile_bounds) * 860 current_visible_rect_.ManhattanInternalDistance(tile_bounds) *
811 content_to_screen_scale_; 861 current_content_to_screen_scale_;
812 862
813 if (max_tile_priority_bin <= TilePriority::SOON && 863 if (max_tile_priority_bin <= TilePriority::SOON &&
814 (current_soon_border_rect_.Intersects(tile_bounds) || 864 (current_soon_border_rect_.Intersects(tile_bounds) ||
815 current_skewport_rect_.Intersects(tile_bounds))) { 865 current_skewport_rect_.Intersects(tile_bounds))) {
816 tile->SetPriority( 866 tile->SetPriority(
817 tree, 867 tree,
818 TilePriority(resolution_, TilePriority::SOON, distance_to_visible)); 868 TilePriority(resolution_, TilePriority::SOON, distance_to_visible));
819 return; 869 return;
820 } 870 }
821 871
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 } 1260 }
1211 current_tile_ = tiling_->TileAt(next_index.first, next_index.second); 1261 current_tile_ = tiling_->TileAt(next_index.first, next_index.second);
1212 } 1262 }
1213 1263
1214 if (current_tile_) 1264 if (current_tile_)
1215 tiling_->UpdateTileAndTwinPriority(current_tile_); 1265 tiling_->UpdateTileAndTwinPriority(current_tile_);
1216 return *this; 1266 return *this;
1217 } 1267 }
1218 1268
1219 } // namespace cc 1269 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling.h ('k') | cc/resources/picture_layer_tiling_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698