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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 parser_.reset(); | 109 parser_.reset(); |
110 } | 110 } |
111 | 111 |
112 #if defined(OS_MACOSX) | 112 #if defined(OS_MACOSX) |
113 namespace { | 113 namespace { |
114 const unsigned int kMaxOutstandingSwapBuffersCallsPerOnscreenContext = 1; | 114 const unsigned int kMaxOutstandingSwapBuffersCallsPerOnscreenContext = 1; |
115 } | 115 } |
116 #endif | 116 #endif |
117 | 117 |
| 118 void GpuScheduler::PutChanged(bool sync) { |
| 119 CommandBuffer::State state = command_buffer_->GetState(); |
| 120 parser_->set_put(state.put_offset); |
| 121 |
| 122 if (sync) |
| 123 ProcessCommands(); |
| 124 else |
| 125 ScheduleProcessCommands(); |
| 126 } |
| 127 |
118 void GpuScheduler::ProcessCommands() { | 128 void GpuScheduler::ProcessCommands() { |
119 GPU_TRACE_EVENT0("gpu", "GpuScheduler:ProcessCommands"); | 129 GPU_TRACE_EVENT0("gpu", "GpuScheduler:ProcessCommands"); |
120 CommandBuffer::State state = command_buffer_->GetState(); | 130 CommandBuffer::State state = command_buffer_->GetState(); |
121 if (state.error != error::kNoError) | 131 if (state.error != error::kNoError) |
122 return; | 132 return; |
123 | 133 |
124 if (decoder_.get()) { | 134 if (decoder_.get()) { |
125 if (!decoder_->MakeCurrent()) { | 135 if (!decoder_->MakeCurrent()) { |
126 LOG(ERROR) << "Context lost because MakeCurrent failed."; | 136 LOG(ERROR) << "Context lost because MakeCurrent failed."; |
127 command_buffer_->SetParseError(error::kLostContext); | 137 command_buffer_->SetParseError(error::kLostContext); |
128 return; | 138 return; |
129 } | 139 } |
130 } | 140 } |
131 | 141 |
132 parser_->set_put(state.put_offset); | |
133 | |
134 #if defined(OS_MACOSX) | 142 #if defined(OS_MACOSX) |
135 bool do_rate_limiting = surface_.get() != NULL; | 143 bool do_rate_limiting = surface_.get() != NULL; |
136 // Don't swamp the browser process with SwapBuffers calls it can't handle. | 144 // Don't swamp the browser process with SwapBuffers calls it can't handle. |
137 if (do_rate_limiting && | 145 if (do_rate_limiting && |
138 swap_buffers_count_ - acknowledged_swap_buffers_count_ >= | 146 swap_buffers_count_ - acknowledged_swap_buffers_count_ >= |
139 kMaxOutstandingSwapBuffersCallsPerOnscreenContext) { | 147 kMaxOutstandingSwapBuffersCallsPerOnscreenContext) { |
140 // Stop doing work on this command buffer. In the GPU process, | 148 // Stop doing work on this command buffer. In the GPU process, |
141 // receipt of the GpuMsg_AcceleratedSurfaceBuffersSwappedACK | 149 // receipt of the GpuMsg_AcceleratedSurfaceBuffersSwappedACK |
142 // message causes ProcessCommands to be scheduled again. | 150 // message causes ProcessCommands to be scheduled again. |
143 return; | 151 return; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 NewCallback(this, | 219 NewCallback(this, |
212 &GpuScheduler::WillSwapBuffers)); | 220 &GpuScheduler::WillSwapBuffers)); |
213 } | 221 } |
214 | 222 |
215 void GpuScheduler::SetCommandProcessedCallback( | 223 void GpuScheduler::SetCommandProcessedCallback( |
216 Callback0::Type* callback) { | 224 Callback0::Type* callback) { |
217 command_processed_callback_.reset(callback); | 225 command_processed_callback_.reset(callback); |
218 } | 226 } |
219 | 227 |
220 } // namespace gpu | 228 } // namespace gpu |
OLD | NEW |