| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "gpu/command_buffer/common/command_buffer.h" | 8 #include "gpu/command_buffer/common/command_buffer.h" |
| 9 | 9 |
| 10 namespace gpu { | 10 namespace gpu { |
| 11 | 11 |
| 12 using gpu::CommandBuffer; | |
| 13 | |
| 14 CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer) | 12 CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer) |
| 15 : command_buffer_(command_buffer), | 13 : command_buffer_(command_buffer), |
| 16 entries_(NULL), | 14 entries_(NULL), |
| 17 entry_count_(0), | 15 entry_count_(0), |
| 18 token_(0), | 16 token_(0), |
| 19 last_token_read_(-1), | 17 last_token_read_(-1), |
| 20 get_(0), | 18 get_(0), |
| 21 put_(0) { | 19 put_(0) { |
| 22 } | 20 } |
| 23 | 21 |
| 24 bool CommandBufferHelper::Initialize() { | 22 bool CommandBufferHelper::Initialize() { |
| 25 ring_buffer_ = command_buffer_->GetRingBuffer(); | 23 ring_buffer_ = command_buffer_->GetRingBuffer(); |
| 26 if (!ring_buffer_) | 24 if (!ring_buffer_.ptr) |
| 27 return false; | 25 return false; |
| 28 | 26 |
| 29 // Map the ring buffer into this process. | 27 entries_ = static_cast<CommandBufferEntry*>(ring_buffer_.ptr); |
| 30 if (!ring_buffer_->Map(ring_buffer_->max_size())) | |
| 31 return false; | |
| 32 | |
| 33 entries_ = static_cast<CommandBufferEntry*>(ring_buffer_->memory()); | |
| 34 entry_count_ = command_buffer_->GetSize(); | 28 entry_count_ = command_buffer_->GetSize(); |
| 35 get_ = command_buffer_->GetGetOffset(); | 29 get_ = command_buffer_->GetGetOffset(); |
| 36 put_ = command_buffer_->GetPutOffset(); | 30 put_ = command_buffer_->GetPutOffset(); |
| 37 last_token_read_ = command_buffer_->GetToken(); | 31 last_token_read_ = command_buffer_->GetToken(); |
| 38 | 32 |
| 39 return true; | 33 return true; |
| 40 } | 34 } |
| 41 | 35 |
| 42 CommandBufferHelper::~CommandBufferHelper() { | 36 CommandBufferHelper::~CommandBufferHelper() { |
| 43 } | 37 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 put_ += entries; | 148 put_ += entries; |
| 155 return space; | 149 return space; |
| 156 } | 150 } |
| 157 | 151 |
| 158 parse_error::ParseError CommandBufferHelper::GetParseError() { | 152 parse_error::ParseError CommandBufferHelper::GetParseError() { |
| 159 int32 parse_error = command_buffer_->ResetParseError(); | 153 int32 parse_error = command_buffer_->ResetParseError(); |
| 160 return static_cast<parse_error::ParseError>(parse_error); | 154 return static_cast<parse_error::ParseError>(parse_error); |
| 161 } | 155 } |
| 162 | 156 |
| 163 } // namespace gpu | 157 } // namespace gpu |
| OLD | NEW |