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_CONTEXT_GROUP_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_CONTEXT_GROUP_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_CONTEXT_GROUP_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_CONTEXT_GROUP_H_ |
7 | 7 |
8 #include <map> | |
9 #include <string> | 8 #include <string> |
10 #include <vector> | 9 #include <vector> |
11 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
12 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
13 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
14 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
17 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 16 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
18 #include "gpu/command_buffer/service/feature_info.h" | 17 #include "gpu/command_buffer/service/feature_info.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 draw_buffer_ = buf; | 176 draw_buffer_ = buf; |
178 } | 177 } |
179 | 178 |
180 bool GetBufferServiceId(GLuint client_id, GLuint* service_id) const; | 179 bool GetBufferServiceId(GLuint client_id, GLuint* service_id) const; |
181 | 180 |
182 void AddSamplerId(GLuint client_id, GLuint service_id) { | 181 void AddSamplerId(GLuint client_id, GLuint service_id) { |
183 samplers_id_map_[client_id] = service_id; | 182 samplers_id_map_[client_id] = service_id; |
184 } | 183 } |
185 | 184 |
186 bool GetSamplerServiceId(GLuint client_id, GLuint* service_id) const { | 185 bool GetSamplerServiceId(GLuint client_id, GLuint* service_id) const { |
187 std::map<GLuint, GLuint>::const_iterator iter = | 186 base::hash_map<GLuint, GLuint>::const_iterator iter = |
188 samplers_id_map_.find(client_id); | 187 samplers_id_map_.find(client_id); |
189 if (iter == samplers_id_map_.end()) | 188 if (iter == samplers_id_map_.end()) |
190 return false; | 189 return false; |
191 if (service_id) | 190 if (service_id) |
192 *service_id = iter->second; | 191 *service_id = iter->second; |
193 return true; | 192 return true; |
194 } | 193 } |
195 | 194 |
196 void RemoveSamplerId(GLuint client_id) { | 195 void RemoveSamplerId(GLuint client_id) { |
197 samplers_id_map_.erase(client_id); | 196 samplers_id_map_.erase(client_id); |
198 } | 197 } |
199 | 198 |
200 void AddTransformFeedbackId(GLuint client_id, GLuint service_id) { | 199 void AddTransformFeedbackId(GLuint client_id, GLuint service_id) { |
201 transformfeedbacks_id_map_[client_id] = service_id; | 200 transformfeedbacks_id_map_[client_id] = service_id; |
202 } | 201 } |
203 | 202 |
204 bool GetTransformFeedbackServiceId( | 203 bool GetTransformFeedbackServiceId( |
205 GLuint client_id, GLuint* service_id) const { | 204 GLuint client_id, GLuint* service_id) const { |
206 std::map<GLuint, GLuint>::const_iterator iter = | 205 base::hash_map<GLuint, GLuint>::const_iterator iter = |
207 transformfeedbacks_id_map_.find(client_id); | 206 transformfeedbacks_id_map_.find(client_id); |
208 if (iter == transformfeedbacks_id_map_.end()) | 207 if (iter == transformfeedbacks_id_map_.end()) |
209 return false; | 208 return false; |
210 if (service_id) | 209 if (service_id) |
211 *service_id = iter->second; | 210 *service_id = iter->second; |
212 return true; | 211 return true; |
213 } | 212 } |
214 | 213 |
215 void RemoveTransformFeedbackId(GLuint client_id) { | 214 void RemoveTransformFeedbackId(GLuint client_id) { |
216 transformfeedbacks_id_map_.erase(client_id); | 215 transformfeedbacks_id_map_.erase(client_id); |
217 } | 216 } |
218 | 217 |
| 218 void AddSyncId(GLuint client_id, GLsync service_id) { |
| 219 syncs_id_map_[client_id] = service_id; |
| 220 } |
| 221 |
| 222 bool GetSyncServiceId(GLuint client_id, GLsync* service_id) const { |
| 223 base::hash_map<GLuint, GLsync>::const_iterator iter = |
| 224 syncs_id_map_.find(client_id); |
| 225 if (iter == syncs_id_map_.end()) |
| 226 return false; |
| 227 if (service_id) |
| 228 *service_id = iter->second; |
| 229 return true; |
| 230 } |
| 231 |
| 232 void RemoveSyncId(GLuint client_id) { |
| 233 syncs_id_map_.erase(client_id); |
| 234 } |
| 235 |
219 private: | 236 private: |
220 friend class base::RefCounted<ContextGroup>; | 237 friend class base::RefCounted<ContextGroup>; |
221 ~ContextGroup(); | 238 ~ContextGroup(); |
222 | 239 |
223 bool CheckGLFeature(GLint min_required, GLint* v); | 240 bool CheckGLFeature(GLint min_required, GLint* v); |
224 bool CheckGLFeatureU(GLint min_required, uint32* v); | 241 bool CheckGLFeatureU(GLint min_required, uint32* v); |
225 bool QueryGLFeature(GLenum pname, GLint min_required, GLint* v); | 242 bool QueryGLFeature(GLenum pname, GLint min_required, GLint* v); |
226 bool QueryGLFeatureU(GLenum pname, GLint min_required, uint32* v); | 243 bool QueryGLFeatureU(GLenum pname, GLint min_required, uint32* v); |
227 bool HaveContexts(); | 244 bool HaveContexts(); |
228 | 245 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 277 |
261 scoped_ptr<ShaderManager> shader_manager_; | 278 scoped_ptr<ShaderManager> shader_manager_; |
262 | 279 |
263 scoped_ptr<ValuebufferManager> valuebuffer_manager_; | 280 scoped_ptr<ValuebufferManager> valuebuffer_manager_; |
264 | 281 |
265 scoped_refptr<FeatureInfo> feature_info_; | 282 scoped_refptr<FeatureInfo> feature_info_; |
266 | 283 |
267 std::vector<base::WeakPtr<gles2::GLES2Decoder> > decoders_; | 284 std::vector<base::WeakPtr<gles2::GLES2Decoder> > decoders_; |
268 | 285 |
269 // Mappings from client side IDs to service side IDs. | 286 // Mappings from client side IDs to service side IDs. |
270 std::map<GLuint, GLuint> samplers_id_map_; | 287 base::hash_map<GLuint, GLuint> samplers_id_map_; |
271 std::map<GLuint, GLuint> transformfeedbacks_id_map_; | 288 base::hash_map<GLuint, GLuint> transformfeedbacks_id_map_; |
| 289 base::hash_map<GLuint, GLsync> syncs_id_map_; |
272 | 290 |
273 GLenum draw_buffer_; | 291 GLenum draw_buffer_; |
274 | 292 |
275 DISALLOW_COPY_AND_ASSIGN(ContextGroup); | 293 DISALLOW_COPY_AND_ASSIGN(ContextGroup); |
276 }; | 294 }; |
277 | 295 |
278 } // namespace gles2 | 296 } // namespace gles2 |
279 } // namespace gpu | 297 } // namespace gpu |
280 | 298 |
281 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_GROUP_H_ | 299 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_GROUP_H_ |
282 | 300 |
283 | 301 |
OLD | NEW |