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