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 <deque> | 9 #include <deque> |
10 #include <string> | 10 #include <string> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 scoped_refptr<GPUTrace> trace_; | 49 scoped_refptr<GPUTrace> trace_; |
50 }; | 50 }; |
51 | 51 |
52 // Traces GPU Commands. | 52 // Traces GPU Commands. |
53 class GPU_EXPORT GPUTracer | 53 class GPU_EXPORT GPUTracer |
54 : public base::SupportsWeakPtr<GPUTracer> { | 54 : public base::SupportsWeakPtr<GPUTracer> { |
55 public: | 55 public: |
56 explicit GPUTracer(gles2::GLES2Decoder* decoder); | 56 explicit GPUTracer(gles2::GLES2Decoder* decoder); |
57 virtual ~GPUTracer(); | 57 virtual ~GPUTracer(); |
58 | 58 |
| 59 void Destroy(bool have_context); |
| 60 |
59 // Scheduled processing in decoder begins. | 61 // Scheduled processing in decoder begins. |
60 bool BeginDecoding(); | 62 bool BeginDecoding(); |
61 | 63 |
62 // Scheduled processing in decoder ends. | 64 // Scheduled processing in decoder ends. |
63 bool EndDecoding(); | 65 bool EndDecoding(); |
64 | 66 |
65 // Begin a trace marker. | 67 // Begin a trace marker. |
66 bool Begin(const std::string& category, const std::string& name, | 68 bool Begin(const std::string& category, const std::string& name, |
67 GpuTracerSource source); | 69 GpuTracerSource source); |
68 | 70 |
69 // End the last started trace marker. | 71 // End the last started trace marker. |
70 bool End(GpuTracerSource source); | 72 bool End(GpuTracerSource source); |
71 | 73 |
72 virtual bool IsTracing(); | 74 virtual bool IsTracing(); |
73 | 75 |
74 // Retrieve the name of the current open trace. | 76 // Retrieve the name of the current open trace. |
75 // Returns empty string if no current open trace. | 77 // Returns empty string if no current open trace. |
76 const std::string& CurrentCategory(GpuTracerSource source) const; | 78 const std::string& CurrentCategory(GpuTracerSource source) const; |
77 const std::string& CurrentName(GpuTracerSource source) const; | 79 const std::string& CurrentName(GpuTracerSource source) const; |
78 | 80 |
79 protected: | 81 protected: |
80 // Trace Processing. | 82 // Trace Processing. |
81 virtual scoped_refptr<Outputter> CreateOutputter(const std::string& name); | 83 virtual scoped_refptr<Outputter> CreateOutputter(const std::string& name); |
82 virtual void PostTask(); | 84 virtual void PostTask(); |
83 | 85 |
84 void Process(); | 86 void Process(); |
85 void ProcessTraces(); | 87 void ProcessTraces(); |
| 88 void ClearFinishedTraces(bool have_context); |
86 | 89 |
87 void IssueProcessTask(); | 90 void IssueProcessTask(); |
88 | 91 |
89 scoped_refptr<gfx::GPUTimingClient> gpu_timing_client_; | 92 scoped_refptr<gfx::GPUTimingClient> gpu_timing_client_; |
90 scoped_refptr<Outputter> outputter_; | 93 scoped_refptr<Outputter> outputter_; |
91 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES]; | 94 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES]; |
92 std::deque<scoped_refptr<GPUTrace> > traces_; | 95 std::deque<scoped_refptr<GPUTrace> > finished_traces_; |
93 | 96 |
94 const unsigned char* gpu_trace_srv_category; | 97 const unsigned char* gpu_trace_srv_category; |
95 const unsigned char* gpu_trace_dev_category; | 98 const unsigned char* gpu_trace_dev_category; |
96 gles2::GLES2Decoder* decoder_; | 99 gles2::GLES2Decoder* decoder_; |
97 | 100 |
98 bool gpu_executing_; | 101 bool gpu_executing_; |
99 bool process_posted_; | 102 bool process_posted_; |
100 | 103 |
101 private: | 104 private: |
102 DISALLOW_COPY_AND_ASSIGN(GPUTracer); | 105 DISALLOW_COPY_AND_ASSIGN(GPUTracer); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 151 |
149 class GPU_EXPORT GPUTrace | 152 class GPU_EXPORT GPUTrace |
150 : public base::RefCounted<GPUTrace> { | 153 : public base::RefCounted<GPUTrace> { |
151 public: | 154 public: |
152 GPUTrace(scoped_refptr<Outputter> outputter, | 155 GPUTrace(scoped_refptr<Outputter> outputter, |
153 gfx::GPUTimingClient* gpu_timing_client, | 156 gfx::GPUTimingClient* gpu_timing_client, |
154 const std::string& category, | 157 const std::string& category, |
155 const std::string& name, | 158 const std::string& name, |
156 const bool enabled); | 159 const bool enabled); |
157 | 160 |
| 161 void Destroy(bool have_context); |
| 162 |
158 void Start(bool trace_service); | 163 void Start(bool trace_service); |
159 void End(bool tracing_service); | 164 void End(bool tracing_service); |
160 bool IsAvailable(); | 165 bool IsAvailable(); |
161 bool IsEnabled() { return enabled_; } | 166 bool IsEnabled() { return enabled_; } |
162 void Process(); | 167 void Process(); |
163 | 168 |
164 private: | 169 private: |
165 ~GPUTrace(); | 170 ~GPUTrace(); |
166 | 171 |
167 void Output(); | 172 void Output(); |
(...skipping 23 matching lines...) Expand all Loading... |
191 | 196 |
192 private: | 197 private: |
193 GPUTracer* gpu_tracer_; | 198 GPUTracer* gpu_tracer_; |
194 GpuTracerSource source_; | 199 GpuTracerSource source_; |
195 }; | 200 }; |
196 | 201 |
197 } // namespace gles2 | 202 } // namespace gles2 |
198 } // namespace gpu | 203 } // namespace gpu |
199 | 204 |
200 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ | 205 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ |
OLD | NEW |