| 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/tiles/picture_layer_tiling.h" | 5 #include "cc/tiles/picture_layer_tiling.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 149 |
| 150 resolution_ = pending_twin->resolution_; | 150 resolution_ = pending_twin->resolution_; |
| 151 bool create_missing_tiles = false; | 151 bool create_missing_tiles = false; |
| 152 if (live_tiles_rect_.IsEmpty()) { | 152 if (live_tiles_rect_.IsEmpty()) { |
| 153 live_tiles_rect_ = pending_twin->live_tiles_rect(); | 153 live_tiles_rect_ = pending_twin->live_tiles_rect(); |
| 154 create_missing_tiles = true; | 154 create_missing_tiles = true; |
| 155 } else { | 155 } else { |
| 156 SetLiveTilesRect(pending_twin->live_tiles_rect()); | 156 SetLiveTilesRect(pending_twin->live_tiles_rect()); |
| 157 } | 157 } |
| 158 | 158 |
| 159 if (tiles_.empty()) { | 159 while (!pending_twin->tiles_.empty()) { |
| 160 tiles_.swap(pending_twin->tiles_); | 160 auto pending_iter = pending_twin->tiles_.begin(); |
| 161 all_tiles_done_ = pending_twin->all_tiles_done_; | 161 pending_iter->second->set_tiling(this); |
| 162 } else { | 162 tiles_[pending_iter->first] = std::move(pending_iter->second); |
| 163 while (!pending_twin->tiles_.empty()) { | 163 pending_twin->tiles_.erase(pending_iter); |
| 164 auto pending_iter = pending_twin->tiles_.begin(); | |
| 165 tiles_[pending_iter->first] = std::move(pending_iter->second); | |
| 166 pending_twin->tiles_.erase(pending_iter); | |
| 167 } | |
| 168 all_tiles_done_ &= pending_twin->all_tiles_done_; | |
| 169 } | 164 } |
| 165 all_tiles_done_ &= pending_twin->all_tiles_done_; |
| 166 |
| 170 DCHECK(pending_twin->tiles_.empty()); | 167 DCHECK(pending_twin->tiles_.empty()); |
| 171 pending_twin->all_tiles_done_ = true; | 168 pending_twin->all_tiles_done_ = true; |
| 172 | 169 |
| 173 if (create_missing_tiles) | 170 if (create_missing_tiles) |
| 174 CreateMissingTilesInLiveTilesRect(); | 171 CreateMissingTilesInLiveTilesRect(); |
| 175 | 172 |
| 176 VerifyLiveTilesRect(false); | 173 VerifyLiveTilesRect(false); |
| 177 | 174 |
| 178 SetTilePriorityRects(pending_twin->current_content_to_screen_scale_, | 175 SetTilePriorityRects(pending_twin->current_content_to_screen_scale_, |
| 179 pending_twin->current_visible_rect_, | 176 pending_twin->current_visible_rect_, |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 tile->SetInvalidated(invalid_content_rect, old_tile->id()); | 313 tile->SetInvalidated(invalid_content_rect, old_tile->id()); |
| 317 } | 314 } |
| 318 } | 315 } |
| 319 } | 316 } |
| 320 | 317 |
| 321 Tile::CreateInfo PictureLayerTiling::CreateInfoForTile(int i, int j) const { | 318 Tile::CreateInfo PictureLayerTiling::CreateInfoForTile(int i, int j) const { |
| 322 gfx::Rect tile_rect = tiling_data_.TileBoundsWithBorder(i, j); | 319 gfx::Rect tile_rect = tiling_data_.TileBoundsWithBorder(i, j); |
| 323 tile_rect.set_size(tiling_data_.max_texture_size()); | 320 tile_rect.set_size(tiling_data_.max_texture_size()); |
| 324 gfx::Rect enclosing_layer_rect = gfx::ScaleToEnclosingRect( | 321 gfx::Rect enclosing_layer_rect = gfx::ScaleToEnclosingRect( |
| 325 tile_rect, 1.f / raster_scales_.width(), 1.f / raster_scales_.height()); | 322 tile_rect, 1.f / raster_scales_.width(), 1.f / raster_scales_.height()); |
| 326 return Tile::CreateInfo(i, j, enclosing_layer_rect, tile_rect, | 323 return Tile::CreateInfo(this, i, j, enclosing_layer_rect, tile_rect, |
| 327 raster_scales_); | 324 raster_scales_); |
| 328 } | 325 } |
| 329 | 326 |
| 330 bool PictureLayerTiling::ShouldCreateTileAt( | 327 bool PictureLayerTiling::ShouldCreateTileAt( |
| 331 const Tile::CreateInfo& info) const { | 328 const Tile::CreateInfo& info) const { |
| 332 const int i = info.tiling_i_index; | 329 const int i = info.tiling_i_index; |
| 333 const int j = info.tiling_j_index; | 330 const int j = info.tiling_j_index; |
| 334 // Active tree should always create a tile. The reason for this is that active | 331 // Active tree should always create a tile. The reason for this is that active |
| 335 // tree represents content that we draw on screen, which means that whenever | 332 // tree represents content that we draw on screen, which means that whenever |
| 336 // we check whether a tile should exist somewhere, the answer is yes. This | 333 // we check whether a tile should exist somewhere, the answer is yes. This |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { | 962 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { |
| 966 size_t amount = 0; | 963 size_t amount = 0; |
| 967 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 964 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| 968 const Tile* tile = it->second.get(); | 965 const Tile* tile = it->second.get(); |
| 969 amount += tile->GPUMemoryUsageInBytes(); | 966 amount += tile->GPUMemoryUsageInBytes(); |
| 970 } | 967 } |
| 971 return amount; | 968 return amount; |
| 972 } | 969 } |
| 973 | 970 |
| 974 } // namespace cc | 971 } // namespace cc |
| OLD | NEW |