| 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/tile_manager.h" | 5 #include "cc/tile_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 default: | 138 default: |
| 139 DCHECK(false) << "Unrecognized TileRasterState value"; | 139 DCHECK(false) << "Unrecognized TileRasterState value"; |
| 140 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 140 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 141 "<unknown TileRasterState value>")); | 141 "<unknown TileRasterState value>")); |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 ManagedTileState::ManagedTileState(Tile* tile) | 145 ManagedTileState::ManagedTileState(Tile* tile) |
| 146 : tile(tile), | 146 : tile(tile), |
| 147 can_use_gpu_memory(false), | 147 can_use_gpu_memory(false), |
| 148 can_be_freed(true), | |
| 149 resource_is_being_initialized(false), | 148 resource_is_being_initialized(false), |
| 150 contents_swizzled(false), | 149 contents_swizzled(false), |
| 151 need_to_gather_pixel_refs(true), | 150 need_to_gather_pixel_refs(true), |
| 152 gpu_memmgr_stats_bin(NEVER_BIN), | 151 gpu_memmgr_stats_bin(NEVER_BIN), |
| 153 raster_state(IDLE_STATE), | 152 raster_state(IDLE_STATE), |
| 154 resolution(NON_IDEAL_RESOLUTION), | 153 resolution(NON_IDEAL_RESOLUTION), |
| 155 time_to_needed_in_seconds(std::numeric_limits<float>::infinity()), | 154 time_to_needed_in_seconds(std::numeric_limits<float>::infinity()), |
| 156 distance_to_visible_in_pixels(std::numeric_limits<float>::infinity()) { | 155 distance_to_visible_in_pixels(std::numeric_limits<float>::infinity()) { |
| 157 for (int i = 0; i < NUM_TREES; ++i) { | 156 for (int i = 0; i < NUM_TREES; ++i) { |
| 158 tree_bin[i] = NEVER_BIN; | 157 tree_bin[i] = NEVER_BIN; |
| 159 bin[i] = NEVER_BIN; | 158 bin[i] = NEVER_BIN; |
| 160 } | 159 } |
| 161 tile->tile_manager()->RegisterManagedTile(this); | 160 tile->tile_manager()->RegisterManagedTile(this); |
| 162 } | 161 } |
| 163 | 162 |
| 164 ManagedTileState::~ManagedTileState() { | 163 ManagedTileState::~ManagedTileState() { |
| 165 tile->tile_manager()->UnregisterManagedTile(this); | 164 tile->tile_manager()->UnregisterManagedTile(this); |
| 166 DCHECK(!resource); | 165 DCHECK(!resource); |
| 167 DCHECK(!resource_is_being_initialized); | 166 DCHECK(!resource_is_being_initialized); |
| 168 } | 167 } |
| 169 | 168 |
| 170 scoped_ptr<base::Value> ManagedTileState::AsValue() const { | 169 scoped_ptr<base::Value> ManagedTileState::AsValue() const { |
| 171 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 170 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 172 state->SetBoolean("can_use_gpu_memory", can_use_gpu_memory); | 171 state->SetBoolean("can_use_gpu_memory", can_use_gpu_memory); |
| 173 state->SetBoolean("can_be_freed", can_be_freed); | 172 state->SetBoolean("can_be_freed", can_be_freed()); |
| 174 state->SetBoolean("has_resource", resource.get() != 0); | 173 state->SetBoolean("has_resource", resource.get() != 0); |
| 175 state->SetBoolean("resource_is_being_initialized", resource_is_being_initializ
ed); | 174 state->SetBoolean("resource_is_being_initialized", resource_is_being_initializ
ed); |
| 176 state->Set("raster_state", TileRasterStateAsValue(raster_state).release()); | 175 state->Set("raster_state", TileRasterStateAsValue(raster_state).release()); |
| 177 state->Set("bin.0", TileManagerBinAsValue(bin[ACTIVE_TREE]).release()); | 176 state->Set("bin.0", TileManagerBinAsValue(bin[ACTIVE_TREE]).release()); |
| 178 state->Set("bin.1", TileManagerBinAsValue(bin[PENDING_TREE]).release()); | 177 state->Set("bin.1", TileManagerBinAsValue(bin[PENDING_TREE]).release()); |
| 179 state->Set("gpu_memmgr_stats_bin", TileManagerBinAsValue(bin[ACTIVE_TREE]).rel
ease()); | 178 state->Set("gpu_memmgr_stats_bin", TileManagerBinAsValue(bin[ACTIVE_TREE]).rel
ease()); |
| 180 state->Set("resolution", TileResolutionAsValue(resolution).release()); | 179 state->Set("resolution", TileResolutionAsValue(resolution).release()); |
| 181 state->Set("time_to_needed_in_seconds", MathUtil::asValueSafely(time_to_needed
_in_seconds).release()); | 180 state->Set("time_to_needed_in_seconds", MathUtil::asValueSafely(time_to_needed
_in_seconds).release()); |
| 182 state->Set("distance_to_visible_in_pixels", MathUtil::asValueSafely(distance_t
o_visible_in_pixels).release()); | 181 state->Set("distance_to_visible_in_pixels", MathUtil::asValueSafely(distance_t
o_visible_in_pixels).release()); |
| 183 return state.PassAs<base::Value>(); | 182 return state.PassAs<base::Value>(); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 | 408 |
| 410 TRACE_EVENT_INSTANT1("cc", "DidManage", "state", | 409 TRACE_EVENT_INSTANT1("cc", "DidManage", "state", |
| 411 ValueToString(BasicStateAsValue())); | 410 ValueToString(BasicStateAsValue())); |
| 412 | 411 |
| 413 // Finally, kick the rasterizer. | 412 // Finally, kick the rasterizer. |
| 414 DispatchMoreTasks(); | 413 DispatchMoreTasks(); |
| 415 } | 414 } |
| 416 | 415 |
| 417 void TileManager::CheckForCompletedTileUploads() { | 416 void TileManager::CheckForCompletedTileUploads() { |
| 418 while (!tiles_with_pending_set_pixels_.empty()) { | 417 while (!tiles_with_pending_set_pixels_.empty()) { |
| 419 ManagedTileState* mts = tiles_with_pending_set_pixels_.front(); | 418 // Note that a scoped_refptr must be used because the unsetting of |
| 419 // cannot_be_freed_ref may cause mts to be unregistered. |
| 420 scoped_refptr<ManagedTileState> mts = |
| 421 tiles_with_pending_set_pixels_.front(); |
| 420 DCHECK(mts->resource); | 422 DCHECK(mts->resource); |
| 421 | 423 |
| 422 // Set pixel tasks complete in the order they are posted. | 424 // Set pixel tasks complete in the order they are posted. |
| 423 if (!resource_pool_->resource_provider()->didSetPixelsComplete( | 425 if (!resource_pool_->resource_provider()->didSetPixelsComplete( |
| 424 mts->resource->id())) { | 426 mts->resource->id())) { |
| 425 break; | 427 break; |
| 426 } | 428 } |
| 427 | 429 |
| 428 if (mts->tile->priority(ACTIVE_TREE).distance_to_visible_in_pixels == 0 && | 430 if (mts->tile->priority(ACTIVE_TREE).distance_to_visible_in_pixels == 0 && |
| 429 mts->tile->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) | 431 mts->tile->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) |
| 430 client_->DidUploadVisibleHighResolutionTile(); | 432 client_->DidUploadVisibleHighResolutionTile(); |
| 431 | 433 |
| 432 // It's now safe to release the pixel buffer. | 434 // It's now safe to release the pixel buffer. |
| 433 resource_pool_->resource_provider()->releasePixelBuffer( | 435 resource_pool_->resource_provider()->releasePixelBuffer( |
| 434 mts->resource->id()); | 436 mts->resource->id()); |
| 435 | 437 |
| 436 DidFinishTileInitialization(mts); | 438 mts->resource_is_being_initialized = false; |
| 439 mts->cannot_be_freed_ref = NULL; |
| 437 | 440 |
| 438 bytes_pending_set_pixels_ -= mts->tile->bytes_consumed_if_allocated(); | 441 bytes_pending_set_pixels_ -= mts->tile->bytes_consumed_if_allocated(); |
| 439 DidTileRasterStateChange(mts, IDLE_STATE); | 442 DidTileRasterStateChange(mts, IDLE_STATE); |
| 440 tiles_with_pending_set_pixels_.pop(); | 443 tiles_with_pending_set_pixels_.pop(); |
| 441 } | 444 } |
| 442 | 445 |
| 443 DispatchMoreTasks(); | 446 DispatchMoreTasks(); |
| 444 } | 447 } |
| 445 | 448 |
| 446 void TileManager::AbortPendingTileUploads() { | 449 void TileManager::AbortPendingTileUploads() { |
| 447 while (!tiles_with_pending_set_pixels_.empty()) { | 450 while (!tiles_with_pending_set_pixels_.empty()) { |
| 448 ManagedTileState* mts = tiles_with_pending_set_pixels_.front(); | 451 // Note that a scoped_refptr must be used because the unsetting of |
| 452 // cannot_be_freed_ref may cause mts to be unregistered. |
| 453 scoped_refptr<ManagedTileState> mts = |
| 454 tiles_with_pending_set_pixels_.front(); |
| 449 DCHECK(mts->resource); | 455 DCHECK(mts->resource); |
| 450 | 456 |
| 451 resource_pool_->resource_provider()->abortSetPixels( | 457 resource_pool_->resource_provider()->abortSetPixels( |
| 452 mts->resource->id()); | 458 mts->resource->id()); |
| 453 resource_pool_->resource_provider()->releasePixelBuffer( | 459 resource_pool_->resource_provider()->releasePixelBuffer( |
| 454 mts->resource->id()); | 460 mts->resource->id()); |
| 455 | 461 |
| 456 mts->resource_is_being_initialized = false; | 462 mts->resource_is_being_initialized = false; |
| 457 mts->can_be_freed = true; | 463 mts->cannot_be_freed_ref = NULL; |
| 458 mts->can_use_gpu_memory = false; | 464 mts->can_use_gpu_memory = false; |
| 459 FreeResourcesForTile(mts); | 465 FreeResourcesForTile(mts); |
| 460 | 466 |
| 461 bytes_pending_set_pixels_ -= mts->tile->bytes_consumed_if_allocated(); | 467 bytes_pending_set_pixels_ -= mts->tile->bytes_consumed_if_allocated(); |
| 462 DidTileRasterStateChange(mts, IDLE_STATE); | 468 DidTileRasterStateChange(mts, IDLE_STATE); |
| 463 tiles_with_pending_set_pixels_.pop(); | 469 tiles_with_pending_set_pixels_.pop(); |
| 464 } | 470 } |
| 465 } | 471 } |
| 466 | 472 |
| 467 void TileManager::GetMemoryStats( | 473 void TileManager::GetMemoryStats( |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 // By clearing the tiles_that_need_to_be_rasterized_ vector and | 592 // By clearing the tiles_that_need_to_be_rasterized_ vector and |
| 587 // tiles_with_image_decoding_tasks_ list above we move all tiles | 593 // tiles_with_image_decoding_tasks_ list above we move all tiles |
| 588 // currently waiting for raster to idle state. | 594 // currently waiting for raster to idle state. |
| 589 // Call DidTileRasterStateChange() for each of these tiles to | 595 // Call DidTileRasterStateChange() for each of these tiles to |
| 590 // have this state change take effect. | 596 // have this state change take effect. |
| 591 // Some memory cannot be released. We figure out how much in this | 597 // Some memory cannot be released. We figure out how much in this |
| 592 // loop as well. | 598 // loop as well. |
| 593 for (TileVector::iterator it = live_or_allocated_tiles_.begin(); | 599 for (TileVector::iterator it = live_or_allocated_tiles_.begin(); |
| 594 it != live_or_allocated_tiles_.end(); ++it) { | 600 it != live_or_allocated_tiles_.end(); ++it) { |
| 595 ManagedTileState* mts = *it; | 601 ManagedTileState* mts = *it; |
| 596 if (!mts->can_be_freed) | 602 if (!mts->can_be_freed()) |
| 597 unreleasable_bytes += mts->tile->bytes_consumed_if_allocated(); | 603 unreleasable_bytes += mts->tile->bytes_consumed_if_allocated(); |
| 598 if (mts->raster_state == WAITING_FOR_RASTER_STATE) | 604 if (mts->raster_state == WAITING_FOR_RASTER_STATE) |
| 599 DidTileRasterStateChange(mts, IDLE_STATE); | 605 DidTileRasterStateChange(mts, IDLE_STATE); |
| 600 } | 606 } |
| 601 | 607 |
| 602 size_t bytes_allocatable = global_state_.memory_limit_in_bytes - unreleasable_
bytes; | 608 size_t bytes_allocatable = global_state_.memory_limit_in_bytes - unreleasable_
bytes; |
| 603 size_t bytes_that_exceeded_memory_budget_in_now_bin = 0; | 609 size_t bytes_that_exceeded_memory_budget_in_now_bin = 0; |
| 604 size_t bytes_left = bytes_allocatable; | 610 size_t bytes_left = bytes_allocatable; |
| 605 for (TileVector::iterator it = live_or_allocated_tiles_.begin(); it != live_or
_allocated_tiles_.end(); ++it) { | 611 for (TileVector::iterator it = live_or_allocated_tiles_.begin(); it != live_or
_allocated_tiles_.end(); ++it) { |
| 606 ManagedTileState* mts = *it; | 612 ManagedTileState* mts = *it; |
| 607 size_t tile_bytes = mts->tile->bytes_consumed_if_allocated(); | 613 size_t tile_bytes = mts->tile->bytes_consumed_if_allocated(); |
| 608 if (!mts->can_be_freed) | 614 if (!mts->can_be_freed()) |
| 609 continue; | 615 continue; |
| 610 if (mts->bin[HIGH_PRIORITY_BIN] == NEVER_BIN && | 616 if (mts->bin[HIGH_PRIORITY_BIN] == NEVER_BIN && |
| 611 mts->bin[LOW_PRIORITY_BIN] == NEVER_BIN) { | 617 mts->bin[LOW_PRIORITY_BIN] == NEVER_BIN) { |
| 612 mts->can_use_gpu_memory = false; | 618 mts->can_use_gpu_memory = false; |
| 613 FreeResourcesForTile(mts); | 619 FreeResourcesForTile(mts); |
| 614 continue; | 620 continue; |
| 615 } | 621 } |
| 616 if (tile_bytes > bytes_left) { | 622 if (tile_bytes > bytes_left) { |
| 617 mts->can_use_gpu_memory = false; | 623 mts->can_use_gpu_memory = false; |
| 618 if (mts->bin[HIGH_PRIORITY_BIN] == NOW_BIN || | 624 if (mts->bin[HIGH_PRIORITY_BIN] == NOW_BIN || |
| (...skipping 27 matching lines...) Expand all Loading... |
| 646 bytes_that_exceeded_memory_budget_in_now_bin; | 652 bytes_that_exceeded_memory_budget_in_now_bin; |
| 647 | 653 |
| 648 // Reverse two tiles_that_need_* vectors such that pop_back gets | 654 // Reverse two tiles_that_need_* vectors such that pop_back gets |
| 649 // the highest priority tile. | 655 // the highest priority tile. |
| 650 std::reverse( | 656 std::reverse( |
| 651 tiles_that_need_to_be_rasterized_.begin(), | 657 tiles_that_need_to_be_rasterized_.begin(), |
| 652 tiles_that_need_to_be_rasterized_.end()); | 658 tiles_that_need_to_be_rasterized_.end()); |
| 653 } | 659 } |
| 654 | 660 |
| 655 void TileManager::FreeResourcesForTile(ManagedTileState* mts) { | 661 void TileManager::FreeResourcesForTile(ManagedTileState* mts) { |
| 656 DCHECK(mts->can_be_freed); | 662 DCHECK(mts->can_be_freed()); |
| 657 if (mts->resource) | 663 if (mts->resource) |
| 658 resource_pool_->ReleaseResource(mts->resource.Pass()); | 664 resource_pool_->ReleaseResource(mts->resource.Pass()); |
| 659 } | 665 } |
| 660 | 666 |
| 661 bool TileManager::CanDispatchRasterTask(ManagedTileState* mts) { | 667 bool TileManager::CanDispatchRasterTask(ManagedTileState* mts) { |
| 662 if (raster_worker_pool_->IsBusy()) | 668 if (raster_worker_pool_->IsBusy()) |
| 663 return false; | 669 return false; |
| 664 size_t new_bytes_pending = bytes_pending_set_pixels_; | 670 size_t new_bytes_pending = bytes_pending_set_pixels_; |
| 665 new_bytes_pending += mts->tile->bytes_consumed_if_allocated(); | 671 new_bytes_pending += mts->tile->bytes_consumed_if_allocated(); |
| 666 return new_bytes_pending <= kMaxPendingUploadBytes && | 672 return new_bytes_pending <= kMaxPendingUploadBytes && |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 | 787 |
| 782 scoped_ptr<ResourcePool::Resource> TileManager::PrepareTileForRaster( | 788 scoped_ptr<ResourcePool::Resource> TileManager::PrepareTileForRaster( |
| 783 ManagedTileState* mts) { | 789 ManagedTileState* mts) { |
| 784 DCHECK(mts->can_use_gpu_memory); | 790 DCHECK(mts->can_use_gpu_memory); |
| 785 scoped_ptr<ResourcePool::Resource> resource = | 791 scoped_ptr<ResourcePool::Resource> resource = |
| 786 resource_pool_->AcquireResource(mts->tile->tile_size_.size(), | 792 resource_pool_->AcquireResource(mts->tile->tile_size_.size(), |
| 787 mts->tile->format_); | 793 mts->tile->format_); |
| 788 resource_pool_->resource_provider()->acquirePixelBuffer(resource->id()); | 794 resource_pool_->resource_provider()->acquirePixelBuffer(resource->id()); |
| 789 | 795 |
| 790 mts->resource_is_being_initialized = true; | 796 mts->resource_is_being_initialized = true; |
| 791 mts->can_be_freed = false; | 797 mts->cannot_be_freed_ref = mts; |
| 792 | 798 |
| 793 DidTileRasterStateChange(mts, RASTER_STATE); | 799 DidTileRasterStateChange(mts, RASTER_STATE); |
| 794 return resource.Pass(); | 800 return resource.Pass(); |
| 795 } | 801 } |
| 796 | 802 |
| 797 void TileManager::DispatchOneRasterTask(scoped_refptr<ManagedTileState> mts) { | 803 void TileManager::DispatchOneRasterTask(scoped_refptr<ManagedTileState> mts) { |
| 798 TRACE_EVENT0("cc", "TileManager::DispatchOneRasterTask"); | 804 TRACE_EVENT0("cc", "TileManager::DispatchOneRasterTask"); |
| 799 scoped_ptr<ResourcePool::Resource> resource = PrepareTileForRaster(mts); | 805 scoped_ptr<ResourcePool::Resource> resource = PrepareTileForRaster(mts); |
| 800 ResourceProvider::ResourceId resource_id = resource->id(); | 806 ResourceProvider::ResourceId resource_id = resource->id(); |
| 801 | 807 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 | 839 |
| 834 void TileManager::OnRasterCompleted( | 840 void TileManager::OnRasterCompleted( |
| 835 scoped_refptr<ManagedTileState> mts, | 841 scoped_refptr<ManagedTileState> mts, |
| 836 scoped_ptr<ResourcePool::Resource> resource, | 842 scoped_ptr<ResourcePool::Resource> resource, |
| 837 int manage_tiles_call_count_when_dispatched) { | 843 int manage_tiles_call_count_when_dispatched) { |
| 838 TRACE_EVENT0("cc", "TileManager::OnRasterCompleted"); | 844 TRACE_EVENT0("cc", "TileManager::OnRasterCompleted"); |
| 839 | 845 |
| 840 // Release raster resources. | 846 // Release raster resources. |
| 841 resource_pool_->resource_provider()->unmapPixelBuffer(resource->id()); | 847 resource_pool_->resource_provider()->unmapPixelBuffer(resource->id()); |
| 842 | 848 |
| 843 mts->can_be_freed = true; | 849 mts->cannot_be_freed_ref = NULL; |
| 844 | 850 |
| 845 // Tile can be freed after the completion of the raster task. Call | 851 // Tile can be freed after the completion of the raster task. Call |
| 846 // AssignGpuMemoryToTiles() to re-assign gpu memory to highest priority | 852 // AssignGpuMemoryToTiles() to re-assign gpu memory to highest priority |
| 847 // tiles if ManageTiles() was called since task was dispatched. The result | 853 // tiles if ManageTiles() was called since task was dispatched. The result |
| 848 // of this could be that this tile is no longer allowed to use gpu | 854 // of this could be that this tile is no longer allowed to use gpu |
| 849 // memory and in that case we need to abort initialization and free all | 855 // memory and in that case we need to abort initialization and free all |
| 850 // associated resources before calling DispatchMoreTasks(). | 856 // associated resources before calling DispatchMoreTasks(). |
| 851 if (manage_tiles_call_count_when_dispatched != manage_tiles_call_count_) | 857 if (manage_tiles_call_count_when_dispatched != manage_tiles_call_count_) |
| 852 AssignGpuMemoryToTiles(); | 858 AssignGpuMemoryToTiles(); |
| 853 | 859 |
| 854 // Finish resource initialization if |can_use_gpu_memory| is true. | 860 // Finish resource initialization if |can_use_gpu_memory| is true. |
| 855 if (mts->can_use_gpu_memory) { | 861 if (mts->can_use_gpu_memory) { |
| 856 // The component order may be bgra if we're uploading bgra pixels to rgba | 862 // The component order may be bgra if we're uploading bgra pixels to rgba |
| 857 // texture. Mark contents as swizzled if image component order is | 863 // texture. Mark contents as swizzled if image component order is |
| 858 // different than texture format. | 864 // different than texture format. |
| 859 mts->contents_swizzled = | 865 mts->contents_swizzled = |
| 860 !PlatformColor::sameComponentOrder(mts->tile->format_); | 866 !PlatformColor::sameComponentOrder(mts->tile->format_); |
| 861 | 867 |
| 862 // Tile resources can't be freed until upload has completed. | 868 // Tile resources can't be freed until upload has completed. |
| 863 mts->can_be_freed = false; | 869 mts->cannot_be_freed_ref = mts; |
| 864 | 870 |
| 865 resource_pool_->resource_provider()->beginSetPixels(resource->id()); | 871 resource_pool_->resource_provider()->beginSetPixels(resource->id()); |
| 866 has_performed_uploads_since_last_flush_ = true; | 872 has_performed_uploads_since_last_flush_ = true; |
| 867 | 873 |
| 868 mts->resource = resource.Pass(); | 874 mts->resource = resource.Pass(); |
| 869 | 875 |
| 870 bytes_pending_set_pixels_ += mts->tile->bytes_consumed_if_allocated(); | 876 bytes_pending_set_pixels_ += mts->tile->bytes_consumed_if_allocated(); |
| 871 DidTileRasterStateChange(mts, SET_PIXELS_STATE); | 877 DidTileRasterStateChange(mts, SET_PIXELS_STATE); |
| 872 tiles_with_pending_set_pixels_.push(mts); | 878 tiles_with_pending_set_pixels_.push(mts); |
| 873 } else { | 879 } else { |
| 874 resource_pool_->resource_provider()->releasePixelBuffer(resource->id()); | 880 resource_pool_->resource_provider()->releasePixelBuffer(resource->id()); |
| 875 resource_pool_->ReleaseResource(resource.Pass()); | 881 resource_pool_->ReleaseResource(resource.Pass()); |
| 876 mts->resource_is_being_initialized = false; | 882 mts->resource_is_being_initialized = false; |
| 877 DidTileRasterStateChange(mts, IDLE_STATE); | 883 DidTileRasterStateChange(mts, IDLE_STATE); |
| 878 } | 884 } |
| 879 } | 885 } |
| 880 | 886 |
| 881 void TileManager::OnRasterTaskCompleted( | 887 void TileManager::OnRasterTaskCompleted( |
| 882 scoped_refptr<ManagedTileState> mts, | 888 scoped_refptr<ManagedTileState> mts, |
| 883 scoped_ptr<ResourcePool::Resource> resource, | 889 scoped_ptr<ResourcePool::Resource> resource, |
| 884 int manage_tiles_call_count_when_dispatched) { | 890 int manage_tiles_call_count_when_dispatched) { |
| 885 OnRasterCompleted(mts, resource.Pass(), | 891 OnRasterCompleted(mts, resource.Pass(), |
| 886 manage_tiles_call_count_when_dispatched); | 892 manage_tiles_call_count_when_dispatched); |
| 887 } | 893 } |
| 888 | 894 |
| 889 void TileManager::DidFinishTileInitialization(ManagedTileState* mts) { | |
| 890 DCHECK(mts->resource); | |
| 891 mts->resource_is_being_initialized = false; | |
| 892 mts->can_be_freed = true; | |
| 893 } | |
| 894 | |
| 895 void TileManager::DidTileRasterStateChange( | 895 void TileManager::DidTileRasterStateChange( |
| 896 ManagedTileState* mts, TileRasterState state) { | 896 ManagedTileState* mts, TileRasterState state) { |
| 897 DCHECK_LT(state, NUM_STATES); | 897 DCHECK_LT(state, NUM_STATES); |
| 898 | 898 |
| 899 for (int i = 0; i < NUM_TREES; ++i) { | 899 for (int i = 0; i < NUM_TREES; ++i) { |
| 900 // Decrement count for current state. | 900 // Decrement count for current state. |
| 901 --raster_state_count_[mts->raster_state][i][mts->tree_bin[i]]; | 901 --raster_state_count_[mts->raster_state][i][mts->tree_bin[i]]; |
| 902 DCHECK_GE(raster_state_count_[mts->raster_state][i][mts->tree_bin[i]], 0); | 902 DCHECK_GE(raster_state_count_[mts->raster_state][i][mts->tree_bin[i]], 0); |
| 903 | 903 |
| 904 // Increment count for new state. | 904 // Increment count for new state. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 decode_begin_time = base::TimeTicks::HighResNow(); | 996 decode_begin_time = base::TimeTicks::HighResNow(); |
| 997 pixel_ref->Decode(); | 997 pixel_ref->Decode(); |
| 998 if (stats) { | 998 if (stats) { |
| 999 stats->totalDeferredImageDecodeCount++; | 999 stats->totalDeferredImageDecodeCount++; |
| 1000 stats->totalDeferredImageDecodeTime += | 1000 stats->totalDeferredImageDecodeTime += |
| 1001 base::TimeTicks::HighResNow() - decode_begin_time; | 1001 base::TimeTicks::HighResNow() - decode_begin_time; |
| 1002 } | 1002 } |
| 1003 } | 1003 } |
| 1004 | 1004 |
| 1005 } // namespace cc | 1005 } // namespace cc |
| OLD | NEW |