| Index: cc/tile_manager.cc
|
| diff --git a/cc/tile_manager.cc b/cc/tile_manager.cc
|
| index 68ec45e5f07c309990031a6d50248d2d38be1cdb..f4bf32b7c073e8c298cab9f22c49f82195964b6b 100644
|
| --- a/cc/tile_manager.cc
|
| +++ b/cc/tile_manager.cc
|
| @@ -145,7 +145,6 @@ scoped_ptr<base::Value> TileRasterStateAsValue(
|
| ManagedTileState::ManagedTileState(Tile* tile)
|
| : tile(tile),
|
| can_use_gpu_memory(false),
|
| - can_be_freed(true),
|
| resource_is_being_initialized(false),
|
| contents_swizzled(false),
|
| need_to_gather_pixel_refs(true),
|
| @@ -170,7 +169,7 @@ ManagedTileState::~ManagedTileState() {
|
| scoped_ptr<base::Value> ManagedTileState::AsValue() const {
|
| scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
|
| state->SetBoolean("can_use_gpu_memory", can_use_gpu_memory);
|
| - state->SetBoolean("can_be_freed", can_be_freed);
|
| + state->SetBoolean("can_be_freed", can_be_freed());
|
| state->SetBoolean("has_resource", resource.get() != 0);
|
| state->SetBoolean("resource_is_being_initialized", resource_is_being_initialized);
|
| state->Set("raster_state", TileRasterStateAsValue(raster_state).release());
|
| @@ -416,7 +415,10 @@ void TileManager::ManageTiles() {
|
|
|
| void TileManager::CheckForCompletedTileUploads() {
|
| while (!tiles_with_pending_set_pixels_.empty()) {
|
| - ManagedTileState* mts = tiles_with_pending_set_pixels_.front();
|
| + // Note that a scoped_refptr must be used because the unsetting of
|
| + // cannot_be_freed_ref may cause mts to be unregistered.
|
| + scoped_refptr<ManagedTileState> mts =
|
| + tiles_with_pending_set_pixels_.front();
|
| DCHECK(mts->resource);
|
|
|
| // Set pixel tasks complete in the order they are posted.
|
| @@ -433,7 +435,8 @@ void TileManager::CheckForCompletedTileUploads() {
|
| resource_pool_->resource_provider()->releasePixelBuffer(
|
| mts->resource->id());
|
|
|
| - DidFinishTileInitialization(mts);
|
| + mts->resource_is_being_initialized = false;
|
| + mts->cannot_be_freed_ref = NULL;
|
|
|
| bytes_pending_set_pixels_ -= mts->tile->bytes_consumed_if_allocated();
|
| DidTileRasterStateChange(mts, IDLE_STATE);
|
| @@ -445,7 +448,10 @@ void TileManager::CheckForCompletedTileUploads() {
|
|
|
| void TileManager::AbortPendingTileUploads() {
|
| while (!tiles_with_pending_set_pixels_.empty()) {
|
| - ManagedTileState* mts = tiles_with_pending_set_pixels_.front();
|
| + // Note that a scoped_refptr must be used because the unsetting of
|
| + // cannot_be_freed_ref may cause mts to be unregistered.
|
| + scoped_refptr<ManagedTileState> mts =
|
| + tiles_with_pending_set_pixels_.front();
|
| DCHECK(mts->resource);
|
|
|
| resource_pool_->resource_provider()->abortSetPixels(
|
| @@ -454,7 +460,7 @@ void TileManager::AbortPendingTileUploads() {
|
| mts->resource->id());
|
|
|
| mts->resource_is_being_initialized = false;
|
| - mts->can_be_freed = true;
|
| + mts->cannot_be_freed_ref = NULL;
|
| mts->can_use_gpu_memory = false;
|
| FreeResourcesForTile(mts);
|
|
|
| @@ -593,7 +599,7 @@ void TileManager::AssignGpuMemoryToTiles() {
|
| for (TileVector::iterator it = live_or_allocated_tiles_.begin();
|
| it != live_or_allocated_tiles_.end(); ++it) {
|
| ManagedTileState* mts = *it;
|
| - if (!mts->can_be_freed)
|
| + if (!mts->can_be_freed())
|
| unreleasable_bytes += mts->tile->bytes_consumed_if_allocated();
|
| if (mts->raster_state == WAITING_FOR_RASTER_STATE)
|
| DidTileRasterStateChange(mts, IDLE_STATE);
|
| @@ -605,7 +611,7 @@ void TileManager::AssignGpuMemoryToTiles() {
|
| for (TileVector::iterator it = live_or_allocated_tiles_.begin(); it != live_or_allocated_tiles_.end(); ++it) {
|
| ManagedTileState* mts = *it;
|
| size_t tile_bytes = mts->tile->bytes_consumed_if_allocated();
|
| - if (!mts->can_be_freed)
|
| + if (!mts->can_be_freed())
|
| continue;
|
| if (mts->bin[HIGH_PRIORITY_BIN] == NEVER_BIN &&
|
| mts->bin[LOW_PRIORITY_BIN] == NEVER_BIN) {
|
| @@ -653,7 +659,7 @@ void TileManager::AssignGpuMemoryToTiles() {
|
| }
|
|
|
| void TileManager::FreeResourcesForTile(ManagedTileState* mts) {
|
| - DCHECK(mts->can_be_freed);
|
| + DCHECK(mts->can_be_freed());
|
| if (mts->resource)
|
| resource_pool_->ReleaseResource(mts->resource.Pass());
|
| }
|
| @@ -788,7 +794,7 @@ scoped_ptr<ResourcePool::Resource> TileManager::PrepareTileForRaster(
|
| resource_pool_->resource_provider()->acquirePixelBuffer(resource->id());
|
|
|
| mts->resource_is_being_initialized = true;
|
| - mts->can_be_freed = false;
|
| + mts->cannot_be_freed_ref = mts;
|
|
|
| DidTileRasterStateChange(mts, RASTER_STATE);
|
| return resource.Pass();
|
| @@ -840,7 +846,7 @@ void TileManager::OnRasterCompleted(
|
| // Release raster resources.
|
| resource_pool_->resource_provider()->unmapPixelBuffer(resource->id());
|
|
|
| - mts->can_be_freed = true;
|
| + mts->cannot_be_freed_ref = NULL;
|
|
|
| // Tile can be freed after the completion of the raster task. Call
|
| // AssignGpuMemoryToTiles() to re-assign gpu memory to highest priority
|
| @@ -860,7 +866,7 @@ void TileManager::OnRasterCompleted(
|
| !PlatformColor::sameComponentOrder(mts->tile->format_);
|
|
|
| // Tile resources can't be freed until upload has completed.
|
| - mts->can_be_freed = false;
|
| + mts->cannot_be_freed_ref = mts;
|
|
|
| resource_pool_->resource_provider()->beginSetPixels(resource->id());
|
| has_performed_uploads_since_last_flush_ = true;
|
| @@ -886,12 +892,6 @@ void TileManager::OnRasterTaskCompleted(
|
| manage_tiles_call_count_when_dispatched);
|
| }
|
|
|
| -void TileManager::DidFinishTileInitialization(ManagedTileState* mts) {
|
| - DCHECK(mts->resource);
|
| - mts->resource_is_being_initialized = false;
|
| - mts->can_be_freed = true;
|
| -}
|
| -
|
| void TileManager::DidTileRasterStateChange(
|
| ManagedTileState* mts, TileRasterState state) {
|
| DCHECK_LT(state, NUM_STATES);
|
|
|