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_SERVICE_BUFFER_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | |
14 #include "gpu/command_buffer/service/gl_utils.h" | 15 #include "gpu/command_buffer/service/gl_utils.h" |
15 #include "gpu/gpu_export.h" | 16 #include "gpu/gpu_export.h" |
16 | 17 |
17 namespace gpu { | 18 namespace gpu { |
19 | |
20 class CommonDecoder; | |
21 | |
18 namespace gles2 { | 22 namespace gles2 { |
19 | 23 |
20 // This class keeps track of the buffers and their sizes so we can do | 24 // This class keeps track of the buffers and their sizes so we can do |
21 // bounds checking. | 25 // bounds checking. |
22 // | 26 // |
23 // NOTE: To support shared resources an instance of this class will need to be | 27 // NOTE: To support shared resources an instance of this class will need to be |
24 // shared by multiple GLES2Decoders. | 28 // shared by multiple GLES2Decoders. |
25 class GPU_EXPORT BufferManager { | 29 class GPU_EXPORT BufferManager { |
26 public: | 30 public: |
27 // Info about Buffers currently in the system. | 31 // Info about Buffers currently in the system. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 | 116 |
113 bool shadowed() const { | 117 bool shadowed() const { |
114 return shadowed_; | 118 return shadowed_; |
115 } | 119 } |
116 | 120 |
117 void MarkAsDeleted() { | 121 void MarkAsDeleted() { |
118 deleted_ = true; | 122 deleted_ = true; |
119 } | 123 } |
120 | 124 |
121 void SetInfo(GLsizeiptr size, GLenum usage, bool shadow); | 125 void SetInfo(GLsizeiptr size, GLenum usage, bool shadow); |
126 void SetInfo(GLsizeiptr size, GLenum usage, CommonDecoder* decoder, | |
127 int32 shm_id, uint32 shm_offset); | |
122 | 128 |
123 // Clears any cache of index ranges. | 129 // Clears any cache of index ranges. |
124 void ClearCache(); | 130 void ClearCache(); |
125 | 131 |
126 // The manager that owns this BufferInfo. | 132 // The manager that owns this BufferInfo. |
127 BufferManager* manager_; | 133 BufferManager* manager_; |
128 | 134 |
129 // True if deleted. | 135 // True if deleted. |
130 bool deleted_; | 136 bool deleted_; |
131 | 137 |
(...skipping 14 matching lines...) Expand all Loading... | |
146 // Whether or not the data is shadowed. | 152 // Whether or not the data is shadowed. |
147 bool shadowed_; | 153 bool shadowed_; |
148 | 154 |
149 // A copy of the data in the buffer. This data is only kept if the target | 155 // A copy of the data in the buffer. This data is only kept if the target |
150 // is backed_ = true. | 156 // is backed_ = true. |
151 scoped_array<int8> shadow_; | 157 scoped_array<int8> shadow_; |
152 | 158 |
153 // A map of ranges to the highest value in that range of a certain type. | 159 // A map of ranges to the highest value in that range of a certain type. |
154 typedef std::map<Range, GLuint, Range::Less> RangeToMaxValueMap; | 160 typedef std::map<Range, GLuint, Range::Less> RangeToMaxValueMap; |
155 RangeToMaxValueMap range_set_; | 161 RangeToMaxValueMap range_set_; |
162 | |
163 // The decoder pointer is reset if the decoder is destroyed. | |
164 base::WeakPtr<CommonDecoder> decoder_; | |
greggman
2012/05/24 20:56:00
I'm a little leary of tracking decoders per buffer
| |
165 | |
166 // The shared memory used with this Buffer. | |
167 int32 shm_id_; | |
168 uint32 shm_offset_; | |
156 }; | 169 }; |
157 | 170 |
158 BufferManager(); | 171 BufferManager(); |
159 ~BufferManager(); | 172 ~BufferManager(); |
160 | 173 |
161 // Must call before destruction. | 174 // Must call before destruction. |
162 void Destroy(bool have_context); | 175 void Destroy(bool have_context); |
163 | 176 |
164 // Creates a BufferInfo for the given buffer. | 177 // Creates a BufferInfo for the given buffer. |
165 void CreateBufferInfo(GLuint client_id, GLuint service_id); | 178 void CreateBufferInfo(GLuint client_id, GLuint service_id); |
166 | 179 |
167 // Gets the buffer info for the given buffer. | 180 // Gets the buffer info for the given buffer. |
168 BufferInfo* GetBufferInfo(GLuint client_id); | 181 BufferInfo* GetBufferInfo(GLuint client_id); |
169 | 182 |
170 // Removes a buffer info for the given buffer. | 183 // Removes a buffer info for the given buffer. |
171 void RemoveBufferInfo(GLuint client_id); | 184 void RemoveBufferInfo(GLuint client_id); |
172 | 185 |
173 // Gets a client id for a given service id. | 186 // Gets a client id for a given service id. |
174 bool GetClientId(GLuint service_id, GLuint* client_id) const; | 187 bool GetClientId(GLuint service_id, GLuint* client_id) const; |
175 | 188 |
176 // Sets the size and usage of a buffer. | 189 // Sets the size and usage of a buffer. |
177 void SetInfo(BufferInfo* info, GLsizeiptr size, GLenum usage); | 190 void SetInfo(BufferInfo* info, GLsizeiptr size, GLenum usage); |
178 | 191 |
192 // Sets the size, usage and shared memory of a buffer. | |
193 void SetInfo(BufferInfo* info, GLsizeiptr size, GLenum usage, | |
194 CommonDecoder* decoder, int32 shm_id, uint32 shm_offset); | |
195 | |
179 // Sets the target of a buffer. Returns false if the target can not be set. | 196 // Sets the target of a buffer. Returns false if the target can not be set. |
180 bool SetTarget(BufferInfo* info, GLenum target); | 197 bool SetTarget(BufferInfo* info, GLenum target); |
181 | 198 |
182 void set_allow_buffers_on_multiple_targets(bool allow) { | 199 void set_allow_buffers_on_multiple_targets(bool allow) { |
183 allow_buffers_on_multiple_targets_ = allow; | 200 allow_buffers_on_multiple_targets_ = allow; |
184 } | 201 } |
185 | 202 |
186 private: | 203 private: |
187 void UpdateMemRepresented(); | 204 void UpdateMemRepresented(); |
188 | 205 |
(...skipping 16 matching lines...) Expand all Loading... | |
205 | 222 |
206 bool have_context_; | 223 bool have_context_; |
207 | 224 |
208 DISALLOW_COPY_AND_ASSIGN(BufferManager); | 225 DISALLOW_COPY_AND_ASSIGN(BufferManager); |
209 }; | 226 }; |
210 | 227 |
211 } // namespace gles2 | 228 } // namespace gles2 |
212 } // namespace gpu | 229 } // namespace gpu |
213 | 230 |
214 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ | 231 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ |
OLD | NEW |