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 | 6 |
7 #include "base/atomicops.h" | 7 #include "base/atomicops.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 281 |
282 void CommandLatencyQuery::Destroy(bool /* have_context */) { | 282 void CommandLatencyQuery::Destroy(bool /* have_context */) { |
283 if (!IsDeleted()) { | 283 if (!IsDeleted()) { |
284 MarkAsDeleted(); | 284 MarkAsDeleted(); |
285 } | 285 } |
286 } | 286 } |
287 | 287 |
288 CommandLatencyQuery::~CommandLatencyQuery() { | 288 CommandLatencyQuery::~CommandLatencyQuery() { |
289 } | 289 } |
290 | 290 |
| 291 |
| 292 class AsyncReadPixelsCompletedQuery |
| 293 : public QueryManager::Query, |
| 294 public base::SupportsWeakPtr<AsyncReadPixelsCompletedQuery> { |
| 295 public: |
| 296 AsyncReadPixelsCompletedQuery( |
| 297 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); |
| 298 |
| 299 virtual bool Begin() OVERRIDE; |
| 300 virtual bool End(uint32 submit_count) OVERRIDE; |
| 301 virtual bool Process() OVERRIDE; |
| 302 virtual void Destroy(bool have_context) OVERRIDE; |
| 303 |
| 304 protected: |
| 305 void Complete(); |
| 306 virtual ~AsyncReadPixelsCompletedQuery(); |
| 307 }; |
| 308 |
| 309 AsyncReadPixelsCompletedQuery::AsyncReadPixelsCompletedQuery( |
| 310 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) |
| 311 : Query(manager, target, shm_id, shm_offset) { |
| 312 } |
| 313 |
| 314 bool AsyncReadPixelsCompletedQuery::Begin() { |
| 315 return true; |
| 316 } |
| 317 |
| 318 bool AsyncReadPixelsCompletedQuery::End(uint32 submit_count) { |
| 319 if (!AddToPendingQueue(submit_count)) { |
| 320 return false; |
| 321 } |
| 322 manager()->decoder()->WaitForReadPixels( |
| 323 base::Bind(&AsyncReadPixelsCompletedQuery::Complete, |
| 324 AsWeakPtr())); |
| 325 |
| 326 return true; |
| 327 } |
| 328 |
| 329 void AsyncReadPixelsCompletedQuery::Complete() { |
| 330 MarkAsCompleted(1); |
| 331 } |
| 332 |
| 333 bool AsyncReadPixelsCompletedQuery::Process() { |
| 334 return true; |
| 335 } |
| 336 |
| 337 void AsyncReadPixelsCompletedQuery::Destroy(bool /* have_context */) { |
| 338 if (!IsDeleted()) { |
| 339 MarkAsDeleted(); |
| 340 } |
| 341 } |
| 342 |
| 343 AsyncReadPixelsCompletedQuery::~AsyncReadPixelsCompletedQuery() { |
| 344 } |
| 345 |
| 346 |
291 class GetErrorQuery : public QueryManager::Query { | 347 class GetErrorQuery : public QueryManager::Query { |
292 public: | 348 public: |
293 GetErrorQuery( | 349 GetErrorQuery( |
294 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); | 350 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); |
295 | 351 |
296 virtual bool Begin() OVERRIDE; | 352 virtual bool Begin() OVERRIDE; |
297 virtual bool End(uint32 submit_count) OVERRIDE; | 353 virtual bool End(uint32 submit_count) OVERRIDE; |
298 virtual bool Process() OVERRIDE; | 354 virtual bool Process() OVERRIDE; |
299 virtual void Destroy(bool have_context) OVERRIDE; | 355 virtual void Destroy(bool have_context) OVERRIDE; |
300 | 356 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 case GL_COMMANDS_ISSUED_CHROMIUM: | 428 case GL_COMMANDS_ISSUED_CHROMIUM: |
373 query = new CommandsIssuedQuery(this, target, shm_id, shm_offset); | 429 query = new CommandsIssuedQuery(this, target, shm_id, shm_offset); |
374 break; | 430 break; |
375 case GL_LATENCY_QUERY_CHROMIUM: | 431 case GL_LATENCY_QUERY_CHROMIUM: |
376 query = new CommandLatencyQuery(this, target, shm_id, shm_offset); | 432 query = new CommandLatencyQuery(this, target, shm_id, shm_offset); |
377 break; | 433 break; |
378 case GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM: | 434 case GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM: |
379 query = new AsyncPixelTransfersCompletedQuery( | 435 query = new AsyncPixelTransfersCompletedQuery( |
380 this, target, shm_id, shm_offset); | 436 this, target, shm_id, shm_offset); |
381 break; | 437 break; |
| 438 case GL_ASYNC_READ_PIXELS_COMPLETED_CHROMIUM: |
| 439 query = new AsyncReadPixelsCompletedQuery( |
| 440 this, target, shm_id, shm_offset); |
| 441 break; |
382 case GL_GET_ERROR_QUERY_CHROMIUM: | 442 case GL_GET_ERROR_QUERY_CHROMIUM: |
383 query = new GetErrorQuery(this, target, shm_id, shm_offset); | 443 query = new GetErrorQuery(this, target, shm_id, shm_offset); |
384 break; | 444 break; |
385 default: { | 445 default: { |
386 GLuint service_id = 0; | 446 GLuint service_id = 0; |
387 glGenQueriesARB(1, &service_id); | 447 glGenQueriesARB(1, &service_id); |
388 DCHECK_NE(0u, service_id); | 448 DCHECK_NE(0u, service_id); |
389 query = new AllSamplesPassedQuery( | 449 query = new AllSamplesPassedQuery( |
390 this, target, shm_id, shm_offset, service_id); | 450 this, target, shm_id, shm_offset, service_id); |
391 break; | 451 break; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 bool QueryManager::EndQuery(Query* query, uint32 submit_count) { | 670 bool QueryManager::EndQuery(Query* query, uint32 submit_count) { |
611 DCHECK(query); | 671 DCHECK(query); |
612 if (!RemovePendingQuery(query)) { | 672 if (!RemovePendingQuery(query)) { |
613 return false; | 673 return false; |
614 } | 674 } |
615 return query->End(submit_count); | 675 return query->End(submit_count); |
616 } | 676 } |
617 | 677 |
618 } // namespace gles2 | 678 } // namespace gles2 |
619 } // namespace gpu | 679 } // namespace gpu |
OLD | NEW |