Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: gpu/command_buffer/service/query_manager.h

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h>
9
8 #include <deque> 10 #include <deque>
9 #include <vector> 11 #include <vector>
10 #include "base/atomicops.h" 12 #include "base/atomicops.h"
11 #include "base/basictypes.h"
12 #include "base/containers/hash_tables.h" 13 #include "base/containers/hash_tables.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
16 #include "gpu/command_buffer/service/feature_info.h" 18 #include "gpu/command_buffer/service/feature_info.h"
17 #include "gpu/gpu_export.h" 19 #include "gpu/gpu_export.h"
18 20
19 namespace gfx { 21 namespace gfx {
20 class GPUTimer; 22 class GPUTimer;
21 class GPUTimingClient; 23 class GPUTimingClient;
22 } 24 }
23 25
24 namespace gpu { 26 namespace gpu {
25 27
26 class GLES2Decoder; 28 class GLES2Decoder;
27 29
28 namespace gles2 { 30 namespace gles2 {
29 31
30 class FeatureInfo; 32 class FeatureInfo;
31 33
32 // This class keeps track of the queries and their state 34 // This class keeps track of the queries and their state
33 // As Queries are not shared there is one QueryManager per context. 35 // As Queries are not shared there is one QueryManager per context.
34 class GPU_EXPORT QueryManager { 36 class GPU_EXPORT QueryManager {
35 public: 37 public:
36 class GPU_EXPORT Query : public base::RefCounted<Query> { 38 class GPU_EXPORT Query : public base::RefCounted<Query> {
37 public: 39 public:
38 Query( 40 Query(QueryManager* manager,
39 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); 41 GLenum target,
42 int32_t shm_id,
43 uint32_t shm_offset);
40 44
41 GLenum target() const { 45 GLenum target() const {
42 return target_; 46 return target_;
43 } 47 }
44 48
45 bool IsDeleted() const { 49 bool IsDeleted() const {
46 return deleted_; 50 return deleted_;
47 } 51 }
48 52
49 bool IsValid() const { 53 bool IsValid() const {
50 return target() && !IsDeleted(); 54 return target() && !IsDeleted();
51 } 55 }
52 56
53 bool IsActive() const { 57 bool IsActive() const {
54 return query_state_ == kQueryState_Active; 58 return query_state_ == kQueryState_Active;
55 } 59 }
56 60
57 bool IsPaused() const { 61 bool IsPaused() const {
58 return query_state_ == kQueryState_Paused; 62 return query_state_ == kQueryState_Paused;
59 } 63 }
60 64
61 bool IsPending() const { 65 bool IsPending() const {
62 return query_state_ == kQueryState_Pending; 66 return query_state_ == kQueryState_Pending;
63 } 67 }
64 68
65 bool IsFinished() const { 69 bool IsFinished() const {
66 return query_state_ == kQueryState_Finished; 70 return query_state_ == kQueryState_Finished;
67 } 71 }
68 72
69 int32 shm_id() const { 73 int32_t shm_id() const { return shm_id_; }
70 return shm_id_;
71 }
72 74
73 uint32 shm_offset() const { 75 uint32_t shm_offset() const { return shm_offset_; }
74 return shm_offset_;
75 }
76 76
77 // Returns false if shared memory for sync is invalid. 77 // Returns false if shared memory for sync is invalid.
78 virtual bool Begin() = 0; 78 virtual bool Begin() = 0;
79 79
80 // Returns false if shared memory for sync is invalid. 80 // Returns false if shared memory for sync is invalid.
81 virtual bool End(base::subtle::Atomic32 submit_count) = 0; 81 virtual bool End(base::subtle::Atomic32 submit_count) = 0;
82 82
83 // Returns false if shared memory for sync is invalid. 83 // Returns false if shared memory for sync is invalid.
84 virtual bool QueryCounter(base::subtle::Atomic32 submit_count) = 0; 84 virtual bool QueryCounter(base::subtle::Atomic32 submit_count) = 0;
85 85
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 query_state_ = kQueryState_Paused; 119 query_state_ = kQueryState_Paused;
120 } 120 }
121 121
122 void MarkAsPending(base::subtle::Atomic32 submit_count) { 122 void MarkAsPending(base::subtle::Atomic32 submit_count) {
123 DCHECK(query_state_ == kQueryState_Active); 123 DCHECK(query_state_ == kQueryState_Active);
124 query_state_ = kQueryState_Pending; 124 query_state_ = kQueryState_Pending;
125 submit_count_ = submit_count; 125 submit_count_ = submit_count;
126 } 126 }
127 127
128 // Returns false if shared memory for sync is invalid. 128 // Returns false if shared memory for sync is invalid.
129 bool MarkAsCompleted(uint64 result); 129 bool MarkAsCompleted(uint64_t result);
130 130
131 void UnmarkAsPending() { 131 void UnmarkAsPending() {
132 DCHECK(query_state_ == kQueryState_Pending); 132 DCHECK(query_state_ == kQueryState_Pending);
133 query_state_ = kQueryState_Finished; 133 query_state_ = kQueryState_Finished;
134 } 134 }
135 135
136 // Returns false if shared memory for sync is invalid. 136 // Returns false if shared memory for sync is invalid.
137 bool AddToPendingQueue(base::subtle::Atomic32 submit_count) { 137 bool AddToPendingQueue(base::subtle::Atomic32 submit_count) {
138 return manager_->AddPendingQuery(this, submit_count); 138 return manager_->AddPendingQuery(this, submit_count);
139 } 139 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 void RunCallbacks(); 173 void RunCallbacks();
174 174
175 // The manager that owns this Query. 175 // The manager that owns this Query.
176 QueryManager* manager_; 176 QueryManager* manager_;
177 177
178 // The type of query. 178 // The type of query.
179 GLenum target_; 179 GLenum target_;
180 180
181 // The shared memory used with this Query. 181 // The shared memory used with this Query.
182 int32 shm_id_; 182 int32_t shm_id_;
183 uint32 shm_offset_; 183 uint32_t shm_offset_;
184 184
185 // Count to set process count do when completed. 185 // Count to set process count do when completed.
186 base::subtle::Atomic32 submit_count_; 186 base::subtle::Atomic32 submit_count_;
187 187
188 // Current state of the query. 188 // Current state of the query.
189 enum QueryState { 189 enum QueryState {
190 kQueryState_Initialize, // Has not been queried yet. 190 kQueryState_Initialize, // Has not been queried yet.
191 kQueryState_Active, // Query began but has not ended. 191 kQueryState_Active, // Query began but has not ended.
192 kQueryState_Paused, // Query was active but is now paused. 192 kQueryState_Paused, // Query was active but is now paused.
193 kQueryState_Pending, // Query ended, waiting for result. 193 kQueryState_Pending, // Query ended, waiting for result.
194 kQueryState_Finished, // Query received result. 194 kQueryState_Finished, // Query received result.
195 } query_state_; 195 } query_state_;
196 196
197 // True if deleted. 197 // True if deleted.
198 bool deleted_; 198 bool deleted_;
199 199
200 // List of callbacks to run when result is available. 200 // List of callbacks to run when result is available.
201 std::vector<base::Closure> callbacks_; 201 std::vector<base::Closure> callbacks_;
202 }; 202 };
203 203
204 QueryManager( 204 QueryManager(
205 GLES2Decoder* decoder, 205 GLES2Decoder* decoder,
206 FeatureInfo* feature_info); 206 FeatureInfo* feature_info);
207 ~QueryManager(); 207 ~QueryManager();
208 208
209 // Must call before destruction. 209 // Must call before destruction.
210 void Destroy(bool have_context); 210 void Destroy(bool have_context);
211 211
212 // Sets up a location to be incremented whenever a disjoint is detected. 212 // Sets up a location to be incremented whenever a disjoint is detected.
213 void SetDisjointSync(int32 shm_id, uint32 shm_offset); 213 void SetDisjointSync(int32_t shm_id, uint32_t shm_offset);
214 214
215 // Creates a Query for the given query. 215 // Creates a Query for the given query.
216 Query* CreateQuery( 216 Query* CreateQuery(GLenum target,
217 GLenum target, GLuint client_id, int32 shm_id, uint32 shm_offset); 217 GLuint client_id,
218 int32_t shm_id,
219 uint32_t shm_offset);
218 220
219 // Gets the query info for the given query. 221 // Gets the query info for the given query.
220 Query* GetQuery(GLuint client_id); 222 Query* GetQuery(GLuint client_id);
221 223
222 // Gets the currently active query for a target. 224 // Gets the currently active query for a target.
223 Query* GetActiveQuery(GLenum target); 225 Query* GetActiveQuery(GLenum target);
224 226
225 // Removes a query info for the given query. 227 // Removes a query info for the given query.
226 void RemoveQuery(GLuint client_id); 228 void RemoveQuery(GLuint client_id);
227 229
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 339
338 scoped_refptr<gfx::GPUTimingClient> gpu_timing_client_; 340 scoped_refptr<gfx::GPUTimingClient> gpu_timing_client_;
339 341
340 DISALLOW_COPY_AND_ASSIGN(QueryManager); 342 DISALLOW_COPY_AND_ASSIGN(QueryManager);
341 }; 343 };
342 344
343 } // namespace gles2 345 } // namespace gles2
344 } // namespace gpu 346 } // namespace gpu
345 347
346 #endif // GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ 348 #endif // GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/program_manager_unittest.cc ('k') | gpu/command_buffer/service/query_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698