| 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 16 matching lines...) Expand all Loading... |
| 27 : public AsyncPixelTransferCompletionObserver { | 27 : public AsyncPixelTransferCompletionObserver { |
| 28 public: | 28 public: |
| 29 AsyncPixelTransferCompletionObserverImpl(base::subtle::Atomic32 submit_count) | 29 AsyncPixelTransferCompletionObserverImpl(base::subtle::Atomic32 submit_count) |
| 30 : submit_count_(submit_count), cancelled_(false) {} | 30 : submit_count_(submit_count), cancelled_(false) {} |
| 31 | 31 |
| 32 void Cancel() { | 32 void Cancel() { |
| 33 base::AutoLock locked(lock_); | 33 base::AutoLock locked(lock_); |
| 34 cancelled_ = true; | 34 cancelled_ = true; |
| 35 } | 35 } |
| 36 | 36 |
| 37 virtual void DidComplete(const AsyncMemoryParams& mem_params) OVERRIDE { | 37 virtual void DidComplete(const AsyncMemoryParams& mem_params) override { |
| 38 base::AutoLock locked(lock_); | 38 base::AutoLock locked(lock_); |
| 39 if (!cancelled_) { | 39 if (!cancelled_) { |
| 40 DCHECK(mem_params.buffer().get()); | 40 DCHECK(mem_params.buffer().get()); |
| 41 void* data = mem_params.GetDataAddress(); | 41 void* data = mem_params.GetDataAddress(); |
| 42 QuerySync* sync = static_cast<QuerySync*>(data); | 42 QuerySync* sync = static_cast<QuerySync*>(data); |
| 43 base::subtle::Release_Store(&sync->process_count, submit_count_); | 43 base::subtle::Release_Store(&sync->process_count, submit_count_); |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 virtual ~AsyncPixelTransferCompletionObserverImpl() {} | 48 virtual ~AsyncPixelTransferCompletionObserverImpl() {} |
| 49 | 49 |
| 50 base::subtle::Atomic32 submit_count_; | 50 base::subtle::Atomic32 submit_count_; |
| 51 | 51 |
| 52 base::Lock lock_; | 52 base::Lock lock_; |
| 53 bool cancelled_; | 53 bool cancelled_; |
| 54 | 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferCompletionObserverImpl); | 55 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferCompletionObserverImpl); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 class AsyncPixelTransfersCompletedQuery | 58 class AsyncPixelTransfersCompletedQuery |
| 59 : public QueryManager::Query, | 59 : public QueryManager::Query, |
| 60 public base::SupportsWeakPtr<AsyncPixelTransfersCompletedQuery> { | 60 public base::SupportsWeakPtr<AsyncPixelTransfersCompletedQuery> { |
| 61 public: | 61 public: |
| 62 AsyncPixelTransfersCompletedQuery( | 62 AsyncPixelTransfersCompletedQuery( |
| 63 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); | 63 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); |
| 64 | 64 |
| 65 virtual bool Begin() OVERRIDE; | 65 virtual bool Begin() override; |
| 66 virtual bool End(base::subtle::Atomic32 submit_count) OVERRIDE; | 66 virtual bool End(base::subtle::Atomic32 submit_count) override; |
| 67 virtual bool Process() OVERRIDE; | 67 virtual bool Process() override; |
| 68 virtual void Destroy(bool have_context) OVERRIDE; | 68 virtual void Destroy(bool have_context) override; |
| 69 | 69 |
| 70 protected: | 70 protected: |
| 71 virtual ~AsyncPixelTransfersCompletedQuery(); | 71 virtual ~AsyncPixelTransfersCompletedQuery(); |
| 72 | 72 |
| 73 scoped_refptr<AsyncPixelTransferCompletionObserverImpl> observer_; | 73 scoped_refptr<AsyncPixelTransferCompletionObserverImpl> observer_; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 AsyncPixelTransfersCompletedQuery::AsyncPixelTransfersCompletedQuery( | 76 AsyncPixelTransfersCompletedQuery::AsyncPixelTransfersCompletedQuery( |
| 77 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) | 77 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) |
| 78 : Query(manager, target, shm_id, shm_offset) { | 78 : Query(manager, target, shm_id, shm_offset) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 observer_->Cancel(); | 132 observer_->Cancel(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace | 135 } // namespace |
| 136 | 136 |
| 137 class AllSamplesPassedQuery : public QueryManager::Query { | 137 class AllSamplesPassedQuery : public QueryManager::Query { |
| 138 public: | 138 public: |
| 139 AllSamplesPassedQuery( | 139 AllSamplesPassedQuery( |
| 140 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset, | 140 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset, |
| 141 GLuint service_id); | 141 GLuint service_id); |
| 142 virtual bool Begin() OVERRIDE; | 142 virtual bool Begin() override; |
| 143 virtual bool End(base::subtle::Atomic32 submit_count) OVERRIDE; | 143 virtual bool End(base::subtle::Atomic32 submit_count) override; |
| 144 virtual bool Process() OVERRIDE; | 144 virtual bool Process() override; |
| 145 virtual void Destroy(bool have_context) OVERRIDE; | 145 virtual void Destroy(bool have_context) override; |
| 146 | 146 |
| 147 protected: | 147 protected: |
| 148 virtual ~AllSamplesPassedQuery(); | 148 virtual ~AllSamplesPassedQuery(); |
| 149 | 149 |
| 150 private: | 150 private: |
| 151 // Service side query id. | 151 // Service side query id. |
| 152 GLuint service_id_; | 152 GLuint service_id_; |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 AllSamplesPassedQuery::AllSamplesPassedQuery( | 155 AllSamplesPassedQuery::AllSamplesPassedQuery( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 } | 191 } |
| 192 | 192 |
| 193 AllSamplesPassedQuery::~AllSamplesPassedQuery() { | 193 AllSamplesPassedQuery::~AllSamplesPassedQuery() { |
| 194 } | 194 } |
| 195 | 195 |
| 196 class CommandsIssuedQuery : public QueryManager::Query { | 196 class CommandsIssuedQuery : public QueryManager::Query { |
| 197 public: | 197 public: |
| 198 CommandsIssuedQuery( | 198 CommandsIssuedQuery( |
| 199 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); | 199 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); |
| 200 | 200 |
| 201 virtual bool Begin() OVERRIDE; | 201 virtual bool Begin() override; |
| 202 virtual bool End(base::subtle::Atomic32 submit_count) OVERRIDE; | 202 virtual bool End(base::subtle::Atomic32 submit_count) override; |
| 203 virtual bool Process() OVERRIDE; | 203 virtual bool Process() override; |
| 204 virtual void Destroy(bool have_context) OVERRIDE; | 204 virtual void Destroy(bool have_context) override; |
| 205 | 205 |
| 206 protected: | 206 protected: |
| 207 virtual ~CommandsIssuedQuery(); | 207 virtual ~CommandsIssuedQuery(); |
| 208 | 208 |
| 209 private: | 209 private: |
| 210 base::TimeTicks begin_time_; | 210 base::TimeTicks begin_time_; |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 CommandsIssuedQuery::CommandsIssuedQuery( | 213 CommandsIssuedQuery::CommandsIssuedQuery( |
| 214 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) | 214 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 238 } | 238 } |
| 239 | 239 |
| 240 CommandsIssuedQuery::~CommandsIssuedQuery() { | 240 CommandsIssuedQuery::~CommandsIssuedQuery() { |
| 241 } | 241 } |
| 242 | 242 |
| 243 class CommandLatencyQuery : public QueryManager::Query { | 243 class CommandLatencyQuery : public QueryManager::Query { |
| 244 public: | 244 public: |
| 245 CommandLatencyQuery( | 245 CommandLatencyQuery( |
| 246 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); | 246 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); |
| 247 | 247 |
| 248 virtual bool Begin() OVERRIDE; | 248 virtual bool Begin() override; |
| 249 virtual bool End(base::subtle::Atomic32 submit_count) OVERRIDE; | 249 virtual bool End(base::subtle::Atomic32 submit_count) override; |
| 250 virtual bool Process() OVERRIDE; | 250 virtual bool Process() override; |
| 251 virtual void Destroy(bool have_context) OVERRIDE; | 251 virtual void Destroy(bool have_context) override; |
| 252 | 252 |
| 253 protected: | 253 protected: |
| 254 virtual ~CommandLatencyQuery(); | 254 virtual ~CommandLatencyQuery(); |
| 255 }; | 255 }; |
| 256 | 256 |
| 257 CommandLatencyQuery::CommandLatencyQuery( | 257 CommandLatencyQuery::CommandLatencyQuery( |
| 258 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) | 258 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) |
| 259 : Query(manager, target, shm_id, shm_offset) { | 259 : Query(manager, target, shm_id, shm_offset) { |
| 260 } | 260 } |
| 261 | 261 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 284 } | 284 } |
| 285 | 285 |
| 286 | 286 |
| 287 class AsyncReadPixelsCompletedQuery | 287 class AsyncReadPixelsCompletedQuery |
| 288 : public QueryManager::Query, | 288 : public QueryManager::Query, |
| 289 public base::SupportsWeakPtr<AsyncReadPixelsCompletedQuery> { | 289 public base::SupportsWeakPtr<AsyncReadPixelsCompletedQuery> { |
| 290 public: | 290 public: |
| 291 AsyncReadPixelsCompletedQuery( | 291 AsyncReadPixelsCompletedQuery( |
| 292 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); | 292 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); |
| 293 | 293 |
| 294 virtual bool Begin() OVERRIDE; | 294 virtual bool Begin() override; |
| 295 virtual bool End(base::subtle::Atomic32 submit_count) OVERRIDE; | 295 virtual bool End(base::subtle::Atomic32 submit_count) override; |
| 296 virtual bool Process() OVERRIDE; | 296 virtual bool Process() override; |
| 297 virtual void Destroy(bool have_context) OVERRIDE; | 297 virtual void Destroy(bool have_context) override; |
| 298 | 298 |
| 299 protected: | 299 protected: |
| 300 void Complete(); | 300 void Complete(); |
| 301 virtual ~AsyncReadPixelsCompletedQuery(); | 301 virtual ~AsyncReadPixelsCompletedQuery(); |
| 302 | 302 |
| 303 private: | 303 private: |
| 304 bool completed_; | 304 bool completed_; |
| 305 bool complete_result_; | 305 bool complete_result_; |
| 306 }; | 306 }; |
| 307 | 307 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 344 |
| 345 AsyncReadPixelsCompletedQuery::~AsyncReadPixelsCompletedQuery() { | 345 AsyncReadPixelsCompletedQuery::~AsyncReadPixelsCompletedQuery() { |
| 346 } | 346 } |
| 347 | 347 |
| 348 | 348 |
| 349 class GetErrorQuery : public QueryManager::Query { | 349 class GetErrorQuery : public QueryManager::Query { |
| 350 public: | 350 public: |
| 351 GetErrorQuery( | 351 GetErrorQuery( |
| 352 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); | 352 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); |
| 353 | 353 |
| 354 virtual bool Begin() OVERRIDE; | 354 virtual bool Begin() override; |
| 355 virtual bool End(base::subtle::Atomic32 submit_count) OVERRIDE; | 355 virtual bool End(base::subtle::Atomic32 submit_count) override; |
| 356 virtual bool Process() OVERRIDE; | 356 virtual bool Process() override; |
| 357 virtual void Destroy(bool have_context) OVERRIDE; | 357 virtual void Destroy(bool have_context) override; |
| 358 | 358 |
| 359 protected: | 359 protected: |
| 360 virtual ~GetErrorQuery(); | 360 virtual ~GetErrorQuery(); |
| 361 | 361 |
| 362 private: | 362 private: |
| 363 }; | 363 }; |
| 364 | 364 |
| 365 GetErrorQuery::GetErrorQuery( | 365 GetErrorQuery::GetErrorQuery( |
| 366 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) | 366 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) |
| 367 : Query(manager, target, shm_id, shm_offset) { | 367 : Query(manager, target, shm_id, shm_offset) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 391 } | 391 } |
| 392 | 392 |
| 393 class CommandsCompletedQuery : public QueryManager::Query { | 393 class CommandsCompletedQuery : public QueryManager::Query { |
| 394 public: | 394 public: |
| 395 CommandsCompletedQuery(QueryManager* manager, | 395 CommandsCompletedQuery(QueryManager* manager, |
| 396 GLenum target, | 396 GLenum target, |
| 397 int32 shm_id, | 397 int32 shm_id, |
| 398 uint32 shm_offset); | 398 uint32 shm_offset); |
| 399 | 399 |
| 400 // Overridden from QueryManager::Query: | 400 // Overridden from QueryManager::Query: |
| 401 virtual bool Begin() OVERRIDE; | 401 virtual bool Begin() override; |
| 402 virtual bool End(base::subtle::Atomic32 submit_count) OVERRIDE; | 402 virtual bool End(base::subtle::Atomic32 submit_count) override; |
| 403 virtual bool Process() OVERRIDE; | 403 virtual bool Process() override; |
| 404 virtual void Destroy(bool have_context) OVERRIDE; | 404 virtual void Destroy(bool have_context) override; |
| 405 | 405 |
| 406 protected: | 406 protected: |
| 407 virtual ~CommandsCompletedQuery(); | 407 virtual ~CommandsCompletedQuery(); |
| 408 | 408 |
| 409 private: | 409 private: |
| 410 scoped_ptr<gfx::GLFence> fence_; | 410 scoped_ptr<gfx::GLFence> fence_; |
| 411 }; | 411 }; |
| 412 | 412 |
| 413 CommandsCompletedQuery::CommandsCompletedQuery(QueryManager* manager, | 413 CommandsCompletedQuery::CommandsCompletedQuery(QueryManager* manager, |
| 414 GLenum target, | 414 GLenum target, |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 bool QueryManager::EndQuery(Query* query, base::subtle::Atomic32 submit_count) { | 738 bool QueryManager::EndQuery(Query* query, base::subtle::Atomic32 submit_count) { |
| 739 DCHECK(query); | 739 DCHECK(query); |
| 740 if (!RemovePendingQuery(query)) { | 740 if (!RemovePendingQuery(query)) { |
| 741 return false; | 741 return false; |
| 742 } | 742 } |
| 743 return query->End(submit_count); | 743 return query->End(submit_count); |
| 744 } | 744 } |
| 745 | 745 |
| 746 } // namespace gles2 | 746 } // namespace gles2 |
| 747 } // namespace gpu | 747 } // namespace gpu |
| OLD | NEW |