OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 UI_GL_GPU_TIMING_H_ | 5 #ifndef UI_GL_GPU_TIMING_H_ |
6 #define UI_GL_GPU_TIMING_H_ | 6 #define UI_GL_GPU_TIMING_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <memory> | 10 #include <memory> |
9 #include <queue> | 11 #include <queue> |
10 | 12 |
11 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
13 #include "ui/gl/gl_export.h" | 16 #include "ui/gl/gl_export.h" |
14 | 17 |
15 // The gpu_timing classes handles the abstraction of GL GPU Timing extensions | 18 // The gpu_timing classes handles the abstraction of GL GPU Timing extensions |
16 // into a common set of functions. Currently the different timer extensions that | 19 // into a common set of functions. Currently the different timer extensions that |
17 // are supported are EXT_timer_query, ARB_timer_query and | 20 // are supported are EXT_timer_query, ARB_timer_query and |
18 // EXT_disjoint_timer_query. | 21 // EXT_disjoint_timer_query. |
19 // | 22 // |
20 // Explanation of Classes: | 23 // Explanation of Classes: |
21 // GPUTiming - GPU Timing is a private class which is only owned by the | 24 // GPUTiming - GPU Timing is a private class which is only owned by the |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 92 |
90 // Start an instant timer, start and end will be equal. | 93 // Start an instant timer, start and end will be equal. |
91 void QueryTimeStamp(); | 94 void QueryTimeStamp(); |
92 | 95 |
93 // Start a timer range. | 96 // Start a timer range. |
94 void Start(); | 97 void Start(); |
95 void End(); | 98 void End(); |
96 | 99 |
97 bool IsAvailable(); | 100 bool IsAvailable(); |
98 | 101 |
99 void GetStartEndTimestamps(int64* start, int64* end); | 102 void GetStartEndTimestamps(int64_t* start, int64_t* end); |
100 int64 GetDeltaElapsed(); | 103 int64_t GetDeltaElapsed(); |
101 | 104 |
102 private: | 105 private: |
103 friend class GPUTimingClient; | 106 friend class GPUTimingClient; |
104 | 107 |
105 explicit GPUTimer(scoped_refptr<GPUTimingClient> gpu_timing_client, | 108 explicit GPUTimer(scoped_refptr<GPUTimingClient> gpu_timing_client, |
106 bool use_elapsed_timer); | 109 bool use_elapsed_timer); |
107 | 110 |
108 bool use_elapsed_timer_ = false; | 111 bool use_elapsed_timer_ = false; |
109 enum TimerState { | 112 enum TimerState { |
110 kTimerState_Ready, | 113 kTimerState_Ready, |
(...skipping 20 matching lines...) Expand all Loading... |
131 | 134 |
132 const char* GetTimerTypeName() const; | 135 const char* GetTimerTypeName() const; |
133 | 136 |
134 // CheckAndResetTimerErrors has to be called before reading timestamps | 137 // CheckAndResetTimerErrors has to be called before reading timestamps |
135 // from GPUTimers instances and after making sure all the timers | 138 // from GPUTimers instances and after making sure all the timers |
136 // were available. | 139 // were available. |
137 // If the returned value is false, all the previous timers should be | 140 // If the returned value is false, all the previous timers should be |
138 // discarded. | 141 // discarded. |
139 bool CheckAndResetTimerErrors(); | 142 bool CheckAndResetTimerErrors(); |
140 | 143 |
141 int64 GetCurrentCPUTime(); | 144 int64_t GetCurrentCPUTime(); |
142 void SetCpuTimeForTesting(const base::Callback<int64(void)>& cpu_time); | 145 void SetCpuTimeForTesting(const base::Callback<int64_t(void)>& cpu_time); |
143 | 146 |
144 bool IsForceTimeElapsedQuery(); | 147 bool IsForceTimeElapsedQuery(); |
145 void ForceTimeElapsedQuery(); | 148 void ForceTimeElapsedQuery(); |
146 | 149 |
147 private: | 150 private: |
148 friend class base::RefCounted<GPUTimingClient>; | 151 friend class base::RefCounted<GPUTimingClient>; |
149 friend class GPUTimer; | 152 friend class GPUTimer; |
150 | 153 |
151 virtual ~GPUTimingClient(); | 154 virtual ~GPUTimingClient(); |
152 | 155 |
153 GPUTimingImpl* gpu_timing_; | 156 GPUTimingImpl* gpu_timing_; |
154 GPUTiming::TimerType timer_type_ = GPUTiming::kTimerTypeInvalid; | 157 GPUTiming::TimerType timer_type_ = GPUTiming::kTimerTypeInvalid; |
155 uint32_t disjoint_counter_ = 0; | 158 uint32_t disjoint_counter_ = 0; |
156 | 159 |
157 DISALLOW_COPY_AND_ASSIGN(GPUTimingClient); | 160 DISALLOW_COPY_AND_ASSIGN(GPUTimingClient); |
158 }; | 161 }; |
159 | 162 |
160 } // namespace gfx | 163 } // namespace gfx |
161 | 164 |
162 #endif // UI_GL_GPU_TIMING_H_ | 165 #endif // UI_GL_GPU_TIMING_H_ |
OLD | NEW |