Index: gpu/command_buffer/service/query_manager.cc |
diff --git a/gpu/command_buffer/service/query_manager.cc b/gpu/command_buffer/service/query_manager.cc |
index 61a8d7f55c68794ff38eccdd011005c3cef5f54c..c71a8bcd0fd983b2dbe1c76b7bc986ccf3fd5795 100644 |
--- a/gpu/command_buffer/service/query_manager.cc |
+++ b/gpu/command_buffer/service/query_manager.cc |
@@ -4,11 +4,13 @@ |
#include "gpu/command_buffer/service/query_manager.h" |
#include "base/atomicops.h" |
+#include "base/bind.h" |
#include "base/logging.h" |
#include "base/time.h" |
#include "gpu/command_buffer/common/gles2_cmd_format.h" |
#include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
#include "gpu/command_buffer/service/feature_info.h" |
+#include "ui/gl/async_pixel_transfer_delegate.h" |
namespace gpu { |
namespace gles2 { |
@@ -162,7 +164,9 @@ void CommandLatencyQuery::Destroy(bool /* have_context */) { |
CommandLatencyQuery::~CommandLatencyQuery() { |
} |
-class AsyncPixelTransfersCompletedQuery : public QueryManager::Query { |
+class AsyncPixelTransfersCompletedQuery |
+ : public QueryManager::Query |
+ , public base::SupportsWeakPtr<AsyncPixelTransfersCompletedQuery> { |
apatrick
2012/12/03 21:23:59
style nit: comma wants to be on line above.
epennerAtGoogle
2012/12/04 19:56:48
Done.
|
public: |
AsyncPixelTransfersCompletedQuery( |
QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); |
@@ -172,6 +176,8 @@ class AsyncPixelTransfersCompletedQuery : public QueryManager::Query { |
virtual bool Process() OVERRIDE; |
virtual void Destroy(bool have_context) OVERRIDE; |
+ void MarkAsCompletedCallback() { MarkAsCompleted(1); } |
+ |
protected: |
virtual ~AsyncPixelTransfersCompletedQuery(); |
}; |
@@ -186,12 +192,25 @@ bool AsyncPixelTransfersCompletedQuery::Begin() { |
} |
bool AsyncPixelTransfersCompletedQuery::End(uint32 submit_count) { |
- // TODO(epenner): Mark completion via an async task. |
- // TODO(epenner): This will be a boolean to start, indicating |
- // completion of all tasks in the query. We could change this |
- // to return a count of tasks completed instead. |
MarkAsPending(submit_count); |
- return MarkAsCompleted(1); |
+ |
+ // This will call MarkAsCompleted(1) as a reply to a task on |
+ // the async upload thread, such that it occurs after all previous |
+ // async transfers have completed. |
+ gfx::AsyncPixelTransferDelegate::Get()->AsyncNotifyCompletion( |
+ base::Bind( |
+ &AsyncPixelTransfersCompletedQuery::MarkAsCompletedCallback, |
+ AsWeakPtr())); |
+ |
+ // TODO: Could we possibly trigger the completion on |
+ // the upload thread by writing to the query shared memory |
+ // directly? |
+ |
+ // TODO: Confirm if the above async task is sufficient. |
+ // Since it is an async task, the bool return value is |
+ // disregarded. It is also called outside the normal |
+ // flow, and never called if this object is destroyed. |
+ return true; |
} |
bool AsyncPixelTransfersCompletedQuery::Process() { |