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 #ifndef GPU_COMMAND_BUFFER_CLIENT_TRANSFER_BUFFER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_CLIENT_TRANSFER_BUFFER_H_ |
6 #define GPU_COMMAND_BUFFER_CLIENT_TRANSFER_BUFFER_H_ | 6 #define GPU_COMMAND_BUFFER_CLIENT_TRANSFER_BUFFER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "gpu/command_buffer/client/ring_buffer.h" | 10 #include "gpu/command_buffer/client/ring_buffer.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 unsigned int size, | 139 unsigned int size, |
140 CommandBufferHelper* helper, | 140 CommandBufferHelper* helper, |
141 TransferBufferInterface* transfer_buffer) | 141 TransferBufferInterface* transfer_buffer) |
142 : buffer_(NULL), | 142 : buffer_(NULL), |
143 size_(0), | 143 size_(0), |
144 helper_(helper), | 144 helper_(helper), |
145 transfer_buffer_(transfer_buffer) { | 145 transfer_buffer_(transfer_buffer) { |
146 Reset(size); | 146 Reset(size); |
147 } | 147 } |
148 | 148 |
| 149 // Constructs an empty and invalid allocation that should be Reset() later. |
| 150 ScopedTransferBufferPtr(CommandBufferHelper* helper, |
| 151 TransferBufferInterface* transfer_buffer) |
| 152 : buffer_(NULL), |
| 153 size_(0), |
| 154 helper_(helper), |
| 155 transfer_buffer_(transfer_buffer) {} |
| 156 |
149 ~ScopedTransferBufferPtr() { | 157 ~ScopedTransferBufferPtr() { |
150 Release(); | 158 Release(); |
151 } | 159 } |
152 | 160 |
153 bool valid() const { | 161 bool valid() const { |
154 return buffer_ != NULL; | 162 return buffer_ != NULL; |
155 } | 163 } |
156 | 164 |
157 unsigned int size() const { | 165 unsigned int size() const { |
158 return size_; | 166 return size_; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 } | 207 } |
200 | 208 |
201 unsigned int num_elements() const { | 209 unsigned int num_elements() const { |
202 return size() / sizeof(T); | 210 return size() / sizeof(T); |
203 } | 211 } |
204 }; | 212 }; |
205 | 213 |
206 } // namespace gpu | 214 } // namespace gpu |
207 | 215 |
208 #endif // GPU_COMMAND_BUFFER_CLIENT_TRANSFER_BUFFER_H_ | 216 #endif // GPU_COMMAND_BUFFER_CLIENT_TRANSFER_BUFFER_H_ |
OLD | NEW |