Chromium Code Reviews| 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 | 9 |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "cc/base/math_util.h" | 11 #include "cc/base/math_util.h" |
| 12 #include "ui/gfx/point_conversions.h" | 12 #include "ui/gfx/point_conversions.h" |
| 13 #include "ui/gfx/rect_conversions.h" | 13 #include "ui/gfx/rect_conversions.h" |
| 14 #include "ui/gfx/safe_integer_conversions.h" | 14 #include "ui/gfx/safe_integer_conversions.h" |
| 15 #include "ui/gfx/size_conversions.h" | 15 #include "ui/gfx/size_conversions.h" |
| 16 | 16 |
| 17 namespace cc { | 17 namespace cc { |
| 18 | 18 |
| 19 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( | 19 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( |
| 20 float contents_scale) { | 20 float contents_scale) { |
| 21 return make_scoped_ptr(new PictureLayerTiling(contents_scale)); | 21 return make_scoped_ptr(new PictureLayerTiling(contents_scale)); |
| 22 } | 22 } |
| 23 | 23 |
| 24 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Clone() const { | 24 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Clone() const { |
| 25 return make_scoped_ptr(new PictureLayerTiling(*this)); | 25 PictureLayerTiling* out = new PictureLayerTiling(contents_scale_); |
|
enne (OOO)
2013/03/29 20:50:58
style nit: please don't ever use unwrapped raw poi
whunt
2013/03/29 21:52:04
Okay, this is a style nit through right? Due to o
enne (OOO)
2013/03/29 22:34:20
Yes. Your code as written is logically correct.
| |
| 26 out->contents_scale_ = contents_scale_; | |
| 27 out->layer_bounds_ = layer_bounds_; | |
| 28 out->resolution_ = resolution_; | |
| 29 out->client_ = client_; | |
| 30 out->tiling_data_ = tiling_data_; | |
| 31 out->last_source_frame_number_ = last_source_frame_number_; | |
| 32 out->last_impl_frame_time_ = last_impl_frame_time_; | |
| 33 return make_scoped_ptr(out); | |
| 26 } | 34 } |
| 27 | 35 |
| 28 PictureLayerTiling::PictureLayerTiling(float contents_scale) | 36 PictureLayerTiling::PictureLayerTiling(float contents_scale) |
| 29 : client_(NULL), | 37 : client_(NULL), |
| 30 contents_scale_(contents_scale), | 38 contents_scale_(contents_scale), |
| 31 tiling_data_(gfx::Size(), gfx::Size(), true), | 39 tiling_data_(gfx::Size(), gfx::Size(), true), |
| 32 resolution_(NON_IDEAL_RESOLUTION), | 40 resolution_(NON_IDEAL_RESOLUTION), |
| 33 last_source_frame_number_(0), | 41 last_source_frame_number_(0), |
| 34 last_impl_frame_time_(0) { | 42 last_impl_frame_time_(0) { |
| 35 } | 43 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 50 } | 58 } |
| 51 | 59 |
| 52 Tile* PictureLayerTiling::TileAt(int i, int j) const { | 60 Tile* PictureLayerTiling::TileAt(int i, int j) const { |
| 53 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); | 61 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); |
| 54 if (iter == tiles_.end()) | 62 if (iter == tiles_.end()) |
| 55 return NULL; | 63 return NULL; |
| 56 return iter->second.get(); | 64 return iter->second.get(); |
| 57 } | 65 } |
| 58 | 66 |
| 59 void PictureLayerTiling::CreateTile(int i, int j) { | 67 void PictureLayerTiling::CreateTile(int i, int j) { |
| 60 gfx::Rect tile_rect = tiling_data_.TileBoundsWithBorder(i, j); | |
| 61 tile_rect.set_size(tiling_data_.max_texture_size()); | |
| 62 TileMapKey key(i, j); | 68 TileMapKey key(i, j); |
| 63 DCHECK(tiles_.find(key) == tiles_.end()); | 69 DCHECK(tiles_.find(key) == tiles_.end()); |
| 70 | |
| 71 gfx::Rect paint_rect = tiling_data_.TileBoundsWithBorder(i, j); | |
| 72 gfx::Rect tile_rect = paint_rect; | |
| 73 tile_rect.set_size(tiling_data_.max_texture_size()); | |
| 74 | |
| 75 // Check our twin for a valid tile. | |
| 76 const PictureLayerTiling* twin = client_->GetTwinTiling(this); | |
| 77 if (twin) { | |
| 78 Tile* candidate_tile = twin->TileAt(i, j); | |
| 79 if (candidate_tile && tiling_data_.max_texture_size() == | |
|
enne (OOO)
2013/03/29 20:50:58
These two conditions aren't really tied together.
whunt
2013/03/29 21:52:04
done.
| |
| 80 twin->tiling_data_.max_texture_size()) { | |
| 81 | |
| 82 // Loop over the invalidation region explicitly because we have | |
|
enne (OOO)
2013/03/29 20:50:58
As a simplification suggestion, what about scaling
whunt
2013/03/29 21:52:04
Is that safe? We did some rounding when generated
enne (OOO)
2013/03/29 22:34:20
I think this is safe to do in both directions if y
| |
| 83 // to scale each rect from layer space to content space. | |
| 84 bool invalid = false; | |
| 85 for (Region::Iterator region_iter(*client_->GetInvalidation()); | |
| 86 !invalid && region_iter.has_rect(); | |
| 87 region_iter.next()) { | |
| 88 | |
| 89 gfx::Rect layer_rect = region_iter.rect(); | |
| 90 gfx::Rect rect = | |
| 91 gfx::ToEnclosingRect(ScaleRect(layer_rect, contents_scale_)); | |
| 92 | |
| 93 if (rect.Intersects(paint_rect)) | |
| 94 invalid = true; | |
| 95 } | |
| 96 if (!invalid) { | |
| 97 tiles_[key] = candidate_tile; | |
| 98 return; | |
| 99 } | |
| 100 } | |
| 101 } | |
| 102 | |
| 103 // Create a new tile because our twin didn't have a valid one. | |
| 64 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); | 104 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); |
| 65 if (tile) | 105 if (tile) |
| 66 tiles_[key] = tile; | 106 tiles_[key] = tile; |
| 67 } | 107 } |
| 68 | 108 |
| 69 Region PictureLayerTiling::OpaqueRegionInContentRect( | 109 Region PictureLayerTiling::OpaqueRegionInContentRect( |
| 70 const gfx::Rect& content_rect) const { | 110 const gfx::Rect& content_rect) const { |
| 71 Region opaque_region; | 111 Region opaque_region; |
| 72 // TODO(enne): implement me | 112 // TODO(enne): implement me |
| 73 return opaque_region; | 113 return opaque_region; |
| 74 } | 114 } |
| 75 | 115 |
| 76 void PictureLayerTiling::SetLayerBounds(gfx::Size layer_bounds) { | 116 void PictureLayerTiling::SetLayerBounds(gfx::Size layer_bounds) { |
| 77 if (layer_bounds_ == layer_bounds) | 117 if (layer_bounds_ == layer_bounds) |
| 78 return; | 118 return; |
| 79 | 119 |
| 80 gfx::Size old_layer_bounds = layer_bounds_; | 120 gfx::Size old_layer_bounds = layer_bounds_; |
| 81 layer_bounds_ = layer_bounds; | 121 layer_bounds_ = layer_bounds; |
| 122 | |
| 123 // Calculate and set the new content bounds. | |
| 82 gfx::Size old_content_bounds = tiling_data_.total_size(); | 124 gfx::Size old_content_bounds = tiling_data_.total_size(); |
| 83 gfx::Size content_bounds = | 125 gfx::Size content_bounds = |
| 84 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds_, contents_scale_)); | 126 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds_, contents_scale_)); |
| 127 tiling_data_.SetTotalSize(content_bounds); | |
| 85 | 128 |
| 86 tiling_data_.SetTotalSize(content_bounds); | 129 // Handle the case where the size of our tiling has changed. |
| 87 if (layer_bounds_.IsEmpty()) { | |
| 88 tiles_.clear(); | |
| 89 return; | |
| 90 } | |
| 91 | |
| 92 gfx::Size tile_size = client_->CalculateTileSize( | 130 gfx::Size tile_size = client_->CalculateTileSize( |
| 93 tiling_data_.max_texture_size(), | 131 tiling_data_.max_texture_size(), |
| 94 content_bounds); | 132 content_bounds); |
| 95 if (tile_size != tiling_data_.max_texture_size()) { | 133 if (tile_size != tiling_data_.max_texture_size()) { |
| 96 tiling_data_.SetMaxTextureSize(tile_size); | 134 tiling_data_.SetMaxTextureSize(tile_size); |
| 97 tiles_.clear(); | 135 tiles_.clear(); |
| 98 CreateTilesFromLayerRect(gfx::Rect(layer_bounds_)); | 136 interest_rect_ = gfx::Rect(); |
|
enne (OOO)
2013/03/29 20:50:58
https://codereview.chromium.org/12865017/diff/1/cc
whunt
2013/03/29 21:52:04
I think my previous response was just incorrect.
enne (OOO)
2013/03/29 22:34:20
Ah, that makes a lot of sense. Thanks for the exp
| |
| 99 return; | 137 return; |
| 100 } | 138 } |
| 101 | 139 |
| 102 // Any tiles outside our new bounds are invalid and should be dropped. | 140 // Delete all tiles that contained previously unpainted regions. |
| 103 if (old_content_bounds.width() > content_bounds.width() || | 141 for (TilingData::DifferenceIterator iter(&tiling_data_, |
|
enne (OOO)
2013/03/29 20:50:58
I think this loop will be a no-op because you have
whunt
2013/03/29 21:52:04
I don't understand. If the new content bounds are
enne (OOO)
2013/03/29 22:34:20
Put another way, what is the maximum index that Ti
| |
| 104 old_content_bounds.height() > content_bounds.height()) { | 142 gfx::Rect(content_bounds), |
| 105 int right = | 143 gfx::Rect(old_content_bounds)); |
| 106 tiling_data_.TileXIndexFromSrcCoord(content_bounds.width() - 1); | 144 iter; ++iter) { |
| 107 int bottom = | 145 tiles_.erase(TileMapKey(iter.index())); |
| 108 tiling_data_.TileYIndexFromSrcCoord(content_bounds.height() - 1); | |
| 109 | |
| 110 std::vector<TileMapKey> invalid_tile_keys; | |
| 111 for (TileMap::const_iterator it = tiles_.begin(); | |
| 112 it != tiles_.end(); ++it) { | |
| 113 if (it->first.first > right || it->first.second > bottom) | |
| 114 invalid_tile_keys.push_back(it->first); | |
| 115 } | |
| 116 for (size_t i = 0; i < invalid_tile_keys.size(); ++i) | |
| 117 tiles_.erase(invalid_tile_keys[i]); | |
| 118 } | |
| 119 | |
| 120 // Create tiles for newly exposed areas. | |
| 121 Region layer_region((gfx::Rect(layer_bounds_))); | |
| 122 layer_region.Subtract(gfx::Rect(old_layer_bounds)); | |
| 123 for (Region::Iterator iter(layer_region); iter.has_rect(); iter.next()) { | |
| 124 Invalidate(iter.rect()); | |
| 125 CreateTilesFromLayerRect(iter.rect()); | |
| 126 } | 146 } |
| 127 } | 147 } |
| 128 | 148 |
| 129 void PictureLayerTiling::Invalidate(const Region& layer_invalidation) { | |
| 130 std::vector<TileMapKey> new_tiles; | |
| 131 | |
| 132 for (Region::Iterator region_iter(layer_invalidation); | |
| 133 region_iter.has_rect(); | |
| 134 region_iter.next()) { | |
| 135 gfx::Rect layer_invalidation = region_iter.rect(); | |
| 136 layer_invalidation.Intersect(gfx::Rect(layer_bounds_)); | |
| 137 gfx::Rect rect = | |
| 138 gfx::ToEnclosingRect(ScaleRect(layer_invalidation, contents_scale_)); | |
| 139 | |
| 140 for (PictureLayerTiling::Iterator tile_iter(this, contents_scale_, rect); | |
| 141 tile_iter; | |
| 142 ++tile_iter) { | |
| 143 TileMapKey key(tile_iter.tile_i_, tile_iter.tile_j_); | |
| 144 TileMap::iterator found = tiles_.find(key); | |
| 145 if (found == tiles_.end()) | |
| 146 continue; | |
| 147 | |
| 148 tiles_.erase(found); | |
| 149 new_tiles.push_back(key); | |
| 150 } | |
| 151 } | |
| 152 | |
| 153 for (size_t i = 0; i < new_tiles.size(); ++i) | |
| 154 CreateTile(new_tiles[i].first, new_tiles[i].second); | |
| 155 } | |
| 156 | |
| 157 void PictureLayerTiling::CreateTilesFromLayerRect(gfx::Rect layer_rect) { | |
| 158 gfx::Rect content_rect = | |
| 159 gfx::ToEnclosingRect(ScaleRect(layer_rect, contents_scale_)); | |
| 160 CreateTilesFromContentRect(content_rect); | |
| 161 } | |
| 162 | |
| 163 void PictureLayerTiling::CreateTilesFromContentRect(gfx::Rect content_rect) { | |
| 164 for (TilingData::Iterator iter(&tiling_data_, content_rect); iter; ++iter) { | |
| 165 TileMap::iterator found = | |
| 166 tiles_.find(TileMapKey(iter.index_x(), iter.index_y())); | |
| 167 // Ignore any tiles that already exist. | |
| 168 if (found != tiles_.end()) | |
| 169 continue; | |
| 170 CreateTile(iter.index_x(), iter.index_y()); | |
| 171 } | |
| 172 } | |
| 173 | |
| 174 PictureLayerTiling::Iterator::Iterator() | 149 PictureLayerTiling::Iterator::Iterator() |
| 175 : tiling_(NULL), | 150 : tiling_(NULL), |
| 176 current_tile_(NULL), | 151 current_tile_(NULL), |
| 177 tile_i_(0), | 152 tile_i_(0), |
| 178 tile_j_(0), | 153 tile_j_(0), |
| 179 left_(0), | 154 left_(0), |
| 180 top_(0), | 155 top_(0), |
| 181 right_(-1), | 156 right_(-1), |
| 182 bottom_(-1) { | 157 bottom_(-1) { |
| 183 } | 158 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 float current_layer_contents_scale, | 305 float current_layer_contents_scale, |
| 331 const gfx::Transform& last_screen_transform, | 306 const gfx::Transform& last_screen_transform, |
| 332 const gfx::Transform& current_screen_transform, | 307 const gfx::Transform& current_screen_transform, |
| 333 int current_source_frame_number, | 308 int current_source_frame_number, |
| 334 double current_frame_time, | 309 double current_frame_time, |
| 335 bool store_screen_space_quads_on_tiles, | 310 bool store_screen_space_quads_on_tiles, |
| 336 size_t max_tiles_for_interest_area) { | 311 size_t max_tiles_for_interest_area) { |
| 337 if (ContentRect().IsEmpty()) | 312 if (ContentRect().IsEmpty()) |
| 338 return; | 313 return; |
| 339 | 314 |
| 315 gfx::Rect viewport_in_content_space = | |
| 316 gfx::ToEnclosingRect(gfx::ScaleRect(viewport_in_layer_space, | |
| 317 contents_scale_)); | |
| 318 | |
| 319 gfx::Size tile_size = tiling_data_.max_texture_size(); | |
| 320 int64 interest_rect_area = | |
| 321 max_tiles_for_interest_area * tile_size.width() * tile_size.height(); | |
| 322 | |
| 323 gfx::Rect interest_rect = ExpandRectEquallyToAreaBoundedBy( | |
| 324 viewport_in_content_space, | |
| 325 interest_rect_area, | |
| 326 ContentRect()); | |
| 327 DCHECK(ContentRect().Contains(interest_rect)); | |
| 328 | |
| 329 ManageTiles(interest_rect_, interest_rect); | |
| 330 interest_rect_ = interest_rect; | |
| 331 | |
| 340 bool first_update_in_new_source_frame = | 332 bool first_update_in_new_source_frame = |
| 341 current_source_frame_number != last_source_frame_number_; | 333 current_source_frame_number != last_source_frame_number_; |
| 342 | 334 |
| 343 bool first_update_in_new_impl_frame = | 335 bool first_update_in_new_impl_frame = |
| 344 current_frame_time != last_impl_frame_time_; | 336 current_frame_time != last_impl_frame_time_; |
| 345 | 337 |
| 346 // In pending tree, this is always called. We update priorities: | 338 // In pending tree, this is always called. We update priorities: |
| 347 // - Immediately after a commit (first_update_in_new_source_frame). | 339 // - Immediately after a commit (first_update_in_new_source_frame). |
| 348 // - On animation ticks after the first frame in the tree | 340 // - On animation ticks after the first frame in the tree |
| 349 // (first_update_in_new_impl_frame). | 341 // (first_update_in_new_impl_frame). |
| 350 // In active tree, this is only called during draw. We update priorities: | 342 // In active tree, this is only called during draw. We update priorities: |
| 351 // - On draw if properties were not already computed by the pending tree | 343 // - On draw if properties were not already computed by the pending tree |
| 352 // and activated for the frame (first_update_in_new_impl_frame). | 344 // and activated for the frame (first_update_in_new_impl_frame). |
| 353 if (!first_update_in_new_impl_frame && !first_update_in_new_source_frame) | 345 if (!first_update_in_new_impl_frame && !first_update_in_new_source_frame) |
| 354 return; | 346 return; |
| 355 | 347 |
| 356 double time_delta = 0; | 348 double time_delta = 0.0; |
| 357 if (last_impl_frame_time_ != 0 && last_layer_bounds == current_layer_bounds) | 349 if (last_impl_frame_time_ != 0.0 && |
| 350 last_layer_bounds == current_layer_bounds) | |
| 358 time_delta = current_frame_time - last_impl_frame_time_; | 351 time_delta = current_frame_time - last_impl_frame_time_; |
| 359 | 352 |
| 360 gfx::Rect viewport_in_content_space = | |
| 361 gfx::ToEnclosingRect(gfx::ScaleRect(viewport_in_layer_space, | |
| 362 contents_scale_)); | |
| 363 | |
| 364 gfx::Size tile_size = tiling_data_.max_texture_size(); | |
| 365 int64 prioritized_rect_area = | |
| 366 max_tiles_for_interest_area * | |
| 367 tile_size.width() * tile_size.height(); | |
| 368 | |
| 369 gfx::Rect prioritized_rect = ExpandRectEquallyToAreaBoundedBy( | |
| 370 viewport_in_content_space, | |
| 371 prioritized_rect_area, | |
| 372 ContentRect()); | |
| 373 DCHECK(ContentRect().Contains(prioritized_rect)); | |
| 374 | |
| 375 // Iterate through all of the tiles that were live last frame but will | |
| 376 // not be live this frame, and mark them as being dead. | |
| 377 for (TilingData::DifferenceIterator iter(&tiling_data_, | |
| 378 last_prioritized_rect_, | |
| 379 prioritized_rect); | |
| 380 iter; | |
| 381 ++iter) { | |
| 382 TileMap::iterator find = tiles_.find(iter.index()); | |
| 383 if (find == tiles_.end()) | |
| 384 continue; | |
| 385 | |
| 386 TilePriority priority; | |
| 387 DCHECK(!priority.is_live); | |
|
enne (OOO)
2013/03/29 20:50:58
Can you also remove is_live from tile priority and
whunt
2013/03/29 21:52:04
From my understanding, all tiles should be live (w
enne (OOO)
2013/03/29 22:34:20
That's fine to leave it out and follow up later.
whunt
2013/03/29 23:17:36
It was just an informal discussion in the cubes li
| |
| 388 Tile* tile = find->second.get(); | |
| 389 tile->SetPriority(tree, priority); | |
| 390 } | |
| 391 last_prioritized_rect_ = prioritized_rect; | |
| 392 | |
| 393 gfx::Rect view_rect(device_viewport); | 353 gfx::Rect view_rect(device_viewport); |
| 394 float current_scale = current_layer_contents_scale / contents_scale_; | 354 float current_scale = current_layer_contents_scale / contents_scale_; |
| 395 float last_scale = last_layer_contents_scale / contents_scale_; | 355 float last_scale = last_layer_contents_scale / contents_scale_; |
| 396 | 356 |
| 397 // Fast path tile priority calculation when both transforms are translations. | 357 // Fast path tile priority calculation when both transforms are translations. |
| 398 if (last_screen_transform.IsIdentityOrTranslation() && | 358 if (last_screen_transform.IsIdentityOrTranslation() && |
| 399 current_screen_transform.IsIdentityOrTranslation()) { | 359 current_screen_transform.IsIdentityOrTranslation()) { |
| 400 gfx::Vector2dF current_offset( | 360 gfx::Vector2dF current_offset( |
| 401 current_screen_transform.matrix().get(0, 3), | 361 current_screen_transform.matrix().get(0, 3), |
| 402 current_screen_transform.matrix().get(1, 3)); | 362 current_screen_transform.matrix().get(1, 3)); |
| 403 gfx::Vector2dF last_offset( | 363 gfx::Vector2dF last_offset( |
| 404 last_screen_transform.matrix().get(0, 3), | 364 last_screen_transform.matrix().get(0, 3), |
| 405 last_screen_transform.matrix().get(1, 3)); | 365 last_screen_transform.matrix().get(1, 3)); |
| 406 | 366 |
| 407 for (TilingData::Iterator iter(&tiling_data_, prioritized_rect); | 367 for (TilingData::Iterator iter(&tiling_data_, interest_rect); |
| 408 iter; ++iter) { | 368 iter; ++iter) { |
| 409 TileMap::iterator find = tiles_.find(iter.index()); | 369 TileMap::iterator find = tiles_.find(iter.index()); |
| 410 if (find == tiles_.end()) | 370 if (find == tiles_.end()) |
| 411 continue; | 371 continue; |
| 412 Tile* tile = find->second.get(); | 372 Tile* tile = find->second.get(); |
| 413 | 373 |
| 414 gfx::Rect tile_bounds = | 374 gfx::Rect tile_bounds = |
| 415 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); | 375 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); |
| 416 gfx::RectF current_screen_rect = gfx::ScaleRect( | 376 gfx::RectF current_screen_rect = gfx::ScaleRect( |
| 417 tile_bounds, | 377 tile_bounds, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 430 last_screen_rect, current_screen_rect, time_delta, view_rect); | 390 last_screen_rect, current_screen_rect, time_delta, view_rect); |
| 431 TilePriority priority( | 391 TilePriority priority( |
| 432 resolution_, | 392 resolution_, |
| 433 time_to_visible_in_seconds, | 393 time_to_visible_in_seconds, |
| 434 distance_to_visible_in_pixels); | 394 distance_to_visible_in_pixels); |
| 435 if (store_screen_space_quads_on_tiles) | 395 if (store_screen_space_quads_on_tiles) |
| 436 priority.set_current_screen_quad(gfx::QuadF(current_screen_rect)); | 396 priority.set_current_screen_quad(gfx::QuadF(current_screen_rect)); |
| 437 tile->SetPriority(tree, priority); | 397 tile->SetPriority(tree, priority); |
| 438 } | 398 } |
| 439 } else { | 399 } else { |
| 440 for (TilingData::Iterator iter(&tiling_data_, prioritized_rect); | 400 for (TilingData::Iterator iter(&tiling_data_, interest_rect); |
| 441 iter; ++iter) { | 401 iter; ++iter) { |
| 442 TileMap::iterator find = tiles_.find(iter.index()); | 402 TileMap::iterator find = tiles_.find(iter.index()); |
| 443 if (find == tiles_.end()) | 403 if (find == tiles_.end()) |
| 444 continue; | 404 continue; |
| 445 Tile* tile = find->second.get(); | 405 Tile* tile = find->second.get(); |
| 446 | 406 |
| 447 gfx::Rect tile_bounds = | 407 gfx::Rect tile_bounds = |
| 448 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); | 408 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); |
| 449 gfx::RectF current_layer_content_rect = gfx::ScaleRect( | 409 gfx::RectF current_layer_content_rect = gfx::ScaleRect( |
| 450 tile_bounds, | 410 tile_bounds, |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 478 &clipped)); | 438 &clipped)); |
| 479 } | 439 } |
| 480 tile->SetPriority(tree, priority); | 440 tile->SetPriority(tree, priority); |
| 481 } | 441 } |
| 482 } | 442 } |
| 483 | 443 |
| 484 last_source_frame_number_ = current_source_frame_number; | 444 last_source_frame_number_ = current_source_frame_number; |
| 485 last_impl_frame_time_ = current_frame_time; | 445 last_impl_frame_time_ = current_frame_time; |
| 486 } | 446 } |
| 487 | 447 |
| 448 void PictureLayerTiling::ManageTiles(const gfx::Rect& old_interest_rect, | |
| 449 const gfx::Rect& new_interest_rect) { | |
| 450 if (old_interest_rect == new_interest_rect) | |
| 451 return; | |
| 452 | |
| 453 // Iterate to delete all tiles outside of our new interest rect. | |
| 454 for (TilingData::DifferenceIterator iter(&tiling_data_, | |
| 455 old_interest_rect, | |
| 456 new_interest_rect); | |
| 457 iter; ++iter) { | |
|
enne (OOO)
2013/03/29 20:50:58
style nit: Could you put "iter" and "++iter" on di
whunt
2013/03/29 21:52:04
Sure.
| |
| 458 TileMapKey key(iter.index()); | |
| 459 TileMap::iterator found = tiles_.find(key); | |
| 460 if (found != tiles_.end() && | |
| 461 !new_interest_rect.Intersects(found->second->content_rect())) | |
|
enne (OOO)
2013/03/29 20:50:58
What are you trying to get at with this condition?
whunt
2013/03/29 21:52:04
we're trying to find tiles that are entirely outsi
| |
| 462 tiles_.erase(found); | |
| 463 } | |
| 464 | |
| 465 // Iterate to allocate new tiles for all regions with newly exposed area. | |
| 466 for (TilingData::DifferenceIterator iter(&tiling_data_, | |
| 467 new_interest_rect, | |
| 468 old_interest_rect); | |
| 469 iter; ++iter) { | |
| 470 TileMapKey key(iter.index()); | |
| 471 TileMap::iterator found = tiles_.find(key); | |
| 472 CreateTile(key.first, key.second); | |
| 473 } | |
| 474 } | |
| 475 | |
| 488 void PictureLayerTiling::DidBecomeActive() { | 476 void PictureLayerTiling::DidBecomeActive() { |
| 489 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 477 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| 490 it->second->SetPriority(ACTIVE_TREE, it->second->priority(PENDING_TREE)); | 478 it->second->SetPriority(ACTIVE_TREE, it->second->priority(PENDING_TREE)); |
| 491 it->second->SetPriority(PENDING_TREE, TilePriority()); | 479 it->second->SetPriority(PENDING_TREE, TilePriority()); |
| 492 | 480 |
| 493 // Tile holds a ref onto a picture pile. If the tile never gets invalidated | 481 // Tile holds a ref onto a picture pile. If the tile never gets invalidated |
| 494 // and recreated, then that picture pile ref could exist indefinitely. To | 482 // and recreated, then that picture pile ref could exist indefinitely. To |
| 495 // prevent this, ask the client to update the pile to its own ref. This | 483 // prevent this, ask the client to update the pile to its own ref. This |
| 496 // will cause PicturePileImpls and their clones to get deleted once the | 484 // will cause PicturePileImpls and their clones to get deleted once the |
| 497 // corresponding PictureLayerImpl and any in flight raster jobs go out of | 485 // corresponding PictureLayerImpl and any in flight raster jobs go out of |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 603 | 591 |
| 604 // If our delta is less then our event distance, we're done. | 592 // If our delta is less then our event distance, we're done. |
| 605 if (delta < event.distance) | 593 if (delta < event.distance) |
| 606 break; | 594 break; |
| 607 } | 595 } |
| 608 | 596 |
| 609 return gfx::Rect(origin_x, origin_y, width, height); | 597 return gfx::Rect(origin_x, origin_y, width, height); |
| 610 } | 598 } |
| 611 | 599 |
| 612 } // namespace cc | 600 } // namespace cc |
| OLD | NEW |