| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 class Outputter : public base::RefCounted<Outputter> { | 129 class Outputter : public base::RefCounted<Outputter> { |
| 130 public: | 130 public: |
| 131 virtual void TraceDevice(const std::string& category, | 131 virtual void TraceDevice(const std::string& category, |
| 132 const std::string& name, | 132 const std::string& name, |
| 133 int64 start_time, | 133 int64 start_time, |
| 134 int64 end_time) = 0; | 134 int64 end_time) = 0; |
| 135 | 135 |
| 136 virtual void TraceServiceBegin(const std::string& category, | 136 virtual void TraceServiceBegin(const std::string& category, |
| 137 const std::string& name, | 137 const std::string& name) = 0; |
| 138 void* id) = 0; | |
| 139 | 138 |
| 140 virtual void TraceServiceEnd(const std::string& category, | 139 virtual void TraceServiceEnd(const std::string& category, |
| 141 const std::string& name, | 140 const std::string& name) = 0; |
| 142 void* id) = 0; | |
| 143 | 141 |
| 144 protected: | 142 protected: |
| 145 virtual ~Outputter() {} | 143 virtual ~Outputter() {} |
| 146 friend class base::RefCounted<Outputter>; | 144 friend class base::RefCounted<Outputter>; |
| 147 }; | 145 }; |
| 148 | 146 |
| 149 class TraceOutputter : public Outputter { | 147 class TraceOutputter : public Outputter { |
| 150 public: | 148 public: |
| 151 static scoped_refptr<TraceOutputter> Create(const std::string& name); | 149 static scoped_refptr<TraceOutputter> Create(const std::string& name); |
| 152 void TraceDevice(const std::string& category, | 150 void TraceDevice(const std::string& category, |
| 153 const std::string& name, | 151 const std::string& name, |
| 154 int64 start_time, | 152 int64 start_time, |
| 155 int64 end_time) override; | 153 int64 end_time) override; |
| 156 | 154 |
| 157 void TraceServiceBegin(const std::string& category, | 155 void TraceServiceBegin(const std::string& category, |
| 158 const std::string& name, | 156 const std::string& name) override; |
| 159 void* id) override; | |
| 160 | 157 |
| 161 void TraceServiceEnd(const std::string& category, | 158 void TraceServiceEnd(const std::string& category, |
| 162 const std::string& name, | 159 const std::string& name) override; |
| 163 void* id) override; | |
| 164 | 160 |
| 165 protected: | 161 protected: |
| 166 friend class base::RefCounted<Outputter>; | 162 friend class base::RefCounted<Outputter>; |
| 167 explicit TraceOutputter(const std::string& name); | 163 explicit TraceOutputter(const std::string& name); |
| 168 ~TraceOutputter() override; | 164 ~TraceOutputter() override; |
| 169 | 165 |
| 170 base::Thread named_thread_; | 166 base::Thread named_thread_; |
| 171 uint64 local_trace_id_; | 167 uint64 local_trace_id_; |
| 172 | 168 |
| 173 DISALLOW_COPY_AND_ASSIGN(TraceOutputter); | 169 DISALLOW_COPY_AND_ASSIGN(TraceOutputter); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 int64 start_time_; | 202 int64 start_time_; |
| 207 int64 end_time_; | 203 int64 end_time_; |
| 208 GpuTracerType tracer_type_; | 204 GpuTracerType tracer_type_; |
| 209 bool end_requested_; | 205 bool end_requested_; |
| 210 | 206 |
| 211 GLuint queries_[2]; | 207 GLuint queries_[2]; |
| 212 | 208 |
| 213 DISALLOW_COPY_AND_ASSIGN(GPUTrace); | 209 DISALLOW_COPY_AND_ASSIGN(GPUTrace); |
| 214 }; | 210 }; |
| 215 | 211 |
| 212 class ScopedGPUTrace { |
| 213 public: |
| 214 ScopedGPUTrace(GPUTracer* gpu_tracer, GpuTracerSource source, |
| 215 const std::string& category, const std::string& name) |
| 216 : gpu_tracer_(gpu_tracer), |
| 217 source_(source) { |
| 218 gpu_tracer_->Begin(category, name, source_); |
| 219 } |
| 220 |
| 221 ~ScopedGPUTrace() { |
| 222 gpu_tracer_->End(source_); |
| 223 } |
| 224 |
| 225 private: |
| 226 GPUTracer* gpu_tracer_; |
| 227 GpuTracerSource source_; |
| 228 }; |
| 229 |
| 216 } // namespace gles2 | 230 } // namespace gles2 |
| 217 } // namespace gpu | 231 } // namespace gpu |
| 218 | 232 |
| 219 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ | 233 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ |
| OLD | NEW |