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/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "gpu/common/gpu_trace_event.h" | 10 #include "gpu/common/gpu_trace_event.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 parser_.reset(); | 111 parser_.reset(); |
112 } | 112 } |
113 | 113 |
114 #if defined(OS_MACOSX) | 114 #if defined(OS_MACOSX) |
115 namespace { | 115 namespace { |
116 const unsigned int kMaxOutstandingSwapBuffersCallsPerOnscreenContext = 1; | 116 const unsigned int kMaxOutstandingSwapBuffersCallsPerOnscreenContext = 1; |
117 } | 117 } |
118 #endif | 118 #endif |
119 | 119 |
| 120 void GpuScheduler::PutChanged(bool sync) { |
| 121 CommandBuffer::State state = command_buffer_->GetState(); |
| 122 parser_->set_put(state.put_offset); |
| 123 |
| 124 if (sync) |
| 125 ProcessCommands(); |
| 126 else |
| 127 ScheduleProcessCommands(); |
| 128 } |
| 129 |
120 void GpuScheduler::ProcessCommands() { | 130 void GpuScheduler::ProcessCommands() { |
121 GPU_TRACE_EVENT0("gpu", "GpuScheduler:ProcessCommands"); | 131 GPU_TRACE_EVENT0("gpu", "GpuScheduler:ProcessCommands"); |
122 CommandBuffer::State state = command_buffer_->GetState(); | 132 CommandBuffer::State state = command_buffer_->GetState(); |
123 if (state.error != error::kNoError) | 133 if (state.error != error::kNoError) |
124 return; | 134 return; |
125 | 135 |
126 if (unscheduled_count_ > 0) | 136 if (unscheduled_count_ > 0) |
127 return; | 137 return; |
128 | 138 |
129 if (decoder_.get()) { | 139 if (decoder_.get()) { |
130 if (!decoder_->MakeCurrent()) { | 140 if (!decoder_->MakeCurrent()) { |
131 LOG(ERROR) << "Context lost because MakeCurrent failed."; | 141 LOG(ERROR) << "Context lost because MakeCurrent failed."; |
132 command_buffer_->SetParseError(error::kLostContext); | 142 command_buffer_->SetParseError(error::kLostContext); |
133 return; | 143 return; |
134 } | 144 } |
135 } | 145 } |
136 | 146 |
137 parser_->set_put(state.put_offset); | |
138 | |
139 #if defined(OS_MACOSX) | 147 #if defined(OS_MACOSX) |
140 bool do_rate_limiting = surface_.get() != NULL; | 148 bool do_rate_limiting = surface_.get() != NULL; |
141 // Don't swamp the browser process with SwapBuffers calls it can't handle. | 149 // Don't swamp the browser process with SwapBuffers calls it can't handle. |
142 if (do_rate_limiting && | 150 if (do_rate_limiting && |
143 swap_buffers_count_ - acknowledged_swap_buffers_count_ >= | 151 swap_buffers_count_ - acknowledged_swap_buffers_count_ >= |
144 kMaxOutstandingSwapBuffersCallsPerOnscreenContext) { | 152 kMaxOutstandingSwapBuffersCallsPerOnscreenContext) { |
145 // Stop doing work on this command buffer. In the GPU process, | 153 // Stop doing work on this command buffer. In the GPU process, |
146 // receipt of the GpuMsg_AcceleratedSurfaceBuffersSwappedACK | 154 // receipt of the GpuMsg_AcceleratedSurfaceBuffersSwappedACK |
147 // message causes ProcessCommands to be scheduled again. | 155 // message causes ProcessCommands to be scheduled again. |
148 return; | 156 return; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 command_processed_callback_.reset(callback); | 241 command_processed_callback_.reset(callback); |
234 } | 242 } |
235 | 243 |
236 void GpuScheduler::ScheduleProcessCommands() { | 244 void GpuScheduler::ScheduleProcessCommands() { |
237 MessageLoop::current()->PostTask( | 245 MessageLoop::current()->PostTask( |
238 FROM_HERE, | 246 FROM_HERE, |
239 method_factory_.NewRunnableMethod(&GpuScheduler::ProcessCommands)); | 247 method_factory_.NewRunnableMethod(&GpuScheduler::ProcessCommands)); |
240 } | 248 } |
241 | 249 |
242 } // namespace gpu | 250 } // namespace gpu |
OLD | NEW |