| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "gpu/command_buffer/service/gpu_scheduler.h" | 5 #include "gpu/command_buffer/service/gpu_scheduler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 bool GpuScheduler::IsScheduled() { | 165 bool GpuScheduler::IsScheduled() { |
| 166 return unscheduled_count_ == 0; | 166 return unscheduled_count_ == 0; |
| 167 } | 167 } |
| 168 | 168 |
| 169 bool GpuScheduler::HasMoreWork() { | 169 bool GpuScheduler::HasMoreWork() { |
| 170 return !unschedule_fences_.empty() || | 170 return !unschedule_fences_.empty() || |
| 171 (decoder_ && decoder_->ProcessPendingQueries()); | 171 (decoder_ && decoder_->ProcessPendingQueries()) || |
| 172 HasMoreIdleWork(); |
| 172 } | 173 } |
| 173 | 174 |
| 174 void GpuScheduler::SetSchedulingChangedCallback( | 175 void GpuScheduler::SetSchedulingChangedCallback( |
| 175 const SchedulingChangedCallback& callback) { | 176 const SchedulingChangedCallback& callback) { |
| 176 scheduling_changed_callback_ = callback; | 177 scheduling_changed_callback_ = callback; |
| 177 } | 178 } |
| 178 | 179 |
| 179 Buffer GpuScheduler::GetSharedMemoryBuffer(int32 shm_id) { | 180 Buffer GpuScheduler::GetSharedMemoryBuffer(int32 shm_id) { |
| 180 return command_buffer_->GetTransferBuffer(shm_id); | 181 return command_buffer_->GetTransferBuffer(shm_id); |
| 181 } | 182 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 TRACE_COUNTER_ID1("gpu", "GpuScheduler::Preempted", this, 1); | 263 TRACE_COUNTER_ID1("gpu", "GpuScheduler::Preempted", this, 1); |
| 263 was_preempted_ = true; | 264 was_preempted_ = true; |
| 264 } else if (was_preempted_ && !preemption_flag_->IsSet()) { | 265 } else if (was_preempted_ && !preemption_flag_->IsSet()) { |
| 265 TRACE_COUNTER_ID1("gpu", "GpuScheduler::Preempted", this, 0); | 266 TRACE_COUNTER_ID1("gpu", "GpuScheduler::Preempted", this, 0); |
| 266 was_preempted_ = false; | 267 was_preempted_ = false; |
| 267 } | 268 } |
| 268 | 269 |
| 269 return preemption_flag_->IsSet(); | 270 return preemption_flag_->IsSet(); |
| 270 } | 271 } |
| 271 | 272 |
| 273 bool GpuScheduler::HasMoreIdleWork() { |
| 274 return (decoder_ && decoder_->HasMoreIdleWork()); |
| 275 } |
| 276 |
| 277 void GpuScheduler::PerformIdleWork() { |
| 278 if (!decoder_) |
| 279 return; |
| 280 decoder_->PerformIdleWork(); |
| 281 } |
| 282 |
| 272 void GpuScheduler::RescheduleTimeOut() { | 283 void GpuScheduler::RescheduleTimeOut() { |
| 273 int new_count = unscheduled_count_ + rescheduled_count_; | 284 int new_count = unscheduled_count_ + rescheduled_count_; |
| 274 | 285 |
| 275 rescheduled_count_ = 0; | 286 rescheduled_count_ = 0; |
| 276 | 287 |
| 277 while (unscheduled_count_) | 288 while (unscheduled_count_) |
| 278 SetScheduled(true); | 289 SetScheduled(true); |
| 279 | 290 |
| 280 rescheduled_count_ = new_count; | 291 rescheduled_count_ = new_count; |
| 281 } | 292 } |
| 282 | 293 |
| 283 GpuScheduler::UnscheduleFence::UnscheduleFence( | 294 GpuScheduler::UnscheduleFence::UnscheduleFence( |
| 284 gfx::GLFence* fence_, base::Closure task_): fence(fence_), task(task_) { | 295 gfx::GLFence* fence_, base::Closure task_): fence(fence_), task(task_) { |
| 285 } | 296 } |
| 286 | 297 |
| 287 GpuScheduler::UnscheduleFence::~UnscheduleFence() { | 298 GpuScheduler::UnscheduleFence::~UnscheduleFence() { |
| 288 } | 299 } |
| 289 | 300 |
| 290 } // namespace gpu | 301 } // namespace gpu |
| OLD | NEW |