| 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 "../client/cmd_buffer_helper.h" | 7 #include "../client/cmd_buffer_helper.h" |
| 8 #include "../common/command_buffer.h" | 8 #include "../common/command_buffer.h" |
| 9 #include "../common/trace_event.h" | 9 #include "../common/trace_event.h" |
| 10 | 10 |
| 11 namespace gpu { | 11 namespace gpu { |
| 12 | 12 |
| 13 CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer) | 13 CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer) |
| 14 : command_buffer_(command_buffer), | 14 : command_buffer_(command_buffer), |
| 15 ring_buffer_id_(-1), | 15 ring_buffer_id_(-1), |
| 16 ring_buffer_size_(0), | 16 ring_buffer_size_(0), |
| 17 entries_(NULL), | 17 entries_(NULL), |
| 18 total_entry_count_(0), | 18 total_entry_count_(0), |
| 19 usable_entry_count_(0), | 19 usable_entry_count_(0), |
| 20 token_(0), | 20 token_(0), |
| 21 put_(0), | 21 put_(0), |
| 22 last_put_sent_(0), | 22 last_put_sent_(0), |
| 23 commands_issued_(0), | 23 commands_issued_(0), |
| 24 usable_(true), | 24 usable_(true), |
| 25 context_lost_(false), |
| 25 last_flush_time_(0) { | 26 last_flush_time_(0) { |
| 26 } | 27 } |
| 27 | 28 |
| 29 bool CommandBufferHelper::IsContextLost() { |
| 30 if (!context_lost_) { |
| 31 context_lost_ = error::IsError(command_buffer()->GetLastError()); |
| 32 } |
| 33 return context_lost_; |
| 34 } |
| 35 |
| 28 bool CommandBufferHelper::AllocateRingBuffer() { | 36 bool CommandBufferHelper::AllocateRingBuffer() { |
| 29 if (!usable()) { | 37 if (!usable()) { |
| 30 return false; | 38 return false; |
| 31 } | 39 } |
| 32 | 40 |
| 33 if (HaveRingBuffer()) { | 41 if (HaveRingBuffer()) { |
| 34 return true; | 42 return true; |
| 35 } | 43 } |
| 36 | 44 |
| 37 int32 id = command_buffer_->CreateTransferBuffer(ring_buffer_size_, -1); | 45 int32 id = command_buffer_->CreateTransferBuffer(ring_buffer_size_, -1); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 256 } |
| 249 return space; | 257 return space; |
| 250 } | 258 } |
| 251 | 259 |
| 252 error::Error CommandBufferHelper::GetError() { | 260 error::Error CommandBufferHelper::GetError() { |
| 253 CommandBuffer::State state = command_buffer_->GetState(); | 261 CommandBuffer::State state = command_buffer_->GetState(); |
| 254 return static_cast<error::Error>(state.error); | 262 return static_cast<error::Error>(state.error); |
| 255 } | 263 } |
| 256 | 264 |
| 257 } // namespace gpu | 265 } // namespace gpu |
| OLD | NEW |