| 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 // This file contains the implementation of the command buffer helper class. | 5 // This file contains the implementation of the command buffer helper class. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/cmd_buffer_helper.h" | 7 #include "gpu/command_buffer/client/cmd_buffer_helper.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "gpu/command_buffer/common/command_buffer.h" | 10 #include "gpu/command_buffer/common/command_buffer.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 if (token_ == 0) { | 162 if (token_ == 0) { |
| 163 TRACE_EVENT0("gpu", "CommandBufferHelper::InsertToken(wrapped)"); | 163 TRACE_EVENT0("gpu", "CommandBufferHelper::InsertToken(wrapped)"); |
| 164 // we wrapped | 164 // we wrapped |
| 165 Finish(); | 165 Finish(); |
| 166 DCHECK_EQ(token_, last_token_read()); | 166 DCHECK_EQ(token_, last_token_read()); |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 return token_; | 169 return token_; |
| 170 } | 170 } |
| 171 | 171 |
| 172 bool CommandBufferHelper::HasTokenPassed(int32 token) { |
| 173 if (token > token_) |
| 174 return true; // we wrapped |
| 175 return last_token_read() >= token; |
| 176 } |
| 177 |
| 172 // Waits until the current token value is greater or equal to the value passed | 178 // Waits until the current token value is greater or equal to the value passed |
| 173 // in argument. | 179 // in argument. |
| 174 void CommandBufferHelper::WaitForToken(int32 token) { | 180 void CommandBufferHelper::WaitForToken(int32 token) { |
| 175 if (!usable() || !HaveRingBuffer()) { | 181 if (!usable() || !HaveRingBuffer()) { |
| 176 return; | 182 return; |
| 177 } | 183 } |
| 178 // Return immediately if corresponding InsertToken failed. | 184 // Return immediately if corresponding InsertToken failed. |
| 179 if (token < 0) | 185 if (token < 0) |
| 180 return; | 186 return; |
| 181 if (token > token_) return; // we wrapped | 187 if (token > token_) return; // we wrapped |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 CommandBufferEntry* space = &entries_[put_]; | 276 CommandBufferEntry* space = &entries_[put_]; |
| 271 put_ += entries; | 277 put_ += entries; |
| 272 DCHECK_LE(put_, total_entry_count_); | 278 DCHECK_LE(put_, total_entry_count_); |
| 273 if (put_ == total_entry_count_) { | 279 if (put_ == total_entry_count_) { |
| 274 put_ = 0; | 280 put_ = 0; |
| 275 } | 281 } |
| 276 return space; | 282 return space; |
| 277 } | 283 } |
| 278 | 284 |
| 279 } // namespace gpu | 285 } // namespace gpu |
| OLD | NEW |