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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
17 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 17 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
18 #include "gpu/command_buffer/service/gpu_timing.h" | |
19 #include "gpu/gpu_export.h" | 18 #include "gpu/gpu_export.h" |
20 | 19 |
| 20 namespace gfx { |
| 21 class GPUTimingClient; |
| 22 class GPUTimer; |
| 23 } |
| 24 |
21 namespace gpu { | 25 namespace gpu { |
22 namespace gles2 { | 26 namespace gles2 { |
23 | 27 |
24 class Outputter; | 28 class Outputter; |
25 class GPUTrace; | 29 class GPUTrace; |
26 | 30 |
27 // Id used to keep trace namespaces separate | 31 // Id used to keep trace namespaces separate |
28 enum GpuTracerSource { | 32 enum GpuTracerSource { |
29 kTraceGroupInvalid = -1, | 33 kTraceGroupInvalid = -1, |
30 | 34 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 protected: | 79 protected: |
76 // Trace Processing. | 80 // Trace Processing. |
77 virtual scoped_refptr<Outputter> CreateOutputter(const std::string& name); | 81 virtual scoped_refptr<Outputter> CreateOutputter(const std::string& name); |
78 virtual void PostTask(); | 82 virtual void PostTask(); |
79 | 83 |
80 void Process(); | 84 void Process(); |
81 void ProcessTraces(); | 85 void ProcessTraces(); |
82 | 86 |
83 void IssueProcessTask(); | 87 void IssueProcessTask(); |
84 | 88 |
| 89 scoped_refptr<gfx::GPUTimingClient> gpu_timing_client_; |
85 scoped_refptr<Outputter> outputter_; | 90 scoped_refptr<Outputter> outputter_; |
86 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES]; | 91 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES]; |
87 std::deque<scoped_refptr<GPUTrace> > traces_; | 92 std::deque<scoped_refptr<GPUTrace> > traces_; |
88 | 93 |
89 const unsigned char* gpu_trace_srv_category; | 94 const unsigned char* gpu_trace_srv_category; |
90 const unsigned char* gpu_trace_dev_category; | 95 const unsigned char* gpu_trace_dev_category; |
91 gles2::GLES2Decoder* decoder_; | 96 gles2::GLES2Decoder* decoder_; |
92 gpu::GPUTiming gpu_timing_; | |
93 | 97 |
94 bool gpu_executing_; | 98 bool gpu_executing_; |
95 bool process_posted_; | 99 bool process_posted_; |
96 | 100 |
97 private: | 101 private: |
98 DISALLOW_COPY_AND_ASSIGN(GPUTracer); | 102 DISALLOW_COPY_AND_ASSIGN(GPUTracer); |
99 }; | 103 }; |
100 | 104 |
101 class Outputter : public base::RefCounted<Outputter> { | 105 class Outputter : public base::RefCounted<Outputter> { |
102 public: | 106 public: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 uint64 local_trace_id_; | 143 uint64 local_trace_id_; |
140 | 144 |
141 private: | 145 private: |
142 DISALLOW_COPY_AND_ASSIGN(TraceOutputter); | 146 DISALLOW_COPY_AND_ASSIGN(TraceOutputter); |
143 }; | 147 }; |
144 | 148 |
145 class GPU_EXPORT GPUTrace | 149 class GPU_EXPORT GPUTrace |
146 : public base::RefCounted<GPUTrace> { | 150 : public base::RefCounted<GPUTrace> { |
147 public: | 151 public: |
148 GPUTrace(scoped_refptr<Outputter> outputter, | 152 GPUTrace(scoped_refptr<Outputter> outputter, |
149 gpu::GPUTiming* gpu_timing, | 153 gfx::GPUTimingClient* gpu_timing_client, |
150 const std::string& category, | 154 const std::string& category, |
151 const std::string& name, | 155 const std::string& name, |
152 const bool enabled); | 156 const bool enabled); |
153 | 157 |
154 void Start(bool trace_service); | 158 void Start(bool trace_service); |
155 void End(bool tracing_service); | 159 void End(bool tracing_service); |
156 bool IsAvailable(); | 160 bool IsAvailable(); |
157 bool IsEnabled() { return enabled_; } | 161 bool IsEnabled() { return enabled_; } |
158 void Process(); | 162 void Process(); |
159 | 163 |
160 private: | 164 private: |
161 ~GPUTrace(); | 165 ~GPUTrace(); |
162 | 166 |
163 void Output(); | 167 void Output(); |
164 | 168 |
165 friend class base::RefCounted<GPUTrace>; | 169 friend class base::RefCounted<GPUTrace>; |
166 | 170 |
167 std::string category_; | 171 std::string category_; |
168 std::string name_; | 172 std::string name_; |
169 scoped_refptr<Outputter> outputter_; | 173 scoped_refptr<Outputter> outputter_; |
170 scoped_ptr<gpu::GPUTimer> gpu_timer_; | 174 scoped_ptr<gfx::GPUTimer> gpu_timer_; |
171 const bool enabled_ = false; | 175 const bool enabled_ = false; |
172 | 176 |
173 DISALLOW_COPY_AND_ASSIGN(GPUTrace); | 177 DISALLOW_COPY_AND_ASSIGN(GPUTrace); |
174 }; | 178 }; |
175 | 179 |
176 class ScopedGPUTrace { | 180 class ScopedGPUTrace { |
177 public: | 181 public: |
178 ScopedGPUTrace(GPUTracer* gpu_tracer, | 182 ScopedGPUTrace(GPUTracer* gpu_tracer, |
179 GpuTracerSource source, | 183 GpuTracerSource source, |
180 const std::string& category, | 184 const std::string& category, |
181 const std::string& name) | 185 const std::string& name) |
182 : gpu_tracer_(gpu_tracer), source_(source) { | 186 : gpu_tracer_(gpu_tracer), source_(source) { |
183 gpu_tracer_->Begin(category, name, source_); | 187 gpu_tracer_->Begin(category, name, source_); |
184 } | 188 } |
185 | 189 |
186 ~ScopedGPUTrace() { gpu_tracer_->End(source_); } | 190 ~ScopedGPUTrace() { gpu_tracer_->End(source_); } |
187 | 191 |
188 private: | 192 private: |
189 GPUTracer* gpu_tracer_; | 193 GPUTracer* gpu_tracer_; |
190 GpuTracerSource source_; | 194 GpuTracerSource source_; |
191 }; | 195 }; |
192 | 196 |
193 } // namespace gles2 | 197 } // namespace gles2 |
194 } // namespace gpu | 198 } // namespace gpu |
195 | 199 |
196 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ | 200 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ |
OLD | NEW |