Chromium Code Reviews| Index: gpu/command_buffer/service/query_manager.h |
| diff --git a/gpu/command_buffer/service/query_manager.h b/gpu/command_buffer/service/query_manager.h |
| index 8e9e46abd6c3b1b6a94ac606f365ecf278dbdd16..c9a4dfb97e19a7c4a1451c48917051de933f5e95 100644 |
| --- a/gpu/command_buffer/service/query_manager.h |
| +++ b/gpu/command_buffer/service/query_manager.h |
| @@ -28,30 +28,26 @@ class GPU_EXPORT QueryManager { |
| public: |
| typedef scoped_refptr<Query> Ref; |
| - Query(QueryManager* manager, GLuint service_id); |
| - |
| - void Initialize(GLenum target, int32 shm_id, uint32 shm_offset); |
| - |
| - bool IsInitialized() const { |
| - return target_ != 0; |
| - } |
| - |
| - GLuint service_id() const { |
| - return service_id_; |
| - } |
| + explicit Query(QueryManager* manager, GLenum target, |
|
apatrick_chromium
2012/03/13 19:24:15
explicit is redundant
|
| + int32 shm_id, uint32 shm_offset); |
| + virtual ~Query(); |
| GLenum target() const { |
| return target_; |
| } |
| bool IsDeleted() const { |
| - return service_id_ == 0; |
| + return deleted_; |
| } |
| bool IsValid() const { |
| return target() && !IsDeleted(); |
| } |
| + bool pending() const { |
| + return pending_; |
| + } |
| + |
| int32 shm_id() const { |
| return shm_id_; |
| } |
| @@ -60,16 +56,28 @@ class GPU_EXPORT QueryManager { |
| return shm_offset_; |
| } |
| - bool pending() const { |
| - return pending_; |
| + // Returns false if shared memory for sync is invalid. |
| + virtual bool Begin() = 0; |
| + |
| + // Returns false if shared memory for sync is invalid. |
| + virtual bool End(uint32 submit_count) = 0; |
| + |
| + // Returns false if shared memory for sync is invalid. |
| + virtual bool Process() = 0; |
| + |
| + virtual void Destroy(bool have_context) = 0; |
| + |
| + protected: |
| + QueryManager* manager() const { |
| + return manager_; |
| } |
| - private: |
| - friend class QueryManager; |
| - friend class QueryManagerTest; |
| - friend class base::RefCounted<Query>; |
| + void MarkAsDeleted() { |
| + deleted_ = true; |
| + } |
| - ~Query(); |
| + // Returns false if shared memory for sync is invalid. |
| + bool MarkAsCompleted(GLuint result); |
| void MarkAsPending(uint32 submit_count) { |
| DCHECK(!pending_); |
| @@ -77,25 +85,23 @@ class GPU_EXPORT QueryManager { |
| submit_count_ = submit_count; |
| } |
| - void MarkAsCompleted() { |
| - DCHECK(pending_); |
| - pending_ = false; |
| + // Returns false if shared memory for sync is invalid. |
| + bool AddToPendingQueue(uint32 submit_count) { |
| + return manager_->AddPendingQuery(this, submit_count); |
| } |
| + private: |
| + friend class QueryManager; |
| + friend class QueryManagerTest; |
| + friend class base::RefCounted<Query>; |
| + |
| uint32 submit_count() const { |
| return submit_count_; |
| } |
| - void MarkAsDeleted() { |
| - service_id_ = 0; |
| - } |
| - |
| // The manager that owns this Query. |
| QueryManager* manager_; |
| - // Service side query id. |
| - GLuint service_id_; |
| - |
| // The type of query. |
| GLenum target_; |
| @@ -106,18 +112,22 @@ class GPU_EXPORT QueryManager { |
| // Count to set process count do when completed. |
| uint32 submit_count_; |
| - // True if in the Queue. |
| + // True if in the queue. |
| bool pending_; |
| + |
| + // True if deleted. |
| + bool deleted_; |
| }; |
| - QueryManager(); |
| + explicit QueryManager(CommonDecoder* decoder); |
| ~QueryManager(); |
| // Must call before destruction. |
| void Destroy(bool have_context); |
| // Creates a Query for the given query. |
| - Query* CreateQuery(GLuint client_id, GLuint service_id); |
| + Query* CreateQuery( |
| + GLenum target, GLuint client_id, int32 shm_id, uint32 shm_offset); |
| // Gets the query info for the given query. |
| Query* GetQuery(GLuint client_id); |
| @@ -125,23 +135,31 @@ class GPU_EXPORT QueryManager { |
| // Removes a query info for the given query. |
| void RemoveQuery(GLuint client_id); |
| - // Gets a client id for a given service id. |
| - bool GetClientId(GLuint service_id, GLuint* client_id) const; |
| + // Returns false if any query is pointing to invalid shared memory. |
| + bool BeginQuery(Query* query); |
| - // Adds to queue of queries waiting for completion. |
| - void AddPendingQuery(Query* query, uint32 submit_count); |
| - |
| - // Removes a query from the queue of pending queries. |
| - void RemovePendingQuery(Query* query); |
| + // Returns false if any query is pointing to invalid shared memory. |
| + bool EndQuery(Query* query, uint32 submit_count); |
| // Processes pending queries. Returns false if any queries are pointing |
| // to invalid shared memory. |
| - bool ProcessPendingQueries(CommonDecoder* decoder); |
| + bool ProcessPendingQueries(); |
| private: |
| void StartTracking(Query* query); |
| void StopTracking(Query* query); |
| + // Adds to queue of queries waiting for completion. |
| + // Returns false if any query is pointing to invalid shared memory. |
| + bool AddPendingQuery(Query* query, uint32 submit_count); |
| + |
| + // Removes a query from the queue of pending queries. |
| + // Returns false if any query is pointing to invalid shared memory. |
| + bool RemovePendingQuery(Query* query); |
| + |
| + // Used to validate shared memory. |
| + CommonDecoder* decoder_; |
| + |
| // Counts the number of Queries allocated with 'this' as their manager. |
| // Allows checking no Query will outlive this. |
| unsigned query_count_; |