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 a813ad3032def52c6847c7f14586ed0d7c012045..36753e72258240c587c700ace0d81966d0ef76e4 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_; |
- } |
+ Query( |
+ QueryManager* manager, GLenum target, 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,31 @@ 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); |
} |
- uint32 submit_count() const { |
- return submit_count_; |
+ void BeginQueryHelper(GLenum target, GLuint id) { |
+ manager_->BeginQueryHelper(target, id); |
} |
- void MarkAsDeleted() { |
- service_id_ = 0; |
+ void EndQueryHelper(GLenum target) { |
+ manager_->EndQueryHelper(target); |
+ } |
+ |
+ private: |
+ friend class QueryManager; |
+ friend class QueryManagerTest; |
+ friend class base::RefCounted<Query>; |
+ |
+ uint32 submit_count() const { |
+ return submit_count_; |
} |
// The manager that owns this Query. |
QueryManager* manager_; |
- // Service side query id. |
- GLuint service_id_; |
- |
// The type of query. |
GLenum target_; |
@@ -106,18 +120,24 @@ 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(); |
+ QueryManager( |
+ CommonDecoder* decoder, |
+ bool use_arb_occlusion_query2_for_occlusion_query_boolean); |
~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,18 +145,15 @@ 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; |
- |
- // Adds to queue of queries waiting for completion. |
- void AddPendingQuery(Query* query, uint32 submit_count); |
+ // Returns false if any query is pointing to invalid shared memory. |
+ bool BeginQuery(Query* query); |
- // 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(); |
// True if there are pending queries. |
bool HavePendingQueries(); |
@@ -145,6 +162,24 @@ class GPU_EXPORT QueryManager { |
void StartTracking(Query* query); |
void StopTracking(Query* query); |
+ // Wrappers for BeginQueryARB and EndQueryARB to hide differences between |
+ // ARB_occlusion_query2 and EXT_occlusion_query_boolean. |
+ void BeginQueryHelper(GLenum target, GLuint id); |
+ void EndQueryHelper(GLenum target); |
+ |
+ // 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_; |
+ |
+ bool use_arb_occlusion_query2_for_occlusion_query_boolean_; |
+ |
// Counts the number of Queries allocated with 'this' as their manager. |
// Allows checking no Query will outlive this. |
unsigned query_count_; |