| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 return false; | 149 return false; |
| 150 } | 150 } |
| 151 | 151 |
| 152 // Wrap put_ before flush. | 152 // Wrap put_ before flush. |
| 153 if (put_ == total_entry_count_) | 153 if (put_ == total_entry_count_) |
| 154 put_ = 0; | 154 put_ = 0; |
| 155 | 155 |
| 156 last_flush_time_ = clock(); | 156 last_flush_time_ = clock(); |
| 157 last_put_sent_ = put_; | 157 last_put_sent_ = put_; |
| 158 CommandBuffer::State state = command_buffer_->FlushSync(put_, get_offset()); | 158 CommandBuffer::State state = command_buffer_->FlushSync(put_, get_offset()); |
| 159 ++flush_generation_; |
| 159 CalcImmediateEntries(0); | 160 CalcImmediateEntries(0); |
| 160 return state.error == error::kNoError; | 161 return state.error == error::kNoError; |
| 161 } | 162 } |
| 162 | 163 |
| 163 void CommandBufferHelper::Flush() { | 164 void CommandBufferHelper::Flush() { |
| 164 // Wrap put_ before flush. | 165 // Wrap put_ before flush. |
| 165 if (put_ == total_entry_count_) | 166 if (put_ == total_entry_count_) |
| 166 put_ = 0; | 167 put_ = 0; |
| 167 | 168 |
| 168 if (usable() && last_put_sent_ != put_) { | 169 if (usable() && last_put_sent_ != put_) { |
| 169 last_flush_time_ = clock(); | 170 last_flush_time_ = clock(); |
| 170 last_put_sent_ = put_; | 171 last_put_sent_ = put_; |
| 171 command_buffer_->Flush(put_); | 172 command_buffer_->Flush(put_); |
| 173 ++flush_generation_; |
| 172 CalcImmediateEntries(0); | 174 CalcImmediateEntries(0); |
| 173 } | 175 } |
| 174 } | 176 } |
| 175 | 177 |
| 176 #if defined(CMD_HELPER_PERIODIC_FLUSH_CHECK) | 178 #if defined(CMD_HELPER_PERIODIC_FLUSH_CHECK) |
| 177 void CommandBufferHelper::PeriodicFlushCheck() { | 179 void CommandBufferHelper::PeriodicFlushCheck() { |
| 178 clock_t current_time = clock(); | 180 clock_t current_time = clock(); |
| 179 if (current_time - last_flush_time_ > kPeriodicFlushDelay * CLOCKS_PER_SEC) | 181 if (current_time - last_flush_time_ > kPeriodicFlushDelay * CLOCKS_PER_SEC) |
| 180 Flush(); | 182 Flush(); |
| 181 } | 183 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 if (!FlushSync()) | 308 if (!FlushSync()) |
| 307 return; | 309 return; |
| 308 CalcImmediateEntries(count); | 310 CalcImmediateEntries(count); |
| 309 } | 311 } |
| 310 } | 312 } |
| 311 } | 313 } |
| 312 } | 314 } |
| 313 | 315 |
| 314 | 316 |
| 315 } // namespace gpu | 317 } // namespace gpu |
| OLD | NEW |