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 #ifndef GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "gpu/command_buffer/service/feature_info.h" |
14 #include "gpu/command_buffer/service/gl_utils.h" | 15 #include "gpu/command_buffer/service/gl_utils.h" |
15 #include "gpu/gpu_export.h" | 16 #include "gpu/gpu_export.h" |
16 | 17 |
17 namespace gpu { | 18 namespace gpu { |
18 | 19 |
19 class CommonDecoder; | 20 class CommonDecoder; |
20 | 21 |
21 namespace gles2 { | 22 namespace gles2 { |
22 | 23 |
| 24 class FeatureInfo; |
| 25 |
23 // This class keeps track of the queries and their state | 26 // This class keeps track of the queries and their state |
24 // As Queries are not shared there is one QueryManager per context. | 27 // As Queries are not shared there is one QueryManager per context. |
25 class GPU_EXPORT QueryManager { | 28 class GPU_EXPORT QueryManager { |
26 public: | 29 public: |
27 class GPU_EXPORT Query : public base::RefCounted<Query> { | 30 class GPU_EXPORT Query : public base::RefCounted<Query> { |
28 public: | 31 public: |
29 typedef scoped_refptr<Query> Ref; | 32 typedef scoped_refptr<Query> Ref; |
30 | 33 |
31 Query( | 34 Query( |
32 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); | 35 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 125 |
123 // True if in the queue. | 126 // True if in the queue. |
124 bool pending_; | 127 bool pending_; |
125 | 128 |
126 // True if deleted. | 129 // True if deleted. |
127 bool deleted_; | 130 bool deleted_; |
128 }; | 131 }; |
129 | 132 |
130 QueryManager( | 133 QueryManager( |
131 CommonDecoder* decoder, | 134 CommonDecoder* decoder, |
132 bool use_arb_occlusion_query2_for_occlusion_query_boolean); | 135 FeatureInfo* feature_info); |
133 ~QueryManager(); | 136 ~QueryManager(); |
134 | 137 |
135 // Must call before destruction. | 138 // Must call before destruction. |
136 void Destroy(bool have_context); | 139 void Destroy(bool have_context); |
137 | 140 |
138 // Creates a Query for the given query. | 141 // Creates a Query for the given query. |
139 Query* CreateQuery( | 142 Query* CreateQuery( |
140 GLenum target, GLuint client_id, int32 shm_id, uint32 shm_offset); | 143 GLenum target, GLuint client_id, int32 shm_id, uint32 shm_offset); |
141 | 144 |
142 // Gets the query info for the given query. | 145 // Gets the query info for the given query. |
(...skipping 25 matching lines...) Expand all Loading... |
168 void EndQueryHelper(GLenum target); | 171 void EndQueryHelper(GLenum target); |
169 | 172 |
170 // Adds to queue of queries waiting for completion. | 173 // Adds to queue of queries waiting for completion. |
171 // Returns false if any query is pointing to invalid shared memory. | 174 // Returns false if any query is pointing to invalid shared memory. |
172 bool AddPendingQuery(Query* query, uint32 submit_count); | 175 bool AddPendingQuery(Query* query, uint32 submit_count); |
173 | 176 |
174 // Removes a query from the queue of pending queries. | 177 // Removes a query from the queue of pending queries. |
175 // Returns false if any query is pointing to invalid shared memory. | 178 // Returns false if any query is pointing to invalid shared memory. |
176 bool RemovePendingQuery(Query* query); | 179 bool RemovePendingQuery(Query* query); |
177 | 180 |
| 181 // Returns a target used for the underlying GL extension |
| 182 // used to emulate a query. |
| 183 GLenum AdjustTargetForEmulation(GLenum target); |
| 184 |
178 // Used to validate shared memory. | 185 // Used to validate shared memory. |
179 CommonDecoder* decoder_; | 186 CommonDecoder* decoder_; |
180 | 187 |
181 bool use_arb_occlusion_query2_for_occlusion_query_boolean_; | 188 bool use_arb_occlusion_query2_for_occlusion_query_boolean_; |
| 189 bool use_arb_occlusion_query_for_occlusion_query_boolean_; |
182 | 190 |
183 // Counts the number of Queries allocated with 'this' as their manager. | 191 // Counts the number of Queries allocated with 'this' as their manager. |
184 // Allows checking no Query will outlive this. | 192 // Allows checking no Query will outlive this. |
185 unsigned query_count_; | 193 unsigned query_count_; |
186 | 194 |
187 // Info for each query in the system. | 195 // Info for each query in the system. |
188 typedef base::hash_map<GLuint, Query::Ref> QueryMap; | 196 typedef base::hash_map<GLuint, Query::Ref> QueryMap; |
189 QueryMap queries_; | 197 QueryMap queries_; |
190 | 198 |
191 // Queries waiting for completion. | 199 // Queries waiting for completion. |
192 typedef std::deque<Query::Ref> QueryQueue; | 200 typedef std::deque<Query::Ref> QueryQueue; |
193 QueryQueue pending_queries_; | 201 QueryQueue pending_queries_; |
194 | 202 |
195 DISALLOW_COPY_AND_ASSIGN(QueryManager); | 203 DISALLOW_COPY_AND_ASSIGN(QueryManager); |
196 }; | 204 }; |
197 | 205 |
198 } // namespace gles2 | 206 } // namespace gles2 |
199 } // namespace gpu | 207 } // namespace gpu |
200 | 208 |
201 #endif // GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ | 209 #endif // GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ |
OLD | NEW |