| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 FreePendingToken(void* p, unsigned int token) = 0; | 50 virtual void FreePendingToken(void* p, unsigned int token) = 0; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 // Class that manages the transfer buffer. | 53 // Class that manages the transfer buffer. |
| 54 class GPU_EXPORT TransferBuffer : public TransferBufferInterface { | 54 class GPU_EXPORT TransferBuffer : public TransferBufferInterface { |
| 55 public: | 55 public: |
| 56 TransferBuffer(CommandBufferHelper* helper); | 56 TransferBuffer(CommandBufferHelper* helper); |
| 57 virtual ~TransferBuffer(); | 57 ~TransferBuffer() override; |
| 58 | 58 |
| 59 // Overridden from TransferBufferInterface. | 59 // Overridden from TransferBufferInterface. |
| 60 virtual bool Initialize( | 60 bool Initialize(unsigned int default_buffer_size, |
| 61 unsigned int default_buffer_size, | 61 unsigned int result_size, |
| 62 unsigned int result_size, | 62 unsigned int min_buffer_size, |
| 63 unsigned int min_buffer_size, | 63 unsigned int max_buffer_size, |
| 64 unsigned int max_buffer_size, | 64 unsigned int alignment, |
| 65 unsigned int alignment, | 65 unsigned int size_to_flush) override; |
| 66 unsigned int size_to_flush) override; | 66 int GetShmId() override; |
| 67 virtual int GetShmId() override; | 67 void* GetResultBuffer() override; |
| 68 virtual void* GetResultBuffer() override; | 68 int GetResultOffset() override; |
| 69 virtual int GetResultOffset() override; | 69 void Free() override; |
| 70 virtual void Free() override; | 70 bool HaveBuffer() const override; |
| 71 virtual bool HaveBuffer() const override; | 71 void* AllocUpTo(unsigned int size, unsigned int* size_allocated) override; |
| 72 virtual void* AllocUpTo( | 72 void* Alloc(unsigned int size) override; |
| 73 unsigned int size, unsigned int* size_allocated) override; | 73 RingBuffer::Offset GetOffset(void* pointer) const override; |
| 74 virtual void* Alloc(unsigned int size) override; | 74 void FreePendingToken(void* p, unsigned int token) override; |
| 75 virtual RingBuffer::Offset GetOffset(void* pointer) const override; | |
| 76 virtual void FreePendingToken(void* p, unsigned int token) override; | |
| 77 | 75 |
| 78 // These are for testing. | 76 // These are for testing. |
| 79 unsigned int GetCurrentMaxAllocationWithoutRealloc() const; | 77 unsigned int GetCurrentMaxAllocationWithoutRealloc() const; |
| 80 unsigned int GetMaxAllocation() const; | 78 unsigned int GetMaxAllocation() const; |
| 81 | 79 |
| 82 private: | 80 private: |
| 83 // Tries to reallocate the ring buffer if it's not large enough for size. | 81 // Tries to reallocate the ring buffer if it's not large enough for size. |
| 84 void ReallocateRingBuffer(unsigned int size); | 82 void ReallocateRingBuffer(unsigned int size); |
| 85 | 83 |
| 86 void AllocateRingBuffer(unsigned int size); | 84 void AllocateRingBuffer(unsigned int size); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 } | 188 } |
| 191 | 189 |
| 192 unsigned int num_elements() const { | 190 unsigned int num_elements() const { |
| 193 return size() / sizeof(T); | 191 return size() / sizeof(T); |
| 194 } | 192 } |
| 195 }; | 193 }; |
| 196 | 194 |
| 197 } // namespace gpu | 195 } // namespace gpu |
| 198 | 196 |
| 199 #endif // GPU_COMMAND_BUFFER_CLIENT_TRANSFER_BUFFER_H_ | 197 #endif // GPU_COMMAND_BUFFER_CLIENT_TRANSFER_BUFFER_H_ |
| OLD | NEW |