| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 virtual RingBuffer::Offset GetOffset(void* pointer) const = 0; | 53 virtual RingBuffer::Offset GetOffset(void* pointer) const = 0; |
| 54 | 54 |
| 55 virtual void DiscardBlock(void* p) = 0; | 55 virtual void DiscardBlock(void* p) = 0; |
| 56 | 56 |
| 57 virtual void FreePendingToken(void* p, unsigned int token) = 0; | 57 virtual void FreePendingToken(void* p, unsigned int token) = 0; |
| 58 | 58 |
| 59 virtual unsigned int GetSize() const = 0; | 59 virtual unsigned int GetSize() const = 0; |
| 60 | 60 |
| 61 virtual unsigned int GetFreeSize() const = 0; | 61 virtual unsigned int GetFreeSize() const = 0; |
| 62 |
| 63 virtual base::SharedMemory* GetSharedMemory() const = 0; |
| 62 }; | 64 }; |
| 63 | 65 |
| 64 // Class that manages the transfer buffer. | 66 // Class that manages the transfer buffer. |
| 65 class GPU_EXPORT TransferBuffer : public TransferBufferInterface { | 67 class GPU_EXPORT TransferBuffer : public TransferBufferInterface { |
| 66 public: | 68 public: |
| 67 TransferBuffer(CommandBufferHelper* helper); | 69 TransferBuffer(CommandBufferHelper* helper); |
| 68 ~TransferBuffer() override; | 70 ~TransferBuffer() override; |
| 69 | 71 |
| 70 // Overridden from TransferBufferInterface. | 72 // Overridden from TransferBufferInterface. |
| 71 bool Initialize(unsigned int default_buffer_size, | 73 bool Initialize(unsigned int default_buffer_size, |
| 72 unsigned int result_size, | 74 unsigned int result_size, |
| 73 unsigned int min_buffer_size, | 75 unsigned int min_buffer_size, |
| 74 unsigned int max_buffer_size, | 76 unsigned int max_buffer_size, |
| 75 unsigned int alignment, | 77 unsigned int alignment, |
| 76 unsigned int size_to_flush) override; | 78 unsigned int size_to_flush) override; |
| 77 int GetShmId() override; | 79 int GetShmId() override; |
| 78 void* GetResultBuffer() override; | 80 void* GetResultBuffer() override; |
| 79 int GetResultOffset() override; | 81 int GetResultOffset() override; |
| 80 void Free() override; | 82 void Free() override; |
| 81 bool HaveBuffer() const override; | 83 bool HaveBuffer() const override; |
| 82 void* AllocUpTo(unsigned int size, unsigned int* size_allocated) override; | 84 void* AllocUpTo(unsigned int size, unsigned int* size_allocated) override; |
| 83 void* Alloc(unsigned int size) override; | 85 void* Alloc(unsigned int size) override; |
| 84 RingBuffer::Offset GetOffset(void* pointer) const override; | 86 RingBuffer::Offset GetOffset(void* pointer) const override; |
| 85 void DiscardBlock(void* p) override; | 87 void DiscardBlock(void* p) override; |
| 86 void FreePendingToken(void* p, unsigned int token) override; | 88 void FreePendingToken(void* p, unsigned int token) override; |
| 87 unsigned int GetSize() const override; | 89 unsigned int GetSize() const override; |
| 88 unsigned int GetFreeSize() const override; | 90 unsigned int GetFreeSize() const override; |
| 91 base::SharedMemory* GetSharedMemory() const override; |
| 89 | 92 |
| 90 // These are for testing. | 93 // These are for testing. |
| 91 unsigned int GetCurrentMaxAllocationWithoutRealloc() const; | 94 unsigned int GetCurrentMaxAllocationWithoutRealloc() const; |
| 92 unsigned int GetMaxAllocation() const; | 95 unsigned int GetMaxAllocation() const; |
| 93 | 96 |
| 94 private: | 97 private: |
| 95 // Tries to reallocate the ring buffer if it's not large enough for size. | 98 // Tries to reallocate the ring buffer if it's not large enough for size. |
| 96 void ReallocateRingBuffer(unsigned int size); | 99 void ReallocateRingBuffer(unsigned int size); |
| 97 | 100 |
| 98 void AllocateRingBuffer(unsigned int size); | 101 void AllocateRingBuffer(unsigned int size); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 } | 215 } |
| 213 | 216 |
| 214 unsigned int num_elements() const { | 217 unsigned int num_elements() const { |
| 215 return size() / sizeof(T); | 218 return size() / sizeof(T); |
| 216 } | 219 } |
| 217 }; | 220 }; |
| 218 | 221 |
| 219 } // namespace gpu | 222 } // namespace gpu |
| 220 | 223 |
| 221 #endif // GPU_COMMAND_BUFFER_CLIENT_TRANSFER_BUFFER_H_ | 224 #endif // GPU_COMMAND_BUFFER_CLIENT_TRANSFER_BUFFER_H_ |
| OLD | NEW |