| 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 <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // GPUTimer - Once a user decides to time something, the user creates a new | 36 // GPUTimer - Once a user decides to time something, the user creates a new |
| 37 // GPUTimer object from a GPUTimingClient and issue Start() and Stop() calls | 37 // GPUTimer object from a GPUTimingClient and issue Start() and Stop() calls |
| 38 // around various GL calls. Once IsAvailable() returns true, the GPU times | 38 // around various GL calls. Once IsAvailable() returns true, the GPU times |
| 39 // will be available through the various time stamp related functions. | 39 // will be available through the various time stamp related functions. |
| 40 // The constructor and destructor of this object handles the actual | 40 // The constructor and destructor of this object handles the actual |
| 41 // creation and deletion of the GL Queries within GL. | 41 // creation and deletion of the GL Queries within GL. |
| 42 | 42 |
| 43 namespace gfx { | 43 namespace gfx { |
| 44 | 44 |
| 45 class GLContextReal; | 45 class GLContextReal; |
| 46 class GPUTiming; | |
| 47 class GPUTimingClient; | 46 class GPUTimingClient; |
| 48 class GPUTimingImpl; | 47 class GPUTimingImpl; |
| 49 class QueryResult; | 48 class QueryResult; |
| 50 class TimeElapsedTimerQuery; | |
| 51 class TimerQuery; | |
| 52 | 49 |
| 53 class GPUTiming { | 50 class GPUTiming { |
| 54 public: | 51 public: |
| 55 enum TimerType { | 52 enum TimerType { |
| 56 kTimerTypeInvalid = -1, | 53 kTimerTypeInvalid = -1, |
| 57 | 54 |
| 58 kTimerTypeEXT, // EXT_timer_query | 55 kTimerTypeEXT, // EXT_timer_query |
| 59 kTimerTypeARB, // ARB_timer_query | 56 kTimerTypeARB, // ARB_timer_query |
| 60 kTimerTypeDisjoint // EXT_disjoint_timer_query | 57 kTimerTypeDisjoint // EXT_disjoint_timer_query |
| 61 }; | 58 }; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 79 class GL_EXPORT GPUTimer { | 76 class GL_EXPORT GPUTimer { |
| 80 public: | 77 public: |
| 81 static void DisableTimestampQueries(); | 78 static void DisableTimestampQueries(); |
| 82 | 79 |
| 83 ~GPUTimer(); | 80 ~GPUTimer(); |
| 84 | 81 |
| 85 // Destroy the timer object. This must be explicitly called before destroying | 82 // Destroy the timer object. This must be explicitly called before destroying |
| 86 // this object. | 83 // this object. |
| 87 void Destroy(bool have_context); | 84 void Destroy(bool have_context); |
| 88 | 85 |
| 86 // Clears current queries. |
| 87 void Reset(); |
| 88 |
| 89 // Start an instant timer, start and end will be equal. |
| 90 void QueryTimeStamp(); |
| 91 |
| 89 // Start a timer range. | 92 // Start a timer range. |
| 90 void Start(); | 93 void Start(); |
| 91 void End(); | 94 void End(); |
| 92 | 95 |
| 93 bool IsAvailable(); | 96 bool IsAvailable(); |
| 94 | 97 |
| 95 void GetStartEndTimestamps(int64* start, int64* end); | 98 void GetStartEndTimestamps(int64* start, int64* end); |
| 96 int64 GetDeltaElapsed(); | 99 int64 GetDeltaElapsed(); |
| 97 | 100 |
| 98 private: | 101 private: |
| 99 friend class GPUTimingClient; | 102 friend class GPUTimingClient; |
| 100 | 103 |
| 101 explicit GPUTimer(scoped_refptr<GPUTimingClient> gpu_timing_client, | 104 explicit GPUTimer(scoped_refptr<GPUTimingClient> gpu_timing_client, |
| 102 bool use_elapsed_timer); | 105 bool use_elapsed_timer); |
| 103 | 106 |
| 104 bool use_elapsed_timer_ = false; | 107 bool use_elapsed_timer_ = false; |
| 105 bool end_requested_ = false; | 108 enum TimerState { |
| 106 bool end_available_ = false; | 109 kTimerState_Ready, |
| 110 kTimerState_WaitingForEnd, |
| 111 kTimerState_WaitingForResult, |
| 112 kTimerState_ResultAvailable |
| 113 } timer_state_ = kTimerState_Ready; |
| 107 scoped_refptr<GPUTimingClient> gpu_timing_client_; | 114 scoped_refptr<GPUTimingClient> gpu_timing_client_; |
| 108 scoped_refptr<QueryResult> time_stamp_result_; | 115 scoped_refptr<QueryResult> time_stamp_result_; |
| 109 scoped_refptr<QueryResult> elapsed_timer_result_; | 116 scoped_refptr<QueryResult> elapsed_timer_result_; |
| 110 | 117 |
| 111 DISALLOW_COPY_AND_ASSIGN(GPUTimer); | 118 DISALLOW_COPY_AND_ASSIGN(GPUTimer); |
| 112 }; | 119 }; |
| 113 | 120 |
| 114 // GPUTimingClient contains all the gl timing logic that is not specific | 121 // GPUTimingClient contains all the gl timing logic that is not specific |
| 115 // to a single GPUTimer. | 122 // to a single GPUTimer. |
| 116 class GL_EXPORT GPUTimingClient | 123 class GL_EXPORT GPUTimingClient |
| (...skipping 28 matching lines...) Expand all Loading... |
| 145 GPUTimingImpl* gpu_timing_; | 152 GPUTimingImpl* gpu_timing_; |
| 146 GPUTiming::TimerType timer_type_ = GPUTiming::kTimerTypeInvalid; | 153 GPUTiming::TimerType timer_type_ = GPUTiming::kTimerTypeInvalid; |
| 147 uint32_t disjoint_counter_ = 0; | 154 uint32_t disjoint_counter_ = 0; |
| 148 | 155 |
| 149 DISALLOW_COPY_AND_ASSIGN(GPUTimingClient); | 156 DISALLOW_COPY_AND_ASSIGN(GPUTimingClient); |
| 150 }; | 157 }; |
| 151 | 158 |
| 152 } // namespace gfx | 159 } // namespace gfx |
| 153 | 160 |
| 154 #endif // UI_GL_GPU_TIMING_H_ | 161 #endif // UI_GL_GPU_TIMING_H_ |
| OLD | NEW |