| 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 // This file contains the GPUTrace class. | 5 // This file contains the GPUTrace class. |
| 6 #ifndef GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ | 6 #ifndef GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ |
| 7 #define GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ | 7 #define GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 struct TraceMarker { | 44 struct TraceMarker { |
| 45 TraceMarker(const std::string& category, const std::string& name); | 45 TraceMarker(const std::string& category, const std::string& name); |
| 46 ~TraceMarker(); | 46 ~TraceMarker(); |
| 47 | 47 |
| 48 std::string category_; | 48 std::string category_; |
| 49 std::string name_; | 49 std::string name_; |
| 50 scoped_refptr<GPUTrace> trace_; | 50 scoped_refptr<GPUTrace> trace_; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 // Traces GPU Commands. | 53 // Traces GPU Commands. |
| 54 class GPUTracer : public base::SupportsWeakPtr<GPUTracer> { | 54 class GPU_EXPORT GPUTracer |
| 55 : public base::SupportsWeakPtr<GPUTracer> { |
| 55 public: | 56 public: |
| 56 explicit GPUTracer(gles2::GLES2Decoder* decoder); | 57 explicit GPUTracer(gles2::GLES2Decoder* decoder); |
| 57 ~GPUTracer(); | 58 ~GPUTracer(); |
| 58 | 59 |
| 59 // Scheduled processing in decoder begins. | 60 // Scheduled processing in decoder begins. |
| 60 bool BeginDecoding(); | 61 bool BeginDecoding(); |
| 61 | 62 |
| 62 // Scheduled processing in decoder ends. | 63 // Scheduled processing in decoder ends. |
| 63 bool EndDecoding(); | 64 bool EndDecoding(); |
| 64 | 65 |
| 65 // Begin a trace marker. | 66 // Begin a trace marker. |
| 66 bool Begin(const std::string& category, const std::string& name, | 67 bool Begin(const std::string& category, const std::string& name, |
| 67 GpuTracerSource source); | 68 GpuTracerSource source); |
| 68 | 69 |
| 69 // End the last started trace marker. | 70 // End the last started trace marker. |
| 70 bool End(GpuTracerSource source); | 71 bool End(GpuTracerSource source); |
| 71 | 72 |
| 72 bool IsTracing(); | 73 bool IsTracing(); |
| 73 | 74 |
| 74 // Retrieve the name of the current open trace. | 75 // Retrieve the name of the current open trace. |
| 75 // Returns empty string if no current open trace. | 76 // Returns empty string if no current open trace. |
| 76 const std::string& CurrentCategory() const; | 77 const std::string& CurrentCategory(GpuTracerSource source) const; |
| 77 const std::string& CurrentName() const; | 78 const std::string& CurrentName(GpuTracerSource source) const; |
| 78 | 79 |
| 79 private: | 80 protected: |
| 80 // Trace Processing. | 81 // Trace Processing. |
| 81 scoped_refptr<GPUTrace> CreateTrace(const std::string& category, | 82 scoped_refptr<GPUTrace> CreateTrace(const std::string& category, |
| 82 const std::string& name); | 83 const std::string& name); |
| 83 void Process(); | 84 void Process(); |
| 84 void ProcessTraces(); | 85 void ProcessTraces(); |
| 85 | 86 |
| 86 void CalculateTimerOffset(); | 87 void CalculateTimerOffset(); |
| 87 void IssueProcessTask(); | 88 void IssueProcessTask(); |
| 88 | 89 |
| 89 scoped_refptr<Outputter> outputter_; | 90 scoped_refptr<Outputter> outputter_; |
| 90 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES]; | 91 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES]; |
| 91 std::deque<scoped_refptr<GPUTrace> > traces_; | 92 std::deque<scoped_refptr<GPUTrace> > traces_; |
| 92 | 93 |
| 93 const unsigned char* gpu_trace_srv_category; | 94 const unsigned char* gpu_trace_srv_category; |
| 94 const unsigned char* gpu_trace_dev_category; | 95 const unsigned char* gpu_trace_dev_category; |
| 95 gles2::GLES2Decoder* decoder_; | 96 gles2::GLES2Decoder* decoder_; |
| 96 | 97 |
| 97 int64 timer_offset_; | 98 int64 timer_offset_; |
| 98 GpuTracerSource last_tracer_source_; | |
| 99 | 99 |
| 100 GpuTracerType tracer_type_; | 100 GpuTracerType tracer_type_; |
| 101 bool gpu_timing_synced_; | 101 bool gpu_timing_synced_; |
| 102 bool gpu_executing_; | 102 bool gpu_executing_; |
| 103 bool process_posted_; | 103 bool process_posted_; |
| 104 | 104 |
| 105 DISALLOW_COPY_AND_ASSIGN(GPUTracer); | 105 DISALLOW_COPY_AND_ASSIGN(GPUTracer); |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 class Outputter : public base::RefCounted<Outputter> { | 108 class Outputter : public base::RefCounted<Outputter> { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 : public base::RefCounted<GPUTrace> { | 140 : public base::RefCounted<GPUTrace> { |
| 141 public: | 141 public: |
| 142 GPUTrace(scoped_refptr<Outputter> outputter, | 142 GPUTrace(scoped_refptr<Outputter> outputter, |
| 143 const std::string& category, | 143 const std::string& category, |
| 144 const std::string& name, | 144 const std::string& name, |
| 145 int64 offset, | 145 int64 offset, |
| 146 GpuTracerType tracer_type); | 146 GpuTracerType tracer_type); |
| 147 | 147 |
| 148 bool IsEnabled() { return tracer_type_ != kTracerTypeInvalid; } | 148 bool IsEnabled() { return tracer_type_ != kTracerTypeInvalid; } |
| 149 | 149 |
| 150 const std::string& category() { return category_; } | |
| 151 const std::string& name() { return name_; } | |
| 152 | |
| 153 void Start(bool trace_service); | 150 void Start(bool trace_service); |
| 154 void End(bool tracing_service); | 151 void End(bool trace_service); |
| 155 bool IsAvailable(); | 152 bool IsAvailable(); |
| 156 void Process(); | 153 void Process(); |
| 157 | 154 |
| 158 private: | 155 private: |
| 159 ~GPUTrace(); | 156 ~GPUTrace(); |
| 160 | 157 |
| 161 void Output(); | 158 void Output(); |
| 162 | 159 |
| 163 friend class base::RefCounted<GPUTrace>; | 160 friend class base::RefCounted<GPUTrace>; |
| 164 | 161 |
| 165 std::string category_; | 162 std::string category_; |
| 166 std::string name_; | 163 std::string name_; |
| 167 scoped_refptr<Outputter> outputter_; | 164 scoped_refptr<Outputter> outputter_; |
| 168 | 165 |
| 169 int64 offset_; | 166 int64 offset_; |
| 170 int64 start_time_; | 167 int64 start_time_; |
| 171 int64 end_time_; | 168 int64 end_time_; |
| 172 GpuTracerType tracer_type_; | 169 GpuTracerType tracer_type_; |
| 173 bool end_requested_; | 170 bool end_requested_; |
| 174 | 171 |
| 175 GLuint queries_[2]; | 172 GLuint queries_[2]; |
| 176 | 173 |
| 177 DISALLOW_COPY_AND_ASSIGN(GPUTrace); | 174 DISALLOW_COPY_AND_ASSIGN(GPUTrace); |
| 178 }; | 175 }; |
| 179 | 176 |
| 180 } // namespace gles2 | 177 } // namespace gles2 |
| 181 } // namespace gpu | 178 } // namespace gpu |
| 182 | 179 |
| 183 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ | 180 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ |
| OLD | NEW |