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/raster/pixel_buffer_tile_task_worker_pool.h" | 5 #include "cc/raster/pixel_buffer_tile_task_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/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 for (RasterTask::Vector::const_iterator it = | 429 for (RasterTask::Vector::const_iterator it = |
430 tasks_with_completed_uploads.begin(); | 430 tasks_with_completed_uploads.begin(); |
431 it != tasks_with_completed_uploads.end(); ++it) { | 431 it != tasks_with_completed_uploads.end(); ++it) { |
432 RasterTask* task = it->get(); | 432 RasterTask* task = it->get(); |
433 RasterTaskState::Vector::iterator state_it = | 433 RasterTaskState::Vector::iterator state_it = |
434 std::find_if(raster_task_states_.begin(), raster_task_states_.end(), | 434 std::find_if(raster_task_states_.begin(), raster_task_states_.end(), |
435 RasterTaskState::TaskComparator(task)); | 435 RasterTaskState::TaskComparator(task)); |
436 DCHECK(state_it != raster_task_states_.end()); | 436 DCHECK(state_it != raster_task_states_.end()); |
437 RasterTaskState& state = *state_it; | 437 RasterTaskState& state = *state_it; |
438 | 438 |
439 // We can use UncheckedMemorySizeBytes here, since these tasks come from | 439 // We can use UncheckedSizeInBytes here, since these tasks come from tiles, |
440 // tiles, the size of which is controlled by the compositor. | 440 // the size of which is controlled by the compositor. |
441 bytes_pending_upload_ -= Resource::UncheckedMemorySizeBytes( | 441 bytes_pending_upload_ -= ResourceUtil::UncheckedSizeInBytes( |
442 task->resource()->size(), task->resource()->format()); | 442 task->resource()->size(), task->resource()->format()); |
443 | 443 |
444 task->WillComplete(); | 444 task->WillComplete(); |
445 task->CompleteOnOriginThread(this); | 445 task->CompleteOnOriginThread(this); |
446 task->DidComplete(); | 446 task->DidComplete(); |
447 | 447 |
448 DCHECK(std::find(completed_raster_tasks_.begin(), | 448 DCHECK(std::find(completed_raster_tasks_.begin(), |
449 completed_raster_tasks_.end(), | 449 completed_raster_tasks_.end(), |
450 task) == completed_raster_tasks_.end()); | 450 task) == completed_raster_tasks_.end()); |
451 completed_raster_tasks_.push_back(task); | 451 completed_raster_tasks_.push_back(task); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 DCHECK(std::find(completed_raster_tasks_.begin(), | 538 DCHECK(std::find(completed_raster_tasks_.begin(), |
539 completed_raster_tasks_.end(), | 539 completed_raster_tasks_.end(), |
540 task) != completed_raster_tasks_.end()); | 540 task) != completed_raster_tasks_.end()); |
541 continue; | 541 continue; |
542 } | 542 } |
543 | 543 |
544 // All raster tasks need to be throttled by bytes of pending uploads, | 544 // All raster tasks need to be throttled by bytes of pending uploads, |
545 // but if it's the only task allow it to complete no matter what its size, | 545 // but if it's the only task allow it to complete no matter what its size, |
546 // to prevent starvation of the task queue. | 546 // to prevent starvation of the task queue. |
547 size_t new_bytes_pending_upload = bytes_pending_upload; | 547 size_t new_bytes_pending_upload = bytes_pending_upload; |
548 // We can use UncheckedMemorySizeBytes here, since these tasks come from | 548 // We can use UncheckedSizeInBytes here, since these tasks come from tiles, |
549 // tiles, the size of which is controlled by the compositor. | 549 // the size of which is controlled by the compositor. |
550 new_bytes_pending_upload += Resource::UncheckedMemorySizeBytes( | 550 new_bytes_pending_upload += ResourceUtil::UncheckedSizeInBytes( |
551 task->resource()->size(), task->resource()->format()); | 551 task->resource()->size(), task->resource()->format()); |
552 if (new_bytes_pending_upload > max_bytes_pending_upload_ && | 552 if (new_bytes_pending_upload > max_bytes_pending_upload_ && |
553 bytes_pending_upload) { | 553 bytes_pending_upload) { |
554 did_throttle_raster_tasks |= item.task_sets; | 554 did_throttle_raster_tasks |= item.task_sets; |
555 continue; | 555 continue; |
556 } | 556 } |
557 | 557 |
558 // If raster has finished, just update |bytes_pending_upload|. | 558 // If raster has finished, just update |bytes_pending_upload|. |
559 if (state.type == RasterTaskState::UPLOADING) { | 559 if (state.type == RasterTaskState::UPLOADING) { |
560 DCHECK(!task->HasCompleted()); | 560 DCHECK(!task->HasCompleted()); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 // Triggers if the current task belongs to a set that should be empty. | 705 // Triggers if the current task belongs to a set that should be empty. |
706 DCHECK((state.task_sets & ~NonEmptyTaskSetsFromTaskCounts(task_counts_)) | 706 DCHECK((state.task_sets & ~NonEmptyTaskSetsFromTaskCounts(task_counts_)) |
707 .none()); | 707 .none()); |
708 RemoveTaskSetsFromTaskCounts(task_counts_, state.task_sets); | 708 RemoveTaskSetsFromTaskCounts(task_counts_, state.task_sets); |
709 continue; | 709 continue; |
710 } | 710 } |
711 | 711 |
712 resource_provider_->BeginSetPixels(raster_task->resource()->id()); | 712 resource_provider_->BeginSetPixels(raster_task->resource()->id()); |
713 has_performed_uploads_since_last_flush_ = true; | 713 has_performed_uploads_since_last_flush_ = true; |
714 | 714 |
715 // We can use UncheckedMemorySizeBytes here, since these tasks come from | 715 // We can use UncheckedSizeInBytes here, since these tasks come from tiles, |
716 // tiles, the size of which is controlled by the compositor. | 716 // the size of which is controlled by the compositor. |
717 bytes_pending_upload_ += Resource::UncheckedMemorySizeBytes( | 717 bytes_pending_upload_ += ResourceUtil::UncheckedSizeInBytes( |
718 raster_task->resource()->size(), raster_task->resource()->format()); | 718 raster_task->resource()->size(), raster_task->resource()->format()); |
719 raster_tasks_with_pending_upload_.push_back(raster_task); | 719 raster_tasks_with_pending_upload_.push_back(raster_task); |
720 state.type = RasterTaskState::UPLOADING; | 720 state.type = RasterTaskState::UPLOADING; |
721 } | 721 } |
722 completed_tasks_.clear(); | 722 completed_tasks_.clear(); |
723 } | 723 } |
724 | 724 |
725 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 725 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
726 PixelBufferTileTaskWorkerPool::StateAsValue() const { | 726 PixelBufferTileTaskWorkerPool::StateAsValue() const { |
727 scoped_refptr<base::trace_event::TracedValue> state = | 727 scoped_refptr<base::trace_event::TracedValue> state = |
(...skipping 17 matching lines...) Expand all Loading... |
745 throttle_state->SetInteger( | 745 throttle_state->SetInteger( |
746 "bytes_available_for_upload", | 746 "bytes_available_for_upload", |
747 static_cast<int>(max_bytes_pending_upload_ - bytes_pending_upload_)); | 747 static_cast<int>(max_bytes_pending_upload_ - bytes_pending_upload_)); |
748 throttle_state->SetInteger("bytes_pending_upload", | 748 throttle_state->SetInteger("bytes_pending_upload", |
749 static_cast<int>(bytes_pending_upload_)); | 749 static_cast<int>(bytes_pending_upload_)); |
750 throttle_state->SetInteger("scheduled_raster_task_count", | 750 throttle_state->SetInteger("scheduled_raster_task_count", |
751 static_cast<int>(scheduled_raster_task_count_)); | 751 static_cast<int>(scheduled_raster_task_count_)); |
752 } | 752 } |
753 | 753 |
754 } // namespace cc | 754 } // namespace cc |
OLD | NEW |