| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/image_copy_raster_worker_pool.h" | 5 #include "cc/resources/image_copy_raster_worker_pool.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/debug/trace_event_argument.h" | |
| 11 #include "cc/debug/traced_value.h" | 10 #include "cc/debug/traced_value.h" |
| 12 #include "cc/resources/resource_pool.h" | 11 #include "cc/resources/resource_pool.h" |
| 13 #include "cc/resources/scoped_resource.h" | 12 #include "cc/resources/scoped_resource.h" |
| 14 #include "gpu/command_buffer/client/gles2_interface.h" | 13 #include "gpu/command_buffer/client/gles2_interface.h" |
| 15 | 14 |
| 16 namespace cc { | 15 namespace cc { |
| 17 | 16 |
| 18 // static | 17 // static |
| 19 scoped_ptr<RasterWorkerPool> ImageCopyRasterWorkerPool::Create( | 18 scoped_ptr<RasterWorkerPool> ImageCopyRasterWorkerPool::Create( |
| 20 base::SequencedTaskRunner* task_runner, | 19 base::SequencedTaskRunner* task_runner, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 ScheduleTasksOnOriginThread(this, &graph_); | 134 ScheduleTasksOnOriginThread(this, &graph_); |
| 136 task_graph_runner_->ScheduleTasks(namespace_token_, &graph_); | 135 task_graph_runner_->ScheduleTasks(namespace_token_, &graph_); |
| 137 | 136 |
| 138 raster_finished_task_ = new_raster_finished_task; | 137 raster_finished_task_ = new_raster_finished_task; |
| 139 raster_required_for_activation_finished_task_ = | 138 raster_required_for_activation_finished_task_ = |
| 140 new_raster_required_for_activation_finished_task; | 139 new_raster_required_for_activation_finished_task; |
| 141 | 140 |
| 142 resource_pool_->ReduceResourceUsage(); | 141 resource_pool_->ReduceResourceUsage(); |
| 143 | 142 |
| 144 TRACE_EVENT_ASYNC_STEP_INTO1( | 143 TRACE_EVENT_ASYNC_STEP_INTO1( |
| 145 "cc", "ScheduledTasks", this, "rasterizing", "state", StateAsValue()); | 144 "cc", |
| 145 "ScheduledTasks", |
| 146 this, |
| 147 "rasterizing", |
| 148 "state", |
| 149 TracedValue::FromValue(StateAsValue().release())); |
| 146 } | 150 } |
| 147 | 151 |
| 148 void ImageCopyRasterWorkerPool::CheckForCompletedTasks() { | 152 void ImageCopyRasterWorkerPool::CheckForCompletedTasks() { |
| 149 TRACE_EVENT0("cc", "ImageCopyRasterWorkerPool::CheckForCompletedTasks"); | 153 TRACE_EVENT0("cc", "ImageCopyRasterWorkerPool::CheckForCompletedTasks"); |
| 150 | 154 |
| 151 task_graph_runner_->CollectCompletedTasks(namespace_token_, | 155 task_graph_runner_->CollectCompletedTasks(namespace_token_, |
| 152 &completed_tasks_); | 156 &completed_tasks_); |
| 153 for (Task::Vector::const_iterator it = completed_tasks_.begin(); | 157 for (Task::Vector::const_iterator it = completed_tasks_.begin(); |
| 154 it != completed_tasks_.end(); | 158 it != completed_tasks_.end(); |
| 155 ++it) { | 159 ++it) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 client_->DidFinishRunningTasks(); | 216 client_->DidFinishRunningTasks(); |
| 213 } | 217 } |
| 214 | 218 |
| 215 void ImageCopyRasterWorkerPool::OnRasterRequiredForActivationFinished() { | 219 void ImageCopyRasterWorkerPool::OnRasterRequiredForActivationFinished() { |
| 216 TRACE_EVENT0( | 220 TRACE_EVENT0( |
| 217 "cc", "ImageCopyRasterWorkerPool::OnRasterRequiredForActivationFinished"); | 221 "cc", "ImageCopyRasterWorkerPool::OnRasterRequiredForActivationFinished"); |
| 218 | 222 |
| 219 DCHECK(raster_tasks_required_for_activation_pending_); | 223 DCHECK(raster_tasks_required_for_activation_pending_); |
| 220 raster_tasks_required_for_activation_pending_ = false; | 224 raster_tasks_required_for_activation_pending_ = false; |
| 221 TRACE_EVENT_ASYNC_STEP_INTO1( | 225 TRACE_EVENT_ASYNC_STEP_INTO1( |
| 222 "cc", "ScheduledTasks", this, "rasterizing", "state", StateAsValue()); | 226 "cc", |
| 227 "ScheduledTasks", |
| 228 this, |
| 229 "rasterizing", |
| 230 "state", |
| 231 TracedValue::FromValue(StateAsValue().release())); |
| 223 client_->DidFinishRunningTasksRequiredForActivation(); | 232 client_->DidFinishRunningTasksRequiredForActivation(); |
| 224 } | 233 } |
| 225 | 234 |
| 226 void ImageCopyRasterWorkerPool::FlushCopies() { | 235 void ImageCopyRasterWorkerPool::FlushCopies() { |
| 227 if (!has_performed_copy_since_last_flush_) | 236 if (!has_performed_copy_since_last_flush_) |
| 228 return; | 237 return; |
| 229 | 238 |
| 230 context_provider_->ContextGL()->ShallowFlushCHROMIUM(); | 239 context_provider_->ContextGL()->ShallowFlushCHROMIUM(); |
| 231 has_performed_copy_since_last_flush_ = false; | 240 has_performed_copy_since_last_flush_ = false; |
| 232 } | 241 } |
| 233 | 242 |
| 234 scoped_refptr<base::debug::ConvertableToTraceFormat> | 243 scoped_ptr<base::Value> ImageCopyRasterWorkerPool::StateAsValue() const { |
| 235 ImageCopyRasterWorkerPool::StateAsValue() const { | 244 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); |
| 236 scoped_refptr<base::debug::TracedValue> state = | |
| 237 new base::debug::TracedValue(); | |
| 238 | 245 |
| 239 state->SetInteger("pending_count", raster_task_states_.size()); | 246 state->SetInteger("pending_count", raster_task_states_.size()); |
| 240 state->SetBoolean("tasks_required_for_activation_pending", | 247 state->SetBoolean("tasks_required_for_activation_pending", |
| 241 raster_tasks_required_for_activation_pending_); | 248 raster_tasks_required_for_activation_pending_); |
| 242 state->BeginDictionary("staging_state"); | 249 state->Set("staging_state", StagingStateAsValue().release()); |
| 243 StagingStateAsValueInto(state.get()); | |
| 244 state->EndDictionary(); | |
| 245 | 250 |
| 246 return state; | 251 return state.PassAs<base::Value>(); |
| 247 } | 252 } |
| 248 void ImageCopyRasterWorkerPool::StagingStateAsValueInto( | 253 scoped_ptr<base::Value> ImageCopyRasterWorkerPool::StagingStateAsValue() const { |
| 249 base::debug::TracedValue* staging_state) const { | 254 scoped_ptr<base::DictionaryValue> staging_state(new base::DictionaryValue); |
| 255 |
| 250 staging_state->SetInteger("staging_resource_count", | 256 staging_state->SetInteger("staging_resource_count", |
| 251 resource_pool_->total_resource_count()); | 257 resource_pool_->total_resource_count()); |
| 252 staging_state->SetInteger("bytes_used_for_staging_resources", | 258 staging_state->SetInteger("bytes_used_for_staging_resources", |
| 253 resource_pool_->total_memory_usage_bytes()); | 259 resource_pool_->total_memory_usage_bytes()); |
| 254 staging_state->SetInteger("pending_copy_count", | 260 staging_state->SetInteger("pending_copy_count", |
| 255 resource_pool_->total_resource_count() - | 261 resource_pool_->total_resource_count() - |
| 256 resource_pool_->acquired_resource_count()); | 262 resource_pool_->acquired_resource_count()); |
| 257 staging_state->SetInteger("bytes_pending_copy", | 263 staging_state->SetInteger("bytes_pending_copy", |
| 258 resource_pool_->total_memory_usage_bytes() - | 264 resource_pool_->total_memory_usage_bytes() - |
| 259 resource_pool_->acquired_memory_usage_bytes()); | 265 resource_pool_->acquired_memory_usage_bytes()); |
| 266 |
| 267 return staging_state.PassAs<base::Value>(); |
| 260 } | 268 } |
| 261 | 269 |
| 262 } // namespace cc | 270 } // namespace cc |
| OLD | NEW |