| 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 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 const int32 kJumpEntries = | 63 const int32 kJumpEntries = |
| 64 sizeof(cmd::Jump) / sizeof(*entries_); // NOLINT | 64 sizeof(cmd::Jump) / sizeof(*entries_); // NOLINT |
| 65 | 65 |
| 66 total_entry_count_ = num_ring_buffer_entries; | 66 total_entry_count_ = num_ring_buffer_entries; |
| 67 usable_entry_count_ = total_entry_count_ - kJumpEntries; | 67 usable_entry_count_ = total_entry_count_ - kJumpEntries; |
| 68 put_ = state.put_offset; | 68 put_ = state.put_offset; |
| 69 return true; | 69 return true; |
| 70 } | 70 } |
| 71 | 71 |
| 72 void CommandBufferHelper::FreeResources() { |
| 73 if (HaveRingBuffer()) { |
| 74 command_buffer_->DestroyTransferBuffer(ring_buffer_id_); |
| 75 ring_buffer_id_ = -1; |
| 76 } |
| 77 } |
| 78 |
| 72 void CommandBufferHelper::FreeRingBuffer() { | 79 void CommandBufferHelper::FreeRingBuffer() { |
| 73 GPU_CHECK_EQ(put_, get_offset()); | 80 GPU_CHECK_EQ(put_, get_offset()); |
| 74 if (HaveRingBuffer()) { | 81 FreeResources(); |
| 75 command_buffer_->DestroyTransferBuffer(ring_buffer_id_); | |
| 76 ring_buffer_id_ = -1; | |
| 77 } | |
| 78 } | 82 } |
| 79 | 83 |
| 80 bool CommandBufferHelper::Initialize(int32 ring_buffer_size) { | 84 bool CommandBufferHelper::Initialize(int32 ring_buffer_size) { |
| 81 ring_buffer_size_ = ring_buffer_size; | 85 ring_buffer_size_ = ring_buffer_size; |
| 82 return AllocateRingBuffer(); | 86 return AllocateRingBuffer(); |
| 83 } | 87 } |
| 84 | 88 |
| 85 CommandBufferHelper::~CommandBufferHelper() { | 89 CommandBufferHelper::~CommandBufferHelper() { |
| 90 FreeResources(); |
| 86 } | 91 } |
| 87 | 92 |
| 88 bool CommandBufferHelper::FlushSync() { | 93 bool CommandBufferHelper::FlushSync() { |
| 89 if (!usable()) { | 94 if (!usable()) { |
| 90 return false; | 95 return false; |
| 91 } | 96 } |
| 92 last_flush_time_ = clock(); | 97 last_flush_time_ = clock(); |
| 93 last_put_sent_ = put_; | 98 last_put_sent_ = put_; |
| 94 CommandBuffer::State state = command_buffer_->FlushSync(put_, get_offset()); | 99 CommandBuffer::State state = command_buffer_->FlushSync(put_, get_offset()); |
| 95 return state.error == error::kNoError; | 100 return state.error == error::kNoError; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 } | 248 } |
| 244 return space; | 249 return space; |
| 245 } | 250 } |
| 246 | 251 |
| 247 error::Error CommandBufferHelper::GetError() { | 252 error::Error CommandBufferHelper::GetError() { |
| 248 CommandBuffer::State state = command_buffer_->GetState(); | 253 CommandBuffer::State state = command_buffer_->GetState(); |
| 249 return static_cast<error::Error>(state.error); | 254 return static_cast<error::Error>(state.error); |
| 250 } | 255 } |
| 251 | 256 |
| 252 } // namespace gpu | 257 } // namespace gpu |
| OLD | NEW |