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