diff options
author | alexst@chromium.org <alexst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-21 05:40:48 +0000 |
---|---|---|
committer | alexst@chromium.org <alexst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-21 05:40:48 +0000 |
commit | 0a3040277d432ddcde310cc6c0f78850d7453e2a (patch) | |
tree | 3e3d312651b9e4efe69c6739424fe4fbb3eed0b4 /cc/resources | |
parent | f9132e9700af6f4ff57fc7b063ff6fe27299f30a (diff) | |
download | chromium_src-0a3040277d432ddcde310cc6c0f78850d7453e2a.zip chromium_src-0a3040277d432ddcde310cc6c0f78850d7453e2a.tar.gz chromium_src-0a3040277d432ddcde310cc6c0f78850d7453e2a.tar.bz2 |
cc: Chromify resource_update_queue
BUG=
Review URL: https://chromiumcodereview.appspot.com/12962007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189530 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/resources')
-rw-r--r-- | cc/resources/bitmap_content_layer_updater.cc | 4 | ||||
-rw-r--r-- | cc/resources/bitmap_skpicture_content_layer_updater.cc | 4 | ||||
-rw-r--r-- | cc/resources/image_layer_updater.cc | 4 | ||||
-rw-r--r-- | cc/resources/prioritized_resource_unittest.cc | 15 | ||||
-rw-r--r-- | cc/resources/resource_update_controller.cc | 24 | ||||
-rw-r--r-- | cc/resources/resource_update_controller_unittest.cc | 4 | ||||
-rw-r--r-- | cc/resources/resource_update_queue.cc | 83 | ||||
-rw-r--r-- | cc/resources/resource_update_queue.h | 40 | ||||
-rw-r--r-- | cc/resources/skpicture_content_layer_updater.cc | 4 |
9 files changed, 85 insertions, 97 deletions
diff --git a/cc/resources/bitmap_content_layer_updater.cc b/cc/resources/bitmap_content_layer_updater.cc index 8a65e9e..7d11e34 100644 --- a/cc/resources/bitmap_content_layer_updater.cc +++ b/cc/resources/bitmap_content_layer_updater.cc @@ -84,9 +84,9 @@ void BitmapContentLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue, source_rect, dest_offset); if (partial_update) - queue->appendPartialUpload(upload); + queue->AppendPartialUpload(upload); else - queue->appendFullUpload(upload); + queue->AppendFullUpload(upload); } void BitmapContentLayerUpdater::SetOpaque(bool opaque) { diff --git a/cc/resources/bitmap_skpicture_content_layer_updater.cc b/cc/resources/bitmap_skpicture_content_layer_updater.cc index e2fdc04..139a190 100644 --- a/cc/resources/bitmap_skpicture_content_layer_updater.cc +++ b/cc/resources/bitmap_skpicture_content_layer_updater.cc @@ -41,9 +41,9 @@ void BitmapSkPictureContentLayerUpdater::Resource::Update( ResourceUpdate upload = ResourceUpdate::Create( texture(), &bitmap_, source_rect, source_rect, dest_offset); if (partial_update) - queue->appendPartialUpload(upload); + queue->AppendPartialUpload(upload); else - queue->appendFullUpload(upload); + queue->AppendFullUpload(upload); } scoped_refptr<BitmapSkPictureContentLayerUpdater> diff --git a/cc/resources/image_layer_updater.cc b/cc/resources/image_layer_updater.cc index 5390d90..4422bc4 100644 --- a/cc/resources/image_layer_updater.cc +++ b/cc/resources/image_layer_updater.cc @@ -52,9 +52,9 @@ void ImageLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue, ResourceUpdate upload = ResourceUpdate::Create( texture, &bitmap_, image_rect, clipped_source_rect, clipped_dest_offset); if (partial_update) - queue->appendPartialUpload(upload); + queue->AppendPartialUpload(upload); else - queue->appendFullUpload(upload); + queue->AppendFullUpload(upload); } } diff --git a/cc/resources/prioritized_resource_unittest.cc b/cc/resources/prioritized_resource_unittest.cc index 51e7df8..17dd746 100644 --- a/cc/resources/prioritized_resource_unittest.cc +++ b/cc/resources/prioritized_resource_unittest.cc @@ -681,28 +681,27 @@ TEST_F(PrioritizedResourceTest, ClearUploadsToEvictedResources) { for (size_t i = 0; i < max_textures; ++i) { const ResourceUpdate upload = ResourceUpdate::Create( textures[i].get(), NULL, gfx::Rect(), gfx::Rect(), gfx::Vector2d()); - queue.appendFullUpload(upload); + queue.AppendFullUpload(upload); } // Make sure that we have backings for all of the textures. for (size_t i = 0; i < max_textures; ++i) EXPECT_TRUE(textures[i]->have_backing_texture()); - queue.clearUploadsToEvictedResources(); - EXPECT_EQ(4, queue.fullUploadSize()); + queue.ClearUploadsToEvictedResources(); + EXPECT_EQ(4, queue.FullUploadSize()); resource_manager->ReduceMemoryOnImplThread( TexturesMemorySize(1), PriorityCalculator::AllowEverythingCutoff(), ResourceProvider()); - queue.clearUploadsToEvictedResources(); - EXPECT_EQ(1, queue.fullUploadSize()); + queue.ClearUploadsToEvictedResources(); + EXPECT_EQ(1, queue.FullUploadSize()); resource_manager->ReduceMemoryOnImplThread( 0, PriorityCalculator::AllowEverythingCutoff(), ResourceProvider()); - queue.clearUploadsToEvictedResources(); - EXPECT_EQ(0, queue.fullUploadSize()); - + queue.ClearUploadsToEvictedResources(); + EXPECT_EQ(0, queue.FullUploadSize()); } TEST_F(PrioritizedResourceTest, UsageStatistics) { diff --git a/cc/resources/resource_update_controller.cc b/cc/resources/resource_update_controller.cc index b568f5c..1dc36b5 100644 --- a/cc/resources/resource_update_controller.cc +++ b/cc/resources/resource_update_controller.cc @@ -107,7 +107,7 @@ void ResourceUpdateController::PerformMoreUpdates( } void ResourceUpdateController::DiscardUploadsToEvictedResources() { - queue_->clearUploadsToEvictedResources(); + queue_->ClearUploadsToEvictedResources(); } void ResourceUpdateController::UpdateTexture(ResourceUpdate update) { @@ -183,18 +183,18 @@ void ResourceUpdateController::UpdateTexture(ResourceUpdate update) { } void ResourceUpdateController::Finalize() { - while (queue_->fullUploadSize()) - UpdateTexture(queue_->takeFirstFullUpload()); + while (queue_->FullUploadSize()) + UpdateTexture(queue_->TakeFirstFullUpload()); - while (queue_->partialUploadSize()) - UpdateTexture(queue_->takeFirstPartialUpload()); + while (queue_->PartialUploadSize()) + UpdateTexture(queue_->TakeFirstPartialUpload()); resource_provider_->FlushUploads(); - if (queue_->copySize()) { + if (queue_->CopySize()) { TextureCopier* copier = resource_provider_->texture_copier(); - while (queue_->copySize()) - copier->CopyTexture(queue_->takeFirstCopy()); + while (queue_->CopySize()) + copier->CopyTexture(queue_->TakeFirstCopy()); // If we've performed any texture copies, we need to insert a flush // here into the compositor context before letting the main thread @@ -234,7 +234,7 @@ base::TimeDelta ResourceUpdateController::PendingUpdateTime() const { bool ResourceUpdateController::UpdateMoreTexturesIfEnoughTimeRemaining() { while (resource_provider_->NumBlockingUploads() < MaxBlockingUpdates()) { - if (!queue_->fullUploadSize()) + if (!queue_->FullUploadSize()) return false; if (!time_limit_.is_null()) { @@ -261,13 +261,13 @@ bool ResourceUpdateController::UpdateMoreTexturesIfEnoughTimeRemaining() { void ResourceUpdateController::UpdateMoreTexturesNow() { size_t uploads = std::min( - queue_->fullUploadSize(), UpdateMoreTexturesSize()); + queue_->FullUploadSize(), UpdateMoreTexturesSize()); if (!uploads) return; - while (queue_->fullUploadSize() && uploads--) - UpdateTexture(queue_->takeFirstFullUpload()); + while (queue_->FullUploadSize() && uploads--) + UpdateTexture(queue_->TakeFirstFullUpload()); resource_provider_->FlushUploads(); } diff --git a/cc/resources/resource_update_controller_unittest.cc b/cc/resources/resource_update_controller_unittest.cc index be87115..bd8f46f 100644 --- a/cc/resources/resource_update_controller_unittest.cc +++ b/cc/resources/resource_update_controller_unittest.cc @@ -146,7 +146,7 @@ protected: const ResourceUpdate upload = ResourceUpdate::Create( textures_[textureIndex].get(), &m_bitmap, rect, rect, gfx::Vector2d()); for (int i = 0; i < count; i++) - m_queue->appendFullUpload(upload); + m_queue->AppendFullUpload(upload); } void appendFullUploadsToUpdateQueue(int count) @@ -163,7 +163,7 @@ protected: const ResourceUpdate upload = ResourceUpdate::Create( textures_[textureIndex].get(), &m_bitmap, rect, rect, gfx::Vector2d()); for (int i = 0; i < count; i++) - m_queue->appendPartialUpload(upload); + m_queue->AppendPartialUpload(upload); } void appendPartialUploadsToUpdateQueue(int count) diff --git a/cc/resources/resource_update_queue.cc b/cc/resources/resource_update_queue.cc index e94f218..18a0fdb 100644 --- a/cc/resources/resource_update_queue.cc +++ b/cc/resources/resource_update_queue.cc @@ -8,71 +8,60 @@ namespace cc { -ResourceUpdateQueue::ResourceUpdateQueue() -{ -} +ResourceUpdateQueue::ResourceUpdateQueue() {} -ResourceUpdateQueue::~ResourceUpdateQueue() -{ -} +ResourceUpdateQueue::~ResourceUpdateQueue() {} -void ResourceUpdateQueue::appendFullUpload(const ResourceUpdate& upload) -{ - m_fullEntries.push_back(upload); +void ResourceUpdateQueue::AppendFullUpload(const ResourceUpdate& upload) { + full_entries_.push_back(upload); } -void ResourceUpdateQueue::appendPartialUpload(const ResourceUpdate& upload) -{ - m_partialEntries.push_back(upload); +void ResourceUpdateQueue::AppendPartialUpload(const ResourceUpdate& upload) { + partial_entries_.push_back(upload); } -void ResourceUpdateQueue::appendCopy(TextureCopier::Parameters copy) -{ - m_copyEntries.push_back(copy); +void ResourceUpdateQueue::AppendCopy(TextureCopier::Parameters copy) { + copy_entries_.push_back(copy); } -void ResourceUpdateQueue::clearUploadsToEvictedResources() -{ - clearUploadsToEvictedResources(m_fullEntries); - clearUploadsToEvictedResources(m_partialEntries); +void ResourceUpdateQueue::ClearUploadsToEvictedResources() { + ClearUploadsToEvictedResources(&full_entries_); + ClearUploadsToEvictedResources(&partial_entries_); } -void ResourceUpdateQueue::clearUploadsToEvictedResources(std::deque<ResourceUpdate>& entryQueue) -{ - std::deque<ResourceUpdate> temp; - entryQueue.swap(temp); - while (temp.size()) { - ResourceUpdate upload = temp.front(); - temp.pop_front(); - if (!upload.texture->BackingResourceWasEvicted()) - entryQueue.push_back(upload); - } +void ResourceUpdateQueue::ClearUploadsToEvictedResources( + std::deque<ResourceUpdate>* entry_queue) { + std::deque<ResourceUpdate> temp; + entry_queue->swap(temp); + while (temp.size()) { + ResourceUpdate upload = temp.front(); + temp.pop_front(); + if (!upload.texture->BackingResourceWasEvicted()) + entry_queue->push_back(upload); + } } -ResourceUpdate ResourceUpdateQueue::takeFirstFullUpload() -{ - ResourceUpdate first = m_fullEntries.front(); - m_fullEntries.pop_front(); - return first; +ResourceUpdate ResourceUpdateQueue::TakeFirstFullUpload() { + ResourceUpdate first = full_entries_.front(); + full_entries_.pop_front(); + return first; } -ResourceUpdate ResourceUpdateQueue::takeFirstPartialUpload() -{ - ResourceUpdate first = m_partialEntries.front(); - m_partialEntries.pop_front(); - return first; +ResourceUpdate ResourceUpdateQueue::TakeFirstPartialUpload() { + ResourceUpdate first = partial_entries_.front(); + partial_entries_.pop_front(); + return first; } -TextureCopier::Parameters ResourceUpdateQueue::takeFirstCopy() -{ - TextureCopier::Parameters first = m_copyEntries.front(); - m_copyEntries.pop_front(); - return first; +TextureCopier::Parameters ResourceUpdateQueue::TakeFirstCopy() { + TextureCopier::Parameters first = copy_entries_.front(); + copy_entries_.pop_front(); + return first; } -bool ResourceUpdateQueue::hasMoreUpdates() const -{ - return m_fullEntries.size() || m_partialEntries.size() || m_copyEntries.size(); +bool ResourceUpdateQueue::HasMoreUpdates() const { + return !full_entries_.empty() || !partial_entries_.empty() || + !copy_entries_.empty(); } } // namespace cc diff --git a/cc/resources/resource_update_queue.h b/cc/resources/resource_update_queue.h index c8bb69b..45a983a 100644 --- a/cc/resources/resource_update_queue.h +++ b/cc/resources/resource_update_queue.h @@ -14,33 +14,33 @@ namespace cc { class CC_EXPORT ResourceUpdateQueue { -public: - ResourceUpdateQueue(); - virtual ~ResourceUpdateQueue(); + public: + ResourceUpdateQueue(); + virtual ~ResourceUpdateQueue(); - void appendFullUpload(const ResourceUpdate&); - void appendPartialUpload(const ResourceUpdate&); - void appendCopy(TextureCopier::Parameters); + void AppendFullUpload(const ResourceUpdate& upload); + void AppendPartialUpload(const ResourceUpdate& upload); + void AppendCopy(TextureCopier::Parameters copy); - void clearUploadsToEvictedResources(); + void ClearUploadsToEvictedResources(); - ResourceUpdate takeFirstFullUpload(); - ResourceUpdate takeFirstPartialUpload(); - TextureCopier::Parameters takeFirstCopy(); + ResourceUpdate TakeFirstFullUpload(); + ResourceUpdate TakeFirstPartialUpload(); + TextureCopier::Parameters TakeFirstCopy(); - size_t fullUploadSize() const { return m_fullEntries.size(); } - size_t partialUploadSize() const { return m_partialEntries.size(); } - size_t copySize() const { return m_copyEntries.size(); } + size_t FullUploadSize() const { return full_entries_.size(); } + size_t PartialUploadSize() const { return partial_entries_.size(); } + size_t CopySize() const { return copy_entries_.size(); } - bool hasMoreUpdates() const; + bool HasMoreUpdates() const; -private: - void clearUploadsToEvictedResources(std::deque<ResourceUpdate>& entryQueue); - std::deque<ResourceUpdate> m_fullEntries; - std::deque<ResourceUpdate> m_partialEntries; - std::deque<TextureCopier::Parameters> m_copyEntries; + private: + void ClearUploadsToEvictedResources(std::deque<ResourceUpdate>* entry_queue); + std::deque<ResourceUpdate> full_entries_; + std::deque<ResourceUpdate> partial_entries_; + std::deque<TextureCopier::Parameters> copy_entries_; - DISALLOW_COPY_AND_ASSIGN(ResourceUpdateQueue); + DISALLOW_COPY_AND_ASSIGN(ResourceUpdateQueue); }; } diff --git a/cc/resources/skpicture_content_layer_updater.cc b/cc/resources/skpicture_content_layer_updater.cc index 1af05f9..0ca6ea8 100644 --- a/cc/resources/skpicture_content_layer_updater.cc +++ b/cc/resources/skpicture_content_layer_updater.cc @@ -76,9 +76,9 @@ void SkPictureContentLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue, ResourceUpdate upload = ResourceUpdate::CreateFromPicture( texture, &picture_, content_rect(), source_rect, dest_offset); if (partial_update) - queue->appendPartialUpload(upload); + queue->AppendPartialUpload(upload); else - queue->appendFullUpload(upload); + queue->AppendFullUpload(upload); } void SkPictureContentLayerUpdater::SetOpaque(bool opaque) { |