| 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 <stdint.h> |
| 10 |
| 9 #include <deque> | 11 #include <deque> |
| 10 #include <stack> | 12 #include <stack> |
| 11 #include <string> | 13 #include <string> |
| 12 #include <vector> | 14 #include <vector> |
| 13 | 15 |
| 14 #include "base/basictypes.h" | 16 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 17 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 18 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 20 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 19 #include "gpu/gpu_export.h" | 21 #include "gpu/gpu_export.h" |
| 20 | 22 |
| 21 namespace gfx { | 23 namespace gfx { |
| 22 class GPUTimingClient; | 24 class GPUTimingClient; |
| 23 class GPUTimer; | 25 class GPUTimer; |
| 24 } | 26 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 void ClearOngoingTraces(bool have_context); | 92 void ClearOngoingTraces(bool have_context); |
| 91 | 93 |
| 92 scoped_refptr<gfx::GPUTimingClient> gpu_timing_client_; | 94 scoped_refptr<gfx::GPUTimingClient> gpu_timing_client_; |
| 93 scoped_refptr<Outputter> outputter_; | 95 scoped_refptr<Outputter> outputter_; |
| 94 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES]; | 96 std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES]; |
| 95 std::deque<scoped_refptr<GPUTrace> > finished_traces_; | 97 std::deque<scoped_refptr<GPUTrace> > finished_traces_; |
| 96 | 98 |
| 97 const unsigned char* gpu_trace_srv_category; | 99 const unsigned char* gpu_trace_srv_category; |
| 98 const unsigned char* gpu_trace_dev_category; | 100 const unsigned char* gpu_trace_dev_category; |
| 99 gles2::GLES2Decoder* decoder_; | 101 gles2::GLES2Decoder* decoder_; |
| 100 int64 disjoint_time_ = 0; | 102 int64_t disjoint_time_ = 0; |
| 101 | 103 |
| 102 bool gpu_executing_ = false; | 104 bool gpu_executing_ = false; |
| 103 bool began_device_traces_ = false; | 105 bool began_device_traces_ = false; |
| 104 | 106 |
| 105 private: | 107 private: |
| 106 DISALLOW_COPY_AND_ASSIGN(GPUTracer); | 108 DISALLOW_COPY_AND_ASSIGN(GPUTracer); |
| 107 }; | 109 }; |
| 108 | 110 |
| 109 class Outputter : public base::RefCounted<Outputter> { | 111 class Outputter : public base::RefCounted<Outputter> { |
| 110 public: | 112 public: |
| 111 virtual void TraceDevice(GpuTracerSource source, | 113 virtual void TraceDevice(GpuTracerSource source, |
| 112 const std::string& category, | 114 const std::string& category, |
| 113 const std::string& name, | 115 const std::string& name, |
| 114 int64 start_time, | 116 int64_t start_time, |
| 115 int64 end_time) = 0; | 117 int64_t end_time) = 0; |
| 116 | 118 |
| 117 virtual void TraceServiceBegin(GpuTracerSource source, | 119 virtual void TraceServiceBegin(GpuTracerSource source, |
| 118 const std::string& category, | 120 const std::string& category, |
| 119 const std::string& name) = 0; | 121 const std::string& name) = 0; |
| 120 | 122 |
| 121 virtual void TraceServiceEnd(GpuTracerSource source, | 123 virtual void TraceServiceEnd(GpuTracerSource source, |
| 122 const std::string& category, | 124 const std::string& category, |
| 123 const std::string& name) = 0; | 125 const std::string& name) = 0; |
| 124 | 126 |
| 125 protected: | 127 protected: |
| 126 virtual ~Outputter() {} | 128 virtual ~Outputter() {} |
| 127 friend class base::RefCounted<Outputter>; | 129 friend class base::RefCounted<Outputter>; |
| 128 }; | 130 }; |
| 129 | 131 |
| 130 class TraceOutputter : public Outputter { | 132 class TraceOutputter : public Outputter { |
| 131 public: | 133 public: |
| 132 static scoped_refptr<TraceOutputter> Create(const std::string& name); | 134 static scoped_refptr<TraceOutputter> Create(const std::string& name); |
| 133 void TraceDevice(GpuTracerSource source, | 135 void TraceDevice(GpuTracerSource source, |
| 134 const std::string& category, | 136 const std::string& category, |
| 135 const std::string& name, | 137 const std::string& name, |
| 136 int64 start_time, | 138 int64_t start_time, |
| 137 int64 end_time) override; | 139 int64_t end_time) override; |
| 138 | 140 |
| 139 void TraceServiceBegin(GpuTracerSource source, | 141 void TraceServiceBegin(GpuTracerSource source, |
| 140 const std::string& category, | 142 const std::string& category, |
| 141 const std::string& name) override; | 143 const std::string& name) override; |
| 142 | 144 |
| 143 void TraceServiceEnd(GpuTracerSource source, | 145 void TraceServiceEnd(GpuTracerSource source, |
| 144 const std::string& category, | 146 const std::string& category, |
| 145 const std::string& name) override; | 147 const std::string& name) override; |
| 146 | 148 |
| 147 protected: | 149 protected: |
| 148 friend class base::RefCounted<Outputter>; | 150 friend class base::RefCounted<Outputter>; |
| 149 explicit TraceOutputter(const std::string& name); | 151 explicit TraceOutputter(const std::string& name); |
| 150 ~TraceOutputter() override; | 152 ~TraceOutputter() override; |
| 151 | 153 |
| 152 base::Thread named_thread_; | 154 base::Thread named_thread_; |
| 153 uint64 local_trace_device_id_ = 0; | 155 uint64_t local_trace_device_id_ = 0; |
| 154 uint64 local_trace_service_id_ = 0; | 156 uint64_t local_trace_service_id_ = 0; |
| 155 | 157 |
| 156 std::stack<uint64> trace_service_id_stack_[NUM_TRACER_SOURCES]; | 158 std::stack<uint64_t> trace_service_id_stack_[NUM_TRACER_SOURCES]; |
| 157 | 159 |
| 158 private: | 160 private: |
| 159 DISALLOW_COPY_AND_ASSIGN(TraceOutputter); | 161 DISALLOW_COPY_AND_ASSIGN(TraceOutputter); |
| 160 }; | 162 }; |
| 161 | 163 |
| 162 class GPU_EXPORT GPUTrace | 164 class GPU_EXPORT GPUTrace |
| 163 : public base::RefCounted<GPUTrace> { | 165 : public base::RefCounted<GPUTrace> { |
| 164 public: | 166 public: |
| 165 GPUTrace(scoped_refptr<Outputter> outputter, | 167 GPUTrace(scoped_refptr<Outputter> outputter, |
| 166 gfx::GPUTimingClient* gpu_timing_client, | 168 gfx::GPUTimingClient* gpu_timing_client, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 213 |
| 212 private: | 214 private: |
| 213 GPUTracer* gpu_tracer_; | 215 GPUTracer* gpu_tracer_; |
| 214 GpuTracerSource source_; | 216 GpuTracerSource source_; |
| 215 }; | 217 }; |
| 216 | 218 |
| 217 } // namespace gles2 | 219 } // namespace gles2 |
| 218 } // namespace gpu | 220 } // namespace gpu |
| 219 | 221 |
| 220 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ | 222 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TRACER_H_ |
| OLD | NEW |