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 "../../gpu_export.h" |
8 #include "../common/buffer.h" | 9 #include "../common/buffer.h" |
9 #include "../common/compiler_specific.h" | 10 #include "../common/compiler_specific.h" |
10 #include "../common/gles2_cmd_utils.h" | 11 #include "../common/gles2_cmd_utils.h" |
11 #include "../common/scoped_ptr.h" | 12 #include "../common/scoped_ptr.h" |
12 #include "../client/ring_buffer.h" | 13 #include "../client/ring_buffer.h" |
13 | 14 |
14 namespace gpu { | 15 namespace gpu { |
15 | 16 |
16 class CommandBufferHelper; | 17 class CommandBufferHelper; |
17 | 18 |
(...skipping 25 matching lines...) Expand all Loading... |
43 private: | 44 private: |
44 unsigned int RoundToAlignment(unsigned int size) { | 45 unsigned int RoundToAlignment(unsigned int size) { |
45 return (size + alignment_ - 1) & ~(alignment_ - 1); | 46 return (size + alignment_ - 1) & ~(alignment_ - 1); |
46 } | 47 } |
47 | 48 |
48 unsigned int alignment_; | 49 unsigned int alignment_; |
49 int32 shm_id_; | 50 int32 shm_id_; |
50 }; | 51 }; |
51 | 52 |
52 // Interface for managing the transfer buffer. | 53 // Interface for managing the transfer buffer. |
53 class TransferBufferInterface { | 54 class GPU_EXPORT TransferBufferInterface { |
54 public: | 55 public: |
55 TransferBufferInterface() { } | 56 TransferBufferInterface() { } |
56 virtual ~TransferBufferInterface() { } | 57 virtual ~TransferBufferInterface() { } |
57 | 58 |
58 virtual bool Initialize( | 59 virtual bool Initialize( |
59 unsigned int buffer_size, | 60 unsigned int buffer_size, |
60 unsigned int result_size, | 61 unsigned int result_size, |
61 unsigned int min_buffer_size, | 62 unsigned int min_buffer_size, |
62 unsigned int max_buffer_size, | 63 unsigned int max_buffer_size, |
63 unsigned int alignment, | 64 unsigned int alignment, |
(...skipping 13 matching lines...) Expand all Loading... |
77 // Allocates size bytes. | 78 // Allocates size bytes. |
78 // Note: Alloc will fail if it can not return size bytes. | 79 // Note: Alloc will fail if it can not return size bytes. |
79 virtual void* Alloc(unsigned int size) = 0; | 80 virtual void* Alloc(unsigned int size) = 0; |
80 | 81 |
81 virtual RingBuffer::Offset GetOffset(void* pointer) const = 0; | 82 virtual RingBuffer::Offset GetOffset(void* pointer) const = 0; |
82 | 83 |
83 virtual void FreePendingToken(void* p, unsigned int token) = 0; | 84 virtual void FreePendingToken(void* p, unsigned int token) = 0; |
84 }; | 85 }; |
85 | 86 |
86 // Class that manages the transfer buffer. | 87 // Class that manages the transfer buffer. |
87 class TransferBuffer : public TransferBufferInterface { | 88 class GPU_EXPORT TransferBuffer : public TransferBufferInterface { |
88 public: | 89 public: |
89 TransferBuffer(CommandBufferHelper* helper); | 90 TransferBuffer(CommandBufferHelper* helper); |
90 virtual ~TransferBuffer(); | 91 virtual ~TransferBuffer(); |
91 | 92 |
92 // Overridden from TransferBufferInterface. | 93 // Overridden from TransferBufferInterface. |
93 virtual bool Initialize( | 94 virtual bool Initialize( |
94 unsigned int buffer_size, | 95 unsigned int buffer_size, |
95 unsigned int result_size, | 96 unsigned int result_size, |
96 unsigned int min_buffer_size, | 97 unsigned int min_buffer_size, |
97 unsigned int max_buffer_size, | 98 unsigned int max_buffer_size, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 void* result_buffer_; | 150 void* result_buffer_; |
150 | 151 |
151 // offset to result area | 152 // offset to result area |
152 uint32 result_shm_offset_; | 153 uint32 result_shm_offset_; |
153 | 154 |
154 // false if we failed to allocate min_buffer_size | 155 // false if we failed to allocate min_buffer_size |
155 bool usable_; | 156 bool usable_; |
156 }; | 157 }; |
157 | 158 |
158 // A class that will manage the lifetime of a transferbuffer allocation. | 159 // A class that will manage the lifetime of a transferbuffer allocation. |
159 class ScopedTransferBufferPtr { | 160 class GPU_EXPORT ScopedTransferBufferPtr { |
160 public: | 161 public: |
161 ScopedTransferBufferPtr( | 162 ScopedTransferBufferPtr( |
162 unsigned int size, | 163 unsigned int size, |
163 CommandBufferHelper* helper, | 164 CommandBufferHelper* helper, |
164 TransferBufferInterface* transfer_buffer) | 165 TransferBufferInterface* transfer_buffer) |
165 : buffer_(NULL), | 166 : buffer_(NULL), |
166 size_(0), | 167 size_(0), |
167 helper_(helper), | 168 helper_(helper), |
168 transfer_buffer_(transfer_buffer) { | 169 transfer_buffer_(transfer_buffer) { |
169 Reset(size); | 170 Reset(size); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 } | 221 } |
221 | 222 |
222 unsigned int num_elements() const { | 223 unsigned int num_elements() const { |
223 return size() / sizeof(T); | 224 return size() / sizeof(T); |
224 } | 225 } |
225 }; | 226 }; |
226 | 227 |
227 } // namespace gpu | 228 } // namespace gpu |
228 | 229 |
229 #endif // GPU_COMMAND_BUFFER_CLIENT_TRANSFER_BUFFER_H_ | 230 #endif // GPU_COMMAND_BUFFER_CLIENT_TRANSFER_BUFFER_H_ |
OLD | NEW |