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 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
15 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 15 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
16 #include "gpu/gpu_export.h" | 16 #include "gpu/gpu_export.h" |
17 #include "ui/gl/gl_bindings.h" | 17 #include "ui/gl/gl_bindings.h" |
18 | 18 |
19 namespace gpu { | 19 namespace gpu { |
20 namespace gles2 { | 20 namespace gles2 { |
21 | 21 |
22 class Outputter; | |
23 class GPUTrace; | |
24 | |
22 // Id used to keep trace namespaces separate | 25 // Id used to keep trace namespaces separate |
23 enum GpuTracerSource { | 26 enum GpuTracerSource { |
27 kTraceGroupInvalid = -1, | |
28 | |
24 kTraceGroupMarker = 0, | 29 kTraceGroupMarker = 0, |
25 kTraceCHROMIUM = 1, | 30 kTraceCHROMIUM = 1, |
26 kTraceDecoder = 2, | 31 kTraceDecoder = 2, |
32 | |
33 NUM_TRACER_SOURCES | |
34 }; | |
35 | |
36 // Marker structure for a Trace. | |
37 struct TraceMarker { | |
38 TraceMarker(const std::string& name); | |
39 ~TraceMarker(); | |
40 | |
41 std::string name_; | |
42 scoped_refptr<GPUTrace> trace_; | |
27 }; | 43 }; |
28 | 44 |
29 // Traces GPU Commands. | 45 // Traces GPU Commands. |
30 class GPUTracer { | 46 class GPUTracer : public base::SupportsWeakPtr<GPUTracer> { |
31 public: | 47 public: |
32 static scoped_ptr<GPUTracer> Create(gles2::GLES2Decoder* decoder); | 48 GPUTracer(gles2::GLES2Decoder* decoder); |
vmiura
2014/08/14 19:43:05
nit: explicit
David Yen
2014/08/19 20:01:30
Done.
| |
33 | 49 ~GPUTracer(); |
34 GPUTracer(); | |
35 virtual ~GPUTracer(); | |
36 | 50 |
37 // Scheduled processing in decoder begins. | 51 // Scheduled processing in decoder begins. |
38 virtual bool BeginDecoding() = 0; | 52 bool BeginDecoding(); |
39 | 53 |
40 // Scheduled processing in decoder ends. | 54 // Scheduled processing in decoder ends. |
41 virtual bool EndDecoding() = 0; | 55 bool EndDecoding(); |
42 | 56 |
43 // Begin a trace marker. | 57 // Begin a trace marker. |
44 virtual bool Begin(const std::string& name, GpuTracerSource source) = 0; | 58 bool Begin(const std::string& name, GpuTracerSource source); |
45 | 59 |
46 // End the last started trace marker. | 60 // End the last started trace marker. |
47 virtual bool End(GpuTracerSource source) = 0; | 61 bool End(GpuTracerSource source); |
48 | 62 |
49 virtual bool IsTracing() = 0; | 63 bool IsTracing(); |
50 | 64 |
51 // Retrieve the name of the current open trace. | 65 // Retrieve the name of the current open trace. |
52 // Returns empty string if no current open trace. | 66 // Returns empty string if no current open trace. |
53 virtual const std::string& CurrentName() const = 0; | 67 const std::string& CurrentName() const; |
54 | 68 |
55 private: | 69 private: |
70 // Trace Processing. | |
71 void Process(); | |
72 void ProcessTraces(); | |
73 | |
74 void CalculateTimerOffset(); | |
75 void IssueProcessTask(); | |
76 | |
77 scoped_refptr<Outputter> outputter_; | |
78 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES]; | |
79 std::deque<scoped_refptr<GPUTrace> > traces_; | |
80 | |
81 const unsigned char* gpu_trace_srv_category; | |
82 const unsigned char* gpu_trace_dev_category; | |
83 gles2::GLES2Decoder* decoder_; | |
84 | |
85 int64 timer_offset_; | |
86 GpuTracerSource last_tracer_source_; | |
87 | |
88 bool enabled_; | |
89 bool gpu_timing_synced_; | |
90 bool gpu_executing_; | |
91 bool process_posted_; | |
92 | |
56 DISALLOW_COPY_AND_ASSIGN(GPUTracer); | 93 DISALLOW_COPY_AND_ASSIGN(GPUTracer); |
57 }; | 94 }; |
58 | 95 |
59 class Outputter : public base::RefCounted<Outputter> { | 96 class Outputter : public base::RefCounted<Outputter> { |
60 public: | 97 public: |
61 virtual void Trace(const std::string& name, | 98 virtual void Trace(const std::string& name, |
62 int64 start_time, | 99 int64 start_time, |
63 int64 end_time) = 0; | 100 int64 end_time) = 0; |
64 | 101 |
65 protected: | 102 protected: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 | 156 |
120 GLuint queries_[2]; | 157 GLuint queries_[2]; |
121 | 158 |
122 DISALLOW_COPY_AND_ASSIGN(GPUTrace); | 159 DISALLOW_COPY_AND_ASSIGN(GPUTrace); |
123 }; | 160 }; |
124 | 161 |
125 } // namespace gles2 | 162 } // namespace gles2 |
126 } // namespace gpu | 163 } // namespace gpu |
127 | 164 |
128 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ | 165 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ |
OLD | NEW |