OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/pixel_buffer_raster_worker_pool.h" | 5 #include "cc/resources/pixel_buffer_raster_worker_pool.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/containers/stack_container.h" | 9 #include "base/containers/stack_container.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 DCHECK_EQ(RasterTaskState::COMPLETED, state_it->type); | 254 DCHECK_EQ(RasterTaskState::COMPLETED, state_it->type); |
255 | 255 |
256 std::swap(*state_it, raster_task_states_.back()); | 256 std::swap(*state_it, raster_task_states_.back()); |
257 raster_task_states_.pop_back(); | 257 raster_task_states_.pop_back(); |
258 | 258 |
259 task->RunReplyOnOriginThread(); | 259 task->RunReplyOnOriginThread(); |
260 } | 260 } |
261 completed_raster_tasks_.clear(); | 261 completed_raster_tasks_.clear(); |
262 } | 262 } |
263 | 263 |
264 SkCanvas* PixelBufferRasterWorkerPool::AcquireCanvasForRaster( | 264 RasterBuffer* PixelBufferRasterWorkerPool::AcquireBufferForRaster( |
265 RasterTask* task) { | 265 RasterTask* task) { |
266 DCHECK(std::find_if(raster_task_states_.begin(), | 266 DCHECK(std::find_if(raster_task_states_.begin(), |
267 raster_task_states_.end(), | 267 raster_task_states_.end(), |
268 RasterTaskState::TaskComparator(task)) != | 268 RasterTaskState::TaskComparator(task)) != |
269 raster_task_states_.end()); | 269 raster_task_states_.end()); |
270 resource_provider_->AcquirePixelRasterBuffer(task->resource()->id()); | 270 return resource_provider_->AcquirePixelRasterBuffer(task->resource()->id()); |
271 return resource_provider_->MapPixelRasterBuffer(task->resource()->id()); | |
272 } | 271 } |
273 | 272 |
274 void PixelBufferRasterWorkerPool::ReleaseCanvasForRaster(RasterTask* task) { | 273 void PixelBufferRasterWorkerPool::ReleaseBufferForRaster(RasterTask* task) { |
275 DCHECK(std::find_if(raster_task_states_.begin(), | 274 DCHECK(std::find_if(raster_task_states_.begin(), |
276 raster_task_states_.end(), | 275 raster_task_states_.end(), |
277 RasterTaskState::TaskComparator(task)) != | 276 RasterTaskState::TaskComparator(task)) != |
278 raster_task_states_.end()); | 277 raster_task_states_.end()); |
279 resource_provider_->ReleasePixelRasterBuffer(task->resource()->id()); | 278 resource_provider_->ReleasePixelRasterBuffer(task->resource()->id()); |
280 } | 279 } |
281 | 280 |
282 void PixelBufferRasterWorkerPool::OnRasterFinished() { | 281 void PixelBufferRasterWorkerPool::OnRasterFinished() { |
283 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::OnRasterFinished"); | 282 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::OnRasterFinished"); |
284 | 283 |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 | 678 |
680 RasterTaskState::Vector::iterator state_it = | 679 RasterTaskState::Vector::iterator state_it = |
681 std::find_if(raster_task_states_.begin(), | 680 std::find_if(raster_task_states_.begin(), |
682 raster_task_states_.end(), | 681 raster_task_states_.end(), |
683 RasterTaskState::TaskComparator(raster_task)); | 682 RasterTaskState::TaskComparator(raster_task)); |
684 DCHECK(state_it != raster_task_states_.end()); | 683 DCHECK(state_it != raster_task_states_.end()); |
685 | 684 |
686 RasterTaskState& state = *state_it; | 685 RasterTaskState& state = *state_it; |
687 DCHECK_EQ(RasterTaskState::SCHEDULED, state.type); | 686 DCHECK_EQ(RasterTaskState::SCHEDULED, state.type); |
688 | 687 |
689 // Balanced with MapPixelRasterBuffer() call in AcquireCanvasForRaster(). | 688 if (!raster_task->HasFinishedRunning()) { |
690 bool content_has_changed = resource_provider_->UnmapPixelRasterBuffer( | 689 // When priorites change, a raster task can be canceled as a result of |
691 raster_task->resource()->id()); | 690 // no longer being of high enough priority to fit in our throttled |
692 | 691 // raster task budget. The task has not yet completed in this case. |
693 // |content_has_changed| can be false as result of task being canceled or | |
694 // task implementation deciding not to modify bitmap (ie. analysis of raster | |
695 // commands detected content as a solid color). | |
696 if (!content_has_changed) { | |
697 raster_task->WillComplete(); | 692 raster_task->WillComplete(); |
698 raster_task->CompleteOnOriginThread(this); | 693 raster_task->CompleteOnOriginThread(this); |
699 raster_task->DidComplete(); | 694 raster_task->DidComplete(); |
700 | 695 |
701 if (!raster_task->HasFinishedRunning()) { | 696 RasterTaskQueue::Item::Vector::const_iterator item_it = |
702 // When priorites change, a raster task can be canceled as a result of | 697 std::find_if(raster_tasks_.items.begin(), |
703 // no longer being of high enough priority to fit in our throttled | 698 raster_tasks_.items.end(), |
704 // raster task budget. The task has not yet completed in this case. | 699 RasterTaskQueue::Item::TaskComparator(raster_task)); |
705 RasterTaskQueue::Item::Vector::const_iterator item_it = | 700 if (item_it != raster_tasks_.items.end()) { |
706 std::find_if(raster_tasks_.items.begin(), | 701 state.type = RasterTaskState::UNSCHEDULED; |
707 raster_tasks_.items.end(), | 702 continue; |
708 RasterTaskQueue::Item::TaskComparator(raster_task)); | |
709 if (item_it != raster_tasks_.items.end()) { | |
710 state.type = RasterTaskState::UNSCHEDULED; | |
711 continue; | |
712 } | |
713 } | 703 } |
714 | 704 |
715 DCHECK(std::find(completed_raster_tasks_.begin(), | 705 DCHECK(std::find(completed_raster_tasks_.begin(), |
716 completed_raster_tasks_.end(), | 706 completed_raster_tasks_.end(), |
717 raster_task) == completed_raster_tasks_.end()); | 707 raster_task) == completed_raster_tasks_.end()); |
718 completed_raster_tasks_.push_back(raster_task); | 708 completed_raster_tasks_.push_back(raster_task); |
719 state.type = RasterTaskState::COMPLETED; | 709 state.type = RasterTaskState::COMPLETED; |
720 DCHECK_LE(static_cast<size_t>(state.required_for_activation), | 710 DCHECK_LE(static_cast<size_t>(state.required_for_activation), |
721 raster_tasks_required_for_activation_count_); | 711 raster_tasks_required_for_activation_count_); |
722 raster_tasks_required_for_activation_count_ -= | 712 raster_tasks_required_for_activation_count_ -= |
723 state.required_for_activation; | 713 state.required_for_activation; |
724 continue; | 714 continue; |
725 } | 715 } |
726 | 716 |
727 DCHECK(raster_task->HasFinishedRunning()); | |
728 | |
729 resource_provider_->BeginSetPixels(raster_task->resource()->id()); | 717 resource_provider_->BeginSetPixels(raster_task->resource()->id()); |
730 has_performed_uploads_since_last_flush_ = true; | 718 has_performed_uploads_since_last_flush_ = true; |
731 | 719 |
732 bytes_pending_upload_ += raster_task->resource()->bytes(); | 720 bytes_pending_upload_ += raster_task->resource()->bytes(); |
733 raster_tasks_with_pending_upload_.push_back(raster_task); | 721 raster_tasks_with_pending_upload_.push_back(raster_task); |
734 state.type = RasterTaskState::UPLOADING; | 722 state.type = RasterTaskState::UPLOADING; |
735 } | 723 } |
736 completed_tasks_.clear(); | 724 completed_tasks_.clear(); |
737 } | 725 } |
738 | 726 |
(...skipping 16 matching lines...) Expand all Loading... |
755 void PixelBufferRasterWorkerPool::ThrottleStateAsValueInto( | 743 void PixelBufferRasterWorkerPool::ThrottleStateAsValueInto( |
756 base::debug::TracedValue* throttle_state) const { | 744 base::debug::TracedValue* throttle_state) const { |
757 throttle_state->SetInteger("bytes_available_for_upload", | 745 throttle_state->SetInteger("bytes_available_for_upload", |
758 max_bytes_pending_upload_ - bytes_pending_upload_); | 746 max_bytes_pending_upload_ - bytes_pending_upload_); |
759 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); | 747 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); |
760 throttle_state->SetInteger("scheduled_raster_task_count", | 748 throttle_state->SetInteger("scheduled_raster_task_count", |
761 scheduled_raster_task_count_); | 749 scheduled_raster_task_count_); |
762 } | 750 } |
763 | 751 |
764 } // namespace cc | 752 } // namespace cc |
OLD | NEW |