| 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" |
| 11 #include "base/debug/trace_event_argument.h" |
| 11 #include "cc/debug/traced_value.h" | 12 #include "cc/debug/traced_value.h" |
| 12 #include "cc/resources/resource.h" | 13 #include "cc/resources/resource.h" |
| 13 #include "gpu/command_buffer/client/gles2_interface.h" | 14 #include "gpu/command_buffer/client/gles2_interface.h" |
| 14 | 15 |
| 15 namespace cc { | 16 namespace cc { |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 const int kCheckForCompletedRasterTasksDelayMs = 6; | 19 const int kCheckForCompletedRasterTasksDelayMs = 6; |
| 19 | 20 |
| 20 const size_t kMaxScheduledRasterTasks = 48; | 21 const size_t kMaxScheduledRasterTasks = 48; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 CheckForCompletedUploads(); | 216 CheckForCompletedUploads(); |
| 216 FlushUploads(); | 217 FlushUploads(); |
| 217 | 218 |
| 218 // Schedule new tasks. | 219 // Schedule new tasks. |
| 219 ScheduleMoreTasks(); | 220 ScheduleMoreTasks(); |
| 220 | 221 |
| 221 // Reschedule check for completed raster tasks. | 222 // Reschedule check for completed raster tasks. |
| 222 check_for_completed_raster_task_notifier_.Schedule(); | 223 check_for_completed_raster_task_notifier_.Schedule(); |
| 223 | 224 |
| 224 TRACE_EVENT_ASYNC_STEP_INTO1( | 225 TRACE_EVENT_ASYNC_STEP_INTO1( |
| 225 "cc", | 226 "cc", "ScheduledTasks", this, StateName(), "state", StateAsValue()); |
| 226 "ScheduledTasks", | |
| 227 this, | |
| 228 StateName(), | |
| 229 "state", | |
| 230 TracedValue::FromValue(StateAsValue().release())); | |
| 231 } | 227 } |
| 232 | 228 |
| 233 void PixelBufferRasterWorkerPool::CheckForCompletedTasks() { | 229 void PixelBufferRasterWorkerPool::CheckForCompletedTasks() { |
| 234 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::CheckForCompletedTasks"); | 230 TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::CheckForCompletedTasks"); |
| 235 | 231 |
| 236 CheckForCompletedRasterizerTasks(); | 232 CheckForCompletedRasterizerTasks(); |
| 237 CheckForCompletedUploads(); | 233 CheckForCompletedUploads(); |
| 238 FlushUploads(); | 234 FlushUploads(); |
| 239 | 235 |
| 240 for (RasterizerTask::Vector::const_iterator it = | 236 for (RasterizerTask::Vector::const_iterator it = |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 should_notify_client_if_no_tasks_required_for_activation_are_pending_ &= | 449 should_notify_client_if_no_tasks_required_for_activation_are_pending_ &= |
| 454 !will_notify_client_that_no_tasks_required_for_activation_are_pending; | 450 !will_notify_client_that_no_tasks_required_for_activation_are_pending; |
| 455 should_notify_client_if_no_tasks_are_pending_ &= | 451 should_notify_client_if_no_tasks_are_pending_ &= |
| 456 !will_notify_client_that_no_tasks_are_pending; | 452 !will_notify_client_that_no_tasks_are_pending; |
| 457 | 453 |
| 458 scheduled_raster_task_count_ = 0; | 454 scheduled_raster_task_count_ = 0; |
| 459 if (PendingRasterTaskCount()) | 455 if (PendingRasterTaskCount()) |
| 460 ScheduleMoreTasks(); | 456 ScheduleMoreTasks(); |
| 461 | 457 |
| 462 TRACE_EVENT_ASYNC_STEP_INTO1( | 458 TRACE_EVENT_ASYNC_STEP_INTO1( |
| 463 "cc", | 459 "cc", "ScheduledTasks", this, StateName(), "state", StateAsValue()); |
| 464 "ScheduledTasks", | |
| 465 this, | |
| 466 StateName(), | |
| 467 "state", | |
| 468 TracedValue::FromValue(StateAsValue().release())); | |
| 469 | 460 |
| 470 // Schedule another check for completed raster tasks while there are | 461 // Schedule another check for completed raster tasks while there are |
| 471 // pending raster tasks or pending uploads. | 462 // pending raster tasks or pending uploads. |
| 472 if (HasPendingTasks()) | 463 if (HasPendingTasks()) |
| 473 check_for_completed_raster_task_notifier_.Schedule(); | 464 check_for_completed_raster_task_notifier_.Schedule(); |
| 474 | 465 |
| 475 // Generate client notifications. | 466 // Generate client notifications. |
| 476 if (will_notify_client_that_no_tasks_required_for_activation_are_pending) { | 467 if (will_notify_client_that_no_tasks_required_for_activation_are_pending) { |
| 477 DCHECK(!HasPendingTasksRequiredForActivation()); | 468 DCHECK(!HasPendingTasksRequiredForActivation()); |
| 478 client_->DidFinishRunningTasksRequiredForActivation(); | 469 client_->DidFinishRunningTasksRequiredForActivation(); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 resource_provider_->BeginSetPixels(raster_task->resource()->id()); | 726 resource_provider_->BeginSetPixels(raster_task->resource()->id()); |
| 736 has_performed_uploads_since_last_flush_ = true; | 727 has_performed_uploads_since_last_flush_ = true; |
| 737 | 728 |
| 738 bytes_pending_upload_ += raster_task->resource()->bytes(); | 729 bytes_pending_upload_ += raster_task->resource()->bytes(); |
| 739 raster_tasks_with_pending_upload_.push_back(raster_task); | 730 raster_tasks_with_pending_upload_.push_back(raster_task); |
| 740 state.type = RasterTaskState::UPLOADING; | 731 state.type = RasterTaskState::UPLOADING; |
| 741 } | 732 } |
| 742 completed_tasks_.clear(); | 733 completed_tasks_.clear(); |
| 743 } | 734 } |
| 744 | 735 |
| 745 scoped_ptr<base::Value> PixelBufferRasterWorkerPool::StateAsValue() const { | 736 scoped_refptr<base::debug::ConvertableToTraceFormat> |
| 746 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); | 737 PixelBufferRasterWorkerPool::StateAsValue() const { |
| 747 | 738 scoped_refptr<base::debug::TracedValue> state = |
| 739 new base::debug::TracedValue(); |
| 748 state->SetInteger("completed_count", completed_raster_tasks_.size()); | 740 state->SetInteger("completed_count", completed_raster_tasks_.size()); |
| 749 state->SetInteger("pending_count", raster_task_states_.size()); | 741 state->SetInteger("pending_count", raster_task_states_.size()); |
| 750 state->SetInteger("pending_upload_count", | 742 state->SetInteger("pending_upload_count", |
| 751 raster_tasks_with_pending_upload_.size()); | 743 raster_tasks_with_pending_upload_.size()); |
| 752 state->SetInteger("pending_required_for_activation_count", | 744 state->SetInteger("pending_required_for_activation_count", |
| 753 raster_tasks_required_for_activation_count_); | 745 raster_tasks_required_for_activation_count_); |
| 754 state->Set("throttle_state", ThrottleStateAsValue().release()); | 746 state->BeginDictionary("throttle_state"); |
| 755 return state.PassAs<base::Value>(); | 747 ThrottleStateAsValueInto(state.get()); |
| 748 state->EndDictionary(); |
| 749 return state; |
| 756 } | 750 } |
| 757 | 751 |
| 758 scoped_ptr<base::Value> PixelBufferRasterWorkerPool::ThrottleStateAsValue() | 752 void PixelBufferRasterWorkerPool::ThrottleStateAsValueInto( |
| 759 const { | 753 base::debug::TracedValue* throttle_state) const { |
| 760 scoped_ptr<base::DictionaryValue> throttle_state(new base::DictionaryValue); | |
| 761 | |
| 762 throttle_state->SetInteger("bytes_available_for_upload", | 754 throttle_state->SetInteger("bytes_available_for_upload", |
| 763 max_bytes_pending_upload_ - bytes_pending_upload_); | 755 max_bytes_pending_upload_ - bytes_pending_upload_); |
| 764 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); | 756 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); |
| 765 throttle_state->SetInteger("scheduled_raster_task_count", | 757 throttle_state->SetInteger("scheduled_raster_task_count", |
| 766 scheduled_raster_task_count_); | 758 scheduled_raster_task_count_); |
| 767 return throttle_state.PassAs<base::Value>(); | |
| 768 } | 759 } |
| 769 | 760 |
| 770 } // namespace cc | 761 } // namespace cc |
| OLD | NEW |