Chromium Code Reviews| 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 "base/time/time.h" | |
|
hamaji
2014/07/09 06:03:15
I guessed using TimeTicks in this file is fine bec
| |
| 10 #include "gpu/command_buffer/common/command_buffer.h" | 11 #include "gpu/command_buffer/common/command_buffer.h" |
| 11 #include "gpu/command_buffer/common/trace_event.h" | 12 #include "gpu/command_buffer/common/trace_event.h" |
| 12 | 13 |
| 13 namespace gpu { | 14 namespace gpu { |
| 14 | 15 |
| 15 CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer) | 16 CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer) |
| 16 : command_buffer_(command_buffer), | 17 : command_buffer_(command_buffer), |
| 17 ring_buffer_id_(-1), | 18 ring_buffer_id_(-1), |
| 18 ring_buffer_size_(0), | 19 ring_buffer_size_(0), |
| 19 entries_(NULL), | 20 entries_(NULL), |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 command_buffer_->WaitForGetOffsetInRange(start, end); | 145 command_buffer_->WaitForGetOffsetInRange(start, end); |
| 145 return command_buffer_->GetLastError() == gpu::error::kNoError; | 146 return command_buffer_->GetLastError() == gpu::error::kNoError; |
| 146 } | 147 } |
| 147 | 148 |
| 148 void CommandBufferHelper::Flush() { | 149 void CommandBufferHelper::Flush() { |
| 149 // Wrap put_ before flush. | 150 // Wrap put_ before flush. |
| 150 if (put_ == total_entry_count_) | 151 if (put_ == total_entry_count_) |
| 151 put_ = 0; | 152 put_ = 0; |
| 152 | 153 |
| 153 if (usable() && last_put_sent_ != put_) { | 154 if (usable() && last_put_sent_ != put_) { |
| 154 last_flush_time_ = clock(); | 155 last_flush_time_ = base::TimeTicks::Now().ToInternalValue(); |
| 155 last_put_sent_ = put_; | 156 last_put_sent_ = put_; |
| 156 command_buffer_->Flush(put_); | 157 command_buffer_->Flush(put_); |
| 157 ++flush_generation_; | 158 ++flush_generation_; |
| 158 CalcImmediateEntries(0); | 159 CalcImmediateEntries(0); |
| 159 } | 160 } |
| 160 } | 161 } |
| 161 | 162 |
| 162 #if defined(CMD_HELPER_PERIODIC_FLUSH_CHECK) | 163 #if defined(CMD_HELPER_PERIODIC_FLUSH_CHECK) |
| 163 void CommandBufferHelper::PeriodicFlushCheck() { | 164 void CommandBufferHelper::PeriodicFlushCheck() { |
| 164 clock_t current_time = clock(); | 165 base::TimeTicks current_time = base::TimeTicks::Now(); |
| 165 if (current_time - last_flush_time_ > kPeriodicFlushDelay * CLOCKS_PER_SEC) | 166 if (current_time - base::TimeTicks::FromInternalValue(last_flush_time_) > |
| 167 base::TimeDelta::FromSecondsD(kPeriodicFlushDelay)) { | |
|
vmiura
2014/07/09 20:18:58
Could we change this to FromMicroseconds to avoid
hamaji
2014/07/10 07:00:16
Did you worry about that 1.0/300 will be converted
vmiura
2014/07/10 22:21:25
Ok, it was just a performance question. In some t
| |
| 166 Flush(); | 168 Flush(); |
| 169 } | |
| 167 } | 170 } |
| 168 #endif | 171 #endif |
| 169 | 172 |
| 170 // Calls Flush() and then waits until the buffer is empty. Break early if the | 173 // Calls Flush() and then waits until the buffer is empty. Break early if the |
| 171 // error is set. | 174 // error is set. |
| 172 bool CommandBufferHelper::Finish() { | 175 bool CommandBufferHelper::Finish() { |
| 173 TRACE_EVENT0("gpu", "CommandBufferHelper::Finish"); | 176 TRACE_EVENT0("gpu", "CommandBufferHelper::Finish"); |
| 174 if (!usable()) { | 177 if (!usable()) { |
| 175 return false; | 178 return false; |
| 176 } | 179 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 if (!WaitForGetOffsetInRange(put_ + count + 1, put_)) | 285 if (!WaitForGetOffsetInRange(put_ + count + 1, put_)) |
| 283 return; | 286 return; |
| 284 CalcImmediateEntries(count); | 287 CalcImmediateEntries(count); |
| 285 DCHECK_GE(immediate_entry_count_, count); | 288 DCHECK_GE(immediate_entry_count_, count); |
| 286 } | 289 } |
| 287 } | 290 } |
| 288 } | 291 } |
| 289 | 292 |
| 290 | 293 |
| 291 } // namespace gpu | 294 } // namespace gpu |
| OLD | NEW |