| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/callback.h" | 7 #include "base/callback.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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 parser_.reset(); | 130 parser_.reset(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 #if defined(OS_MACOSX) | 133 #if defined(OS_MACOSX) |
| 134 namespace { | 134 namespace { |
| 135 const unsigned int kMaxOutstandingSwapBuffersCallsPerOnscreenContext = 1; | 135 const unsigned int kMaxOutstandingSwapBuffersCallsPerOnscreenContext = 1; |
| 136 } | 136 } |
| 137 #endif | 137 #endif |
| 138 | 138 |
| 139 void GpuScheduler::PutChanged(bool sync) { | 139 void GpuScheduler::PutChanged(bool sync) { |
| 140 TRACE_EVENT0("gpu", "GpuScheduler:PutChanged"); | 140 TRACE_EVENT1("gpu", "GpuScheduler:PutChanged", "this", this); |
| 141 CommandBuffer::State state = command_buffer_->GetState(); | 141 CommandBuffer::State state = command_buffer_->GetState(); |
| 142 parser_->set_put(state.put_offset); | 142 parser_->set_put(state.put_offset); |
| 143 | 143 |
| 144 if (sync) | 144 if (sync) |
| 145 ProcessCommands(); | 145 ProcessCommands(); |
| 146 else | 146 else |
| 147 ScheduleProcessCommands(); | 147 ScheduleProcessCommands(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void GpuScheduler::ProcessCommands() { | 150 void GpuScheduler::ProcessCommands() { |
| 151 TRACE_EVENT0("gpu", "GpuScheduler:ProcessCommands"); | 151 TRACE_EVENT1("gpu", "GpuScheduler:ProcessCommands", "this", this); |
| 152 CommandBuffer::State state = command_buffer_->GetState(); | 152 CommandBuffer::State state = command_buffer_->GetState(); |
| 153 if (state.error != error::kNoError) | 153 if (state.error != error::kNoError) |
| 154 return; | 154 return; |
| 155 | 155 |
| 156 if (unscheduled_count_ > 0) { | 156 if (unscheduled_count_ > 0) { |
| 157 TRACE_EVENT1("gpu", "EarlyOut_Unscheduled", | 157 TRACE_EVENT1("gpu", "EarlyOut_Unscheduled", |
| 158 "unscheduled_count_", unscheduled_count_); | 158 "unscheduled_count_", unscheduled_count_); |
| 159 return; | 159 return; |
| 160 } | 160 } |
| 161 | 161 |
| 162 if (decoder_.get()) { | 162 if (decoder_.get()) { |
| 163 if (!decoder_->MakeCurrent()) { | 163 if (!decoder_->MakeCurrent()) { |
| 164 LOG(ERROR) << "Context lost because MakeCurrent failed."; | 164 LOG(ERROR) << "Context lost because MakeCurrent failed."; |
| 165 command_buffer_->SetParseError(error::kLostContext); | 165 command_buffer_->SetParseError(error::kLostContext); |
| 166 return; | 166 return; |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 | 169 |
| 170 #if defined(OS_MACOSX) | 170 #if defined(OS_MACOSX) |
| 171 bool do_rate_limiting = surface_.get() != NULL; | 171 bool do_rate_limiting = surface_.get() != NULL; |
| 172 // Don't swamp the browser process with SwapBuffers calls it can't handle. | 172 // Don't swamp the browser process with SwapBuffers calls it can't handle. |
| 173 if (do_rate_limiting && | 173 if (do_rate_limiting && |
| 174 swap_buffers_count_ - acknowledged_swap_buffers_count_ >= | 174 swap_buffers_count_ - acknowledged_swap_buffers_count_ >= |
| 175 kMaxOutstandingSwapBuffersCallsPerOnscreenContext) { | 175 kMaxOutstandingSwapBuffersCallsPerOnscreenContext) { |
| 176 TRACE_EVENT0("gpu", "EarlyOut_OSX_Throttle"); |
| 176 // Stop doing work on this command buffer. In the GPU process, | 177 // Stop doing work on this command buffer. In the GPU process, |
| 177 // receipt of the GpuMsg_AcceleratedSurfaceBuffersSwappedACK | 178 // receipt of the GpuMsg_AcceleratedSurfaceBuffersSwappedACK |
| 178 // message causes ProcessCommands to be scheduled again. | 179 // message causes ProcessCommands to be scheduled again. |
| 179 return; | 180 return; |
| 180 } | 181 } |
| 181 #endif | 182 #endif |
| 182 | 183 |
| 183 base::TimeTicks start_time = base::TimeTicks::Now(); | 184 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 184 base::TimeDelta elapsed; | 185 base::TimeDelta elapsed; |
| 185 bool is_break = false; | 186 bool is_break = false; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 elapsed.InMicroseconds() < kMinimumSchedulerQuantumMicros); | 220 elapsed.InMicroseconds() < kMinimumSchedulerQuantumMicros); |
| 220 | 221 |
| 221 if (unscheduled_count_ == 0 && | 222 if (unscheduled_count_ == 0 && |
| 222 error != error::kWaiting && | 223 error != error::kWaiting && |
| 223 !parser_->IsEmpty()) { | 224 !parser_->IsEmpty()) { |
| 224 ScheduleProcessCommands(); | 225 ScheduleProcessCommands(); |
| 225 } | 226 } |
| 226 } | 227 } |
| 227 | 228 |
| 228 void GpuScheduler::SetScheduled(bool scheduled) { | 229 void GpuScheduler::SetScheduled(bool scheduled) { |
| 229 TRACE_EVENT2("gpu", "GpuScheduler:SetScheduled", "scheduled", scheduled, | 230 TRACE_EVENT2("gpu", "GpuScheduler:SetScheduled", "this", this, |
| 230 "unscheduled_count_", unscheduled_count_); | 231 "new unscheduled_count_", |
| 232 unscheduled_count_ + (scheduled? -1 : 1)); |
| 231 if (scheduled) { | 233 if (scheduled) { |
| 232 --unscheduled_count_; | 234 --unscheduled_count_; |
| 233 DCHECK_GE(unscheduled_count_, 0); | 235 DCHECK_GE(unscheduled_count_, 0); |
| 234 | 236 |
| 235 if (unscheduled_count_ == 0) { | 237 if (unscheduled_count_ == 0) { |
| 236 if (scheduled_callback_.get()) | 238 if (scheduled_callback_.get()) |
| 237 scheduled_callback_->Run(); | 239 scheduled_callback_->Run(); |
| 238 | 240 |
| 239 ScheduleProcessCommands(); | 241 ScheduleProcessCommands(); |
| 240 } | 242 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 method_factory_.NewRunnableMethod(&GpuScheduler::ProcessCommands)); | 303 method_factory_.NewRunnableMethod(&GpuScheduler::ProcessCommands)); |
| 302 } | 304 } |
| 303 | 305 |
| 304 void GpuScheduler::WillResize(gfx::Size size) { | 306 void GpuScheduler::WillResize(gfx::Size size) { |
| 305 if (wrapped_resize_callback_.get()) { | 307 if (wrapped_resize_callback_.get()) { |
| 306 wrapped_resize_callback_->Run(size); | 308 wrapped_resize_callback_->Run(size); |
| 307 } | 309 } |
| 308 } | 310 } |
| 309 | 311 |
| 310 } // namespace gpu | 312 } // namespace gpu |
| OLD | NEW |