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 #include "gpu/command_buffer/service/query_manager.h" | 5 #include "gpu/command_buffer/service/query_manager.h" |
6 #include "base/atomicops.h" | 6 #include "base/atomicops.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 DCHECK(queries_.empty()); | 225 DCHECK(queries_.empty()); |
226 | 226 |
227 // If this triggers, that means something is keeping a reference to | 227 // If this triggers, that means something is keeping a reference to |
228 // a Query belonging to this. | 228 // a Query belonging to this. |
229 CHECK_EQ(query_count_, 0u); | 229 CHECK_EQ(query_count_, 0u); |
230 } | 230 } |
231 | 231 |
232 void QueryManager::Destroy(bool have_context) { | 232 void QueryManager::Destroy(bool have_context) { |
233 pending_queries_.clear(); | 233 pending_queries_.clear(); |
234 while (!queries_.empty()) { | 234 while (!queries_.empty()) { |
235 Query* query = queries_.begin()->second; | 235 Query* query = queries_.begin()->second.get(); |
236 query->Destroy(have_context); | 236 query->Destroy(have_context); |
237 queries_.erase(queries_.begin()); | 237 queries_.erase(queries_.begin()); |
238 } | 238 } |
239 } | 239 } |
240 | 240 |
241 QueryManager::Query* QueryManager::CreateQuery( | 241 QueryManager::Query* QueryManager::CreateQuery( |
242 GLenum target, GLuint client_id, int32 shm_id, uint32 shm_offset) { | 242 GLenum target, GLuint client_id, int32 shm_id, uint32 shm_offset) { |
243 Query::Ref query; | 243 Query::Ref query; |
244 switch (target) { | 244 switch (target) { |
245 case GL_COMMANDS_ISSUED_CHROMIUM: | 245 case GL_COMMANDS_ISSUED_CHROMIUM: |
246 query = new CommandsIssuedQuery(this, target, shm_id, shm_offset); | 246 query = new CommandsIssuedQuery(this, target, shm_id, shm_offset); |
247 break; | 247 break; |
248 case GL_LATENCY_QUERY_CHROMIUM: | 248 case GL_LATENCY_QUERY_CHROMIUM: |
249 query = new CommandLatencyQuery(this, target, shm_id, shm_offset); | 249 query = new CommandLatencyQuery(this, target, shm_id, shm_offset); |
250 break; | 250 break; |
251 case GL_GET_ERROR_QUERY_CHROMIUM: | 251 case GL_GET_ERROR_QUERY_CHROMIUM: |
252 query = new GetErrorQuery(this, target, shm_id, shm_offset); | 252 query = new GetErrorQuery(this, target, shm_id, shm_offset); |
253 break; | 253 break; |
254 default: { | 254 default: { |
255 GLuint service_id = 0; | 255 GLuint service_id = 0; |
256 glGenQueriesARB(1, &service_id); | 256 glGenQueriesARB(1, &service_id); |
257 DCHECK_NE(0u, service_id); | 257 DCHECK_NE(0u, service_id); |
258 query = new AllSamplesPassedQuery( | 258 query = new AllSamplesPassedQuery( |
259 this, target, shm_id, shm_offset, service_id); | 259 this, target, shm_id, shm_offset, service_id); |
260 break; | 260 break; |
261 } | 261 } |
262 } | 262 } |
263 std::pair<QueryMap::iterator, bool> result = | 263 std::pair<QueryMap::iterator, bool> result = |
264 queries_.insert(std::make_pair(client_id, query)); | 264 queries_.insert(std::make_pair(client_id, query)); |
265 DCHECK(result.second); | 265 DCHECK(result.second); |
266 return query.get(); | 266 return query.get(); |
267 } | 267 } |
268 | 268 |
269 QueryManager::Query* QueryManager::GetQuery( | 269 QueryManager::Query* QueryManager::GetQuery( |
270 GLuint client_id) { | 270 GLuint client_id) { |
271 QueryMap::iterator it = queries_.find(client_id); | 271 QueryMap::iterator it = queries_.find(client_id); |
| 272 return .get()()); |
272 return it != queries_.end() ? it->second : NULL; | 273 return it != queries_.end() ? it->second : NULL; |
273 } | 274 } |
274 | 275 |
275 void QueryManager::RemoveQuery(GLuint client_id) { | 276 void QueryManager::RemoveQuery(GLuint client_id) { |
276 QueryMap::iterator it = queries_.find(client_id); | 277 QueryMap::iterator it = queries_.find(client_id); |
277 if (it != queries_.end()) { | 278 if (it != queries_.end()) { |
278 Query* query = it->second; | 279 Query* query = it->second.get(); |
279 RemovePendingQuery(query); | 280 RemovePendingQuery(query); |
280 query->MarkAsDeleted(); | 281 query->MarkAsDeleted(); |
281 queries_.erase(it); | 282 queries_.erase(it); |
282 } | 283 } |
283 } | 284 } |
284 | 285 |
285 void QueryManager::StartTracking(QueryManager::Query* /* query */) { | 286 void QueryManager::StartTracking(QueryManager::Query* /* query */) { |
286 ++query_count_; | 287 ++query_count_; |
287 } | 288 } |
288 | 289 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 if (!RemovePendingQuery(query)) { | 424 if (!RemovePendingQuery(query)) { |
424 return false; | 425 return false; |
425 } | 426 } |
426 return query->End(submit_count); | 427 return query->End(submit_count); |
427 } | 428 } |
428 | 429 |
429 } // namespace gles2 | 430 } // namespace gles2 |
430 } // namespace gpu | 431 } // namespace gpu |
431 | 432 |
432 | 433 |
OLD | NEW |