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 85e273c6c3a02b570cc87b634823c577eaaf63a8..c8ccace5cab45dc08b8a41a78f4b02e6afd45c8d 100644 |
--- a/gpu/command_buffer/service/query_manager.cc |
+++ b/gpu/command_buffer/service/query_manager.cc |
@@ -12,6 +12,7 @@ |
#include "base/time/time.h" |
#include "gpu/command_buffer/common/gles2_cmd_format.h" |
#include "gpu/command_buffer/service/async_pixel_transfer_manager.h" |
+#include "gpu/command_buffer/service/cmd_buffer_engine.h" |
#include "gpu/command_buffer/service/error_state.h" |
#include "gpu/command_buffer/service/feature_info.h" |
#include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
@@ -24,8 +25,15 @@ namespace { |
class AsyncPixelTransferCompletionObserverImpl |
: public AsyncPixelTransferCompletionObserver { |
public: |
- AsyncPixelTransferCompletionObserverImpl(uint32 submit_count) |
- : submit_count_(submit_count), |
+ AsyncPixelTransferCompletionObserverImpl( |
+ base::WeakPtr<QueryManager> manager, |
+ scoped_refptr<base::MessageLoopProxy> proxy, |
+ uint32 submit_count, |
+ uint32 serial) |
+ : manager_(manager), |
+ proxy_(proxy), |
+ submit_count_(submit_count), |
+ serial_(serial), |
cancelled_(false) {} |
void Cancel() { |
@@ -46,13 +54,31 @@ class AsyncPixelTransferCompletionObserverImpl |
// submit_count was written to sync->process_count. |
base::subtle::MemoryBarrier(); |
sync->process_count = submit_count_; |
+ |
+ if (serial_) { |
+ proxy_->PostTask( |
+ FROM_HERE, |
+ base::Bind(&AsyncPixelTransferCompletionObserverImpl::SetSerial, |
+ this)); |
+ } |
} |
} |
private: |
virtual ~AsyncPixelTransferCompletionObserverImpl() {} |
+ void SetSerial() { |
+ if (!manager_.get()) |
+ return; |
+ |
+ manager_->decoder()->engine()->set_serial(serial_); |
+ } |
+ |
+ base::WeakPtr<QueryManager> manager_; |
+ scoped_refptr<base::MessageLoopProxy> proxy_; |
+ |
uint32 submit_count_; |
+ uint32 serial_; |
base::Lock lock_; |
bool cancelled_; |
@@ -99,7 +125,10 @@ bool AsyncPixelTransfersCompletedQuery::End(uint32 submit_count) { |
mem_params.shm_data_offset = shm_offset(); |
mem_params.shm_data_size = sizeof(QuerySync); |
- observer_ = new AsyncPixelTransferCompletionObserverImpl(submit_count); |
+ scoped_refptr<base::MessageLoopProxy> proxy = |
+ base::MessageLoop::current()->message_loop_proxy(); |
+ observer_ = new AsyncPixelTransferCompletionObserverImpl( |
+ manager()->AsWeakPtr(), proxy, submit_count, serial()); |
// Ask AsyncPixelTransferDelegate to run completion callback after all |
// previous async transfers are done. No guarantee that callback is run |