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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
676 | 675 |
677 RasterTaskState::Vector::iterator state_it = | 676 RasterTaskState::Vector::iterator state_it = |
678 std::find_if(raster_task_states_.begin(), | 677 std::find_if(raster_task_states_.begin(), |
679 raster_task_states_.end(), | 678 raster_task_states_.end(), |
680 RasterTaskState::TaskComparator(raster_task)); | 679 RasterTaskState::TaskComparator(raster_task)); |
681 DCHECK(state_it != raster_task_states_.end()); | 680 DCHECK(state_it != raster_task_states_.end()); |
682 | 681 |
683 RasterTaskState& state = *state_it; | 682 RasterTaskState& state = *state_it; |
684 DCHECK_EQ(RasterTaskState::SCHEDULED, state.type); | 683 DCHECK_EQ(RasterTaskState::SCHEDULED, state.type); |
685 | 684 |
686 // Balanced with MapPixelRasterBuffer() call in AcquireCanvasForRaster(). | 685 if (!raster_task->HasFinishedRunning()) { |
reveman
2014/08/15 11:54:31
Should we release the raster buffer in this case?
auygun
2014/08/15 12:24:19
Buffer is relased in RasterTaskImpl::CompleteOnOri
reveman
2014/08/15 13:59:34
Acknowledged.
| |
687 bool content_has_changed = resource_provider_->UnmapPixelRasterBuffer( | 686 // When priorites change, a raster task can be canceled as a result of |
688 raster_task->resource()->id()); | 687 // no longer being of high enough priority to fit in our throttled |
689 | 688 // raster task budget. The task has not yet completed in this case. |
690 // |content_has_changed| can be false as result of task being canceled or | 689 RasterTaskQueue::Item::Vector::const_iterator item_it = |
691 // task implementation deciding not to modify bitmap (ie. analysis of raster | 690 std::find_if(raster_tasks_.items.begin(), |
692 // commands detected content as a solid color). | 691 raster_tasks_.items.end(), |
693 if (!content_has_changed) { | 692 RasterTaskQueue::Item::TaskComparator(raster_task)); |
694 raster_task->WillComplete(); | 693 if (item_it != raster_tasks_.items.end()) { |
695 raster_task->CompleteOnOriginThread(this); | 694 raster_task->WillComplete(); |
696 raster_task->DidComplete(); | 695 raster_task->CompleteOnOriginThread(this); |
697 | 696 raster_task->DidComplete(); |
reveman
2014/08/15 11:54:31
These functions need to be called even if the cond
auygun
2014/08/15 12:24:20
Aren't they called later in CheckForCompletedUploa
reveman
2014/08/15 13:59:34
Acknowledged.
| |
698 if (!raster_task->HasFinishedRunning()) { | 697 state.type = RasterTaskState::UNSCHEDULED; |
699 // When priorites change, a raster task can be canceled as a result of | 698 continue; |
700 // no longer being of high enough priority to fit in our throttled | |
701 // raster task budget. The task has not yet completed in this case. | |
702 RasterTaskQueue::Item::Vector::const_iterator item_it = | |
703 std::find_if(raster_tasks_.items.begin(), | |
704 raster_tasks_.items.end(), | |
705 RasterTaskQueue::Item::TaskComparator(raster_task)); | |
706 if (item_it != raster_tasks_.items.end()) { | |
707 state.type = RasterTaskState::UNSCHEDULED; | |
708 continue; | |
709 } | |
710 } | 699 } |
711 | |
712 DCHECK(std::find(completed_raster_tasks_.begin(), | |
713 completed_raster_tasks_.end(), | |
714 raster_task) == completed_raster_tasks_.end()); | |
715 completed_raster_tasks_.push_back(raster_task); | |
716 state.type = RasterTaskState::COMPLETED; | |
717 DCHECK_LE(static_cast<size_t>(state.required_for_activation), | |
718 raster_tasks_required_for_activation_count_); | |
719 raster_tasks_required_for_activation_count_ -= | |
720 state.required_for_activation; | |
reveman
2014/08/15 11:54:31
We still need this code in case the task is no lon
auygun
2014/08/15 12:24:20
Now the task is pushed into raster_tasks_with_pend
reveman
2014/08/15 13:59:34
It seemed a bit awkward to attempt an upload when
auygun
2014/08/15 15:08:23
Ok. I think it's better to not to attempt an uploa
| |
721 continue; | |
722 } | 700 } |
723 | 701 |
724 DCHECK(raster_task->HasFinishedRunning()); | |
725 | |
726 resource_provider_->BeginSetPixels(raster_task->resource()->id()); | 702 resource_provider_->BeginSetPixels(raster_task->resource()->id()); |
727 has_performed_uploads_since_last_flush_ = true; | 703 has_performed_uploads_since_last_flush_ = true; |
728 | 704 |
729 bytes_pending_upload_ += raster_task->resource()->bytes(); | 705 bytes_pending_upload_ += raster_task->resource()->bytes(); |
730 raster_tasks_with_pending_upload_.push_back(raster_task); | 706 raster_tasks_with_pending_upload_.push_back(raster_task); |
731 state.type = RasterTaskState::UPLOADING; | 707 state.type = RasterTaskState::UPLOADING; |
732 } | 708 } |
733 completed_tasks_.clear(); | 709 completed_tasks_.clear(); |
734 } | 710 } |
735 | 711 |
(...skipping 16 matching lines...) Expand all Loading... | |
752 void PixelBufferRasterWorkerPool::ThrottleStateAsValueInto( | 728 void PixelBufferRasterWorkerPool::ThrottleStateAsValueInto( |
753 base::debug::TracedValue* throttle_state) const { | 729 base::debug::TracedValue* throttle_state) const { |
754 throttle_state->SetInteger("bytes_available_for_upload", | 730 throttle_state->SetInteger("bytes_available_for_upload", |
755 max_bytes_pending_upload_ - bytes_pending_upload_); | 731 max_bytes_pending_upload_ - bytes_pending_upload_); |
756 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); | 732 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); |
757 throttle_state->SetInteger("scheduled_raster_task_count", | 733 throttle_state->SetInteger("scheduled_raster_task_count", |
758 scheduled_raster_task_count_); | 734 scheduled_raster_task_count_); |
759 } | 735 } |
760 | 736 |
761 } // namespace cc | 737 } // namespace cc |
OLD | NEW |