| 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 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 // Allocates up to size bytes. | 41 // Allocates up to size bytes. |
| 42 virtual void* AllocUpTo(unsigned int size, unsigned int* size_allocated) = 0; | 42 virtual void* AllocUpTo(unsigned int size, unsigned int* size_allocated) = 0; |
| 43 | 43 |
| 44 // Allocates size bytes. | 44 // Allocates size bytes. |
| 45 // Note: Alloc will fail if it can not return size bytes. | 45 // Note: Alloc will fail if it can not return size bytes. |
| 46 virtual void* Alloc(unsigned int size) = 0; | 46 virtual void* Alloc(unsigned int size) = 0; |
| 47 | 47 |
| 48 virtual RingBuffer::Offset GetOffset(void* pointer) const = 0; | 48 virtual RingBuffer::Offset GetOffset(void* pointer) const = 0; |
| 49 | 49 |
| 50 virtual void DiscardBlock(void* p) = 0; |
| 51 |
| 50 virtual void FreePendingToken(void* p, unsigned int token) = 0; | 52 virtual void FreePendingToken(void* p, unsigned int token) = 0; |
| 51 }; | 53 }; |
| 52 | 54 |
| 53 // Class that manages the transfer buffer. | 55 // Class that manages the transfer buffer. |
| 54 class GPU_EXPORT TransferBuffer : public TransferBufferInterface { | 56 class GPU_EXPORT TransferBuffer : public TransferBufferInterface { |
| 55 public: | 57 public: |
| 56 TransferBuffer(CommandBufferHelper* helper); | 58 TransferBuffer(CommandBufferHelper* helper); |
| 57 ~TransferBuffer() override; | 59 ~TransferBuffer() override; |
| 58 | 60 |
| 59 // Overridden from TransferBufferInterface. | 61 // Overridden from TransferBufferInterface. |
| 60 bool Initialize(unsigned int default_buffer_size, | 62 bool Initialize(unsigned int default_buffer_size, |
| 61 unsigned int result_size, | 63 unsigned int result_size, |
| 62 unsigned int min_buffer_size, | 64 unsigned int min_buffer_size, |
| 63 unsigned int max_buffer_size, | 65 unsigned int max_buffer_size, |
| 64 unsigned int alignment, | 66 unsigned int alignment, |
| 65 unsigned int size_to_flush) override; | 67 unsigned int size_to_flush) override; |
| 66 int GetShmId() override; | 68 int GetShmId() override; |
| 67 void* GetResultBuffer() override; | 69 void* GetResultBuffer() override; |
| 68 int GetResultOffset() override; | 70 int GetResultOffset() override; |
| 69 void Free() override; | 71 void Free() override; |
| 70 bool HaveBuffer() const override; | 72 bool HaveBuffer() const override; |
| 71 void* AllocUpTo(unsigned int size, unsigned int* size_allocated) override; | 73 void* AllocUpTo(unsigned int size, unsigned int* size_allocated) override; |
| 72 void* Alloc(unsigned int size) override; | 74 void* Alloc(unsigned int size) override; |
| 73 RingBuffer::Offset GetOffset(void* pointer) const override; | 75 RingBuffer::Offset GetOffset(void* pointer) const override; |
| 76 void DiscardBlock(void* p) override; |
| 74 void FreePendingToken(void* p, unsigned int token) override; | 77 void FreePendingToken(void* p, unsigned int token) override; |
| 75 | 78 |
| 76 // These are for testing. | 79 // These are for testing. |
| 77 unsigned int GetCurrentMaxAllocationWithoutRealloc() const; | 80 unsigned int GetCurrentMaxAllocationWithoutRealloc() const; |
| 78 unsigned int GetMaxAllocation() const; | 81 unsigned int GetMaxAllocation() const; |
| 79 | 82 |
| 80 private: | 83 private: |
| 81 // Tries to reallocate the ring buffer if it's not large enough for size. | 84 // Tries to reallocate the ring buffer if it's not large enough for size. |
| 82 void ReallocateRingBuffer(unsigned int size); | 85 void ReallocateRingBuffer(unsigned int size); |
| 83 | 86 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 RingBuffer::Offset offset() const { | 159 RingBuffer::Offset offset() const { |
| 157 return transfer_buffer_->GetOffset(buffer_); | 160 return transfer_buffer_->GetOffset(buffer_); |
| 158 } | 161 } |
| 159 | 162 |
| 160 void* address() const { | 163 void* address() const { |
| 161 return buffer_; | 164 return buffer_; |
| 162 } | 165 } |
| 163 | 166 |
| 164 void Release(); | 167 void Release(); |
| 165 | 168 |
| 169 void Discard(); |
| 170 |
| 166 void Reset(unsigned int new_size); | 171 void Reset(unsigned int new_size); |
| 167 | 172 |
| 168 private: | 173 private: |
| 169 void* buffer_; | 174 void* buffer_; |
| 170 unsigned int size_; | 175 unsigned int size_; |
| 171 CommandBufferHelper* helper_; | 176 CommandBufferHelper* helper_; |
| 172 TransferBufferInterface* transfer_buffer_; | 177 TransferBufferInterface* transfer_buffer_; |
| 173 DISALLOW_COPY_AND_ASSIGN(ScopedTransferBufferPtr); | 178 DISALLOW_COPY_AND_ASSIGN(ScopedTransferBufferPtr); |
| 174 }; | 179 }; |
| 175 | 180 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 188 } | 193 } |
| 189 | 194 |
| 190 unsigned int num_elements() const { | 195 unsigned int num_elements() const { |
| 191 return size() / sizeof(T); | 196 return size() / sizeof(T); |
| 192 } | 197 } |
| 193 }; | 198 }; |
| 194 | 199 |
| 195 } // namespace gpu | 200 } // namespace gpu |
| 196 | 201 |
| 197 #endif // GPU_COMMAND_BUFFER_CLIENT_TRANSFER_BUFFER_H_ | 202 #endif // GPU_COMMAND_BUFFER_CLIENT_TRANSFER_BUFFER_H_ |
| OLD | NEW |