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

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

Issue 676953003: cc: Always keep the PictureLayerImpl::twin_layer_ pointer valid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: twins: add-test-case Created 6 years, 2 months 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); 141 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect);
142 if (tile.get()) { 142 if (tile.get()) {
143 DCHECK(!tile->is_shared()); 143 DCHECK(!tile->is_shared());
144 tile->set_tiling_index(i, j); 144 tile->set_tiling_index(i, j);
145 tiles_[key] = tile; 145 tiles_[key] = tile;
146 } 146 }
147 return tile.get(); 147 return tile.get();
148 } 148 }
149 149
150 void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() { 150 void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() {
151 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); 151 const PictureLayerTiling* twin_tiling =
152 client_->GetPendingOrActiveTwinTiling(this);
152 bool include_borders = false; 153 bool include_borders = false;
153 for (TilingData::Iterator iter( 154 for (TilingData::Iterator iter(
154 &tiling_data_, live_tiles_rect_, include_borders); 155 &tiling_data_, live_tiles_rect_, include_borders);
155 iter; 156 iter;
156 ++iter) { 157 ++iter) {
157 TileMapKey key = iter.index(); 158 TileMapKey key = iter.index();
158 TileMap::iterator find = tiles_.find(key); 159 TileMap::iterator find = tiles_.find(key);
159 if (find != tiles_.end()) 160 if (find != tiles_.end())
160 continue; 161 continue;
161 CreateTile(key.first, key.second, twin_tiling); 162 CreateTile(key.first, key.second, twin_tiling);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 for (int j = before_top; j <= before_bottom; ++j) 219 for (int j = before_top; j <= before_bottom; ++j)
219 RemoveTileAt(i, j, recycled_twin); 220 RemoveTileAt(i, j, recycled_twin);
220 } 221 }
221 for (int i = before_left; i <= after_right; ++i) { 222 for (int i = before_left; i <= after_right; ++i) {
222 for (int j = after_bottom + 1; j <= before_bottom; ++j) 223 for (int j = after_bottom + 1; j <= before_bottom; ++j)
223 RemoveTileAt(i, j, recycled_twin); 224 RemoveTileAt(i, j, recycled_twin);
224 } 225 }
225 226
226 // If the layer grew, the live_tiles_rect_ is not changed, but a new row 227 // If the layer grew, the live_tiles_rect_ is not changed, but a new row
227 // and/or column of tiles may now exist inside the same live_tiles_rect_. 228 // and/or column of tiles may now exist inside the same live_tiles_rect_.
228 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); 229 const PictureLayerTiling* twin_tiling =
230 client_->GetPendingOrActiveTwinTiling(this);
229 if (after_right > before_right) { 231 if (after_right > before_right) {
230 DCHECK_EQ(after_right, before_right + 1); 232 DCHECK_EQ(after_right, before_right + 1);
231 for (int j = before_top; j <= after_bottom; ++j) 233 for (int j = before_top; j <= after_bottom; ++j)
232 CreateTile(after_right, j, twin_tiling); 234 CreateTile(after_right, j, twin_tiling);
233 } 235 }
234 if (after_bottom > before_bottom) { 236 if (after_bottom > before_bottom) {
235 DCHECK_EQ(after_bottom, before_bottom + 1); 237 DCHECK_EQ(after_bottom, before_bottom + 1);
236 for (int i = before_left; i <= before_right; ++i) 238 for (int i = before_left; i <= before_right; ++i)
237 CreateTile(i, after_bottom, twin_tiling); 239 CreateTile(i, after_bottom, twin_tiling);
238 } 240 }
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 // Iterate to delete all tiles outside of our new live_tiles rect. 624 // Iterate to delete all tiles outside of our new live_tiles rect.
623 PictureLayerTiling* recycled_twin = client_->GetRecycledTwinTiling(this); 625 PictureLayerTiling* recycled_twin = client_->GetRecycledTwinTiling(this);
624 for (TilingData::DifferenceIterator iter(&tiling_data_, 626 for (TilingData::DifferenceIterator iter(&tiling_data_,
625 live_tiles_rect_, 627 live_tiles_rect_,
626 new_live_tiles_rect); 628 new_live_tiles_rect);
627 iter; 629 iter;
628 ++iter) { 630 ++iter) {
629 RemoveTileAt(iter.index_x(), iter.index_y(), recycled_twin); 631 RemoveTileAt(iter.index_x(), iter.index_y(), recycled_twin);
630 } 632 }
631 633
632 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); 634 const PictureLayerTiling* twin_tiling =
635 client_->GetPendingOrActiveTwinTiling(this);
633 636
634 // Iterate to allocate new tiles for all regions with newly exposed area. 637 // Iterate to allocate new tiles for all regions with newly exposed area.
635 for (TilingData::DifferenceIterator iter(&tiling_data_, 638 for (TilingData::DifferenceIterator iter(&tiling_data_,
636 new_live_tiles_rect, 639 new_live_tiles_rect,
637 live_tiles_rect_); 640 live_tiles_rect_);
638 iter; 641 iter;
639 ++iter) { 642 ++iter) {
640 TileMapKey key(iter.index()); 643 TileMapKey key(iter.index());
641 CreateTile(key.first, key.second, twin_tiling); 644 CreateTile(key.first, key.second, twin_tiling);
642 } 645 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 713
711 if (resolution_ != HIGH_RESOLUTION) 714 if (resolution_ != HIGH_RESOLUTION)
712 return false; 715 return false;
713 716
714 if (IsTileOccluded(tile)) 717 if (IsTileOccluded(tile))
715 return false; 718 return false;
716 719
717 if (client_->RequiresHighResToDraw()) 720 if (client_->RequiresHighResToDraw())
718 return true; 721 return true;
719 722
720 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); 723 const PictureLayerTiling* twin_tiling =
724 client_->GetPendingOrActiveTwinTiling(this);
721 if (!twin_tiling) 725 if (!twin_tiling)
722 return true; 726 return true;
723 727
724 if (twin_tiling->layer_bounds() != layer_bounds()) 728 if (twin_tiling->layer_bounds() != layer_bounds())
725 return true; 729 return true;
726 730
727 if (twin_tiling->current_visible_rect_ != current_visible_rect_) 731 if (twin_tiling->current_visible_rect_ != current_visible_rect_)
728 return true; 732 return true;
729 733
730 Tile* twin_tile = 734 Tile* twin_tile =
731 twin_tiling->TileAt(tile->tiling_i_index(), tile->tiling_j_index()); 735 twin_tiling->TileAt(tile->tiling_i_index(), tile->tiling_j_index());
732 // If twin tile is missing, it might not have a recording, so we don't need 736 // If twin tile is missing, it might not have a recording, so we don't need
733 // this tile to be required for activation. 737 // this tile to be required for activation.
734 if (!twin_tile) 738 if (!twin_tile)
735 return false; 739 return false;
736 740
737 return true; 741 return true;
738 } 742 }
739 743
740 void PictureLayerTiling::UpdateTileAndTwinPriority(Tile* tile) const { 744 void PictureLayerTiling::UpdateTileAndTwinPriority(Tile* tile) const {
741 UpdateTilePriority(tile); 745 UpdateTilePriority(tile);
742 746
743 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); 747 const PictureLayerTiling* twin_tiling =
748 client_->GetPendingOrActiveTwinTiling(this);
744 if (!tile->is_shared() || !twin_tiling) { 749 if (!tile->is_shared() || !twin_tiling) {
745 WhichTree tree = client_->GetTree(); 750 WhichTree tree = client_->GetTree();
746 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; 751 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE;
747 tile->SetPriority(twin_tree, TilePriority()); 752 tile->SetPriority(twin_tree, TilePriority());
748 tile->set_is_occluded(twin_tree, false); 753 tile->set_is_occluded(twin_tree, false);
749 if (twin_tree == PENDING_TREE) 754 if (twin_tree == PENDING_TREE)
750 tile->set_required_for_activation(false); 755 tile->set_required_for_activation(false);
751 return; 756 return;
752 } 757 }
753 758
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 DCHECK(*this); 1231 DCHECK(*this);
1227 do { 1232 do {
1228 ++current_eviction_tiles_index_; 1233 ++current_eviction_tiles_index_;
1229 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && 1234 } while (current_eviction_tiles_index_ != eviction_tiles_->size() &&
1230 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); 1235 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources());
1231 1236
1232 return *this; 1237 return *this;
1233 } 1238 }
1234 1239
1235 } // namespace cc 1240 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698