Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: gpu/command_buffer/service/gpu_tracer.h

Issue 419073008: Simplified GPU Tracer by removing parent base class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 Trace;
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 : name_(name), trace_(NULL) {}
40
41 std::string name_;
42 scoped_refptr<Trace> 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);
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;
68
69 void CalculateTimerOffset();
vmiura 2014/07/29 23:45:31 Should this be private?
David Yen 2014/08/04 22:20:05 Done.
54 70
55 private: 71 private:
72 // Trace Processing.
73 scoped_refptr<Trace> CreateTrace(const std::string& name);
74 void Process();
75 void ProcessTraces();
76
77 void IssueProcessTask();
78
79 scoped_refptr<Outputter> outputter_;
80 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES];
81 std::deque<scoped_refptr<Trace> > traces_;
82
83 const unsigned char* gpu_trace_srv_category;
84 const unsigned char* gpu_trace_dev_category;
85 gles2::GLES2Decoder* decoder_;
86
87 int64 timer_offset_;
88 GpuTracerSource last_tracer_source_;
89
90 bool enabled_;
91 bool gpu_timing_synced_;
92 bool gpu_executing_;
93 bool process_posted_;
94
56 DISALLOW_COPY_AND_ASSIGN(GPUTracer); 95 DISALLOW_COPY_AND_ASSIGN(GPUTracer);
57 }; 96 };
58 97
59 class Outputter : public base::RefCounted<Outputter> { 98 class Outputter : public base::RefCounted<Outputter> {
60 public: 99 public:
61 virtual void Trace(const std::string& name, 100 virtual void Trace(const std::string& name,
62 int64 start_time, 101 int64 start_time,
63 int64 end_time) = 0; 102 int64 end_time) = 0;
64 103
65 protected: 104 protected:
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 176
138 GLuint queries_[2]; 177 GLuint queries_[2];
139 178
140 DISALLOW_COPY_AND_ASSIGN(GLARBTimerTrace); 179 DISALLOW_COPY_AND_ASSIGN(GLARBTimerTrace);
141 }; 180 };
142 181
143 } // namespace gles2 182 } // namespace gles2
144 } // namespace gpu 183 } // namespace gpu
145 184
146 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ 185 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698