Chromium Code Reviews| Index: gpu/command_buffer/service/gpu_tracer.h |
| diff --git a/gpu/command_buffer/service/gpu_tracer.h b/gpu/command_buffer/service/gpu_tracer.h |
| index f64455c067109924b5626f8bc8ea55fbd0fe7a6f..c4c5c31b72dab2fe3a8de3d1aa282723c71782ea 100644 |
| --- a/gpu/command_buffer/service/gpu_tracer.h |
| +++ b/gpu/command_buffer/service/gpu_tracer.h |
| @@ -10,6 +10,10 @@ |
| #include "base/basictypes.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/threading/thread.h" |
| + |
| +#include "ui/gl/gl_bindings.h" |
| namespace gpu { |
| namespace gles2 { |
| @@ -36,6 +40,88 @@ class GPUTracer { |
| DISALLOW_COPY_AND_ASSIGN(GPUTracer); |
| }; |
| +class Outputter : public base::RefCounted<Outputter> { |
| + public: |
| + virtual void Trace(const std::string& name, |
| + int64 start_time, int64 end_time) = 0; |
| + |
| + protected: |
| + virtual ~Outputter() {} |
| + friend class base::RefCounted<Outputter>; |
| +}; |
| + |
| +class TraceOutputter |
| + : public Outputter, private base::Thread { |
|
piman
2014/01/07 22:47:49
Instead of private inheritance, can you make a bas
vmiura
2014/01/07 23:26:47
Done.
|
| + public: |
| + static scoped_refptr<TraceOutputter> Create(const std::string& name); |
| + virtual void Trace(const std::string& name, int64 start_time, |
| + int64 end_time) OVERRIDE; |
| + |
| + protected: |
| + friend class base::RefCounted<Outputter>; |
| + explicit TraceOutputter(const std::string& name); |
| + virtual ~TraceOutputter(); |
| + |
| + uint64 local_trace_id_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TraceOutputter); |
| +}; |
| + |
| +class Trace : public base::RefCounted<Trace> { |
| + public: |
| + explicit Trace(const std::string& name) : name_(name) {} |
| + |
| + virtual void Start() = 0; |
| + virtual void End() = 0; |
| + |
| + // True if the the results of this query are available. |
| + virtual bool IsAvailable() = 0; |
| + |
| + virtual bool IsProcessable(); |
| + virtual void Process() = 0; |
| + |
| + virtual const std::string& name(); |
| + |
| + protected: |
| + virtual ~Trace() {} |
| + |
| + private: |
| + friend class base::RefCounted<Trace>; |
| + |
| + std::string name_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(Trace); |
| +}; |
| + |
| +class GLARBTimerTrace : public Trace { |
| + public: |
| + GLARBTimerTrace(scoped_refptr<Outputter> outputter, |
| + const std::string& name, |
| + int64 offset); |
| + |
| + // Implementation of Tracer |
| + virtual void Start() OVERRIDE; |
| + virtual void End() OVERRIDE; |
| + virtual bool IsAvailable() OVERRIDE; |
| + virtual void Process() OVERRIDE; |
| + |
| + private: |
| + virtual ~GLARBTimerTrace(); |
| + |
| + void Output(); |
| + |
| + scoped_refptr<Outputter> outputter_; |
| + |
| + int64 offset_; |
| + int64 start_time_; |
| + int64 end_time_; |
| + bool end_requested_; |
| + |
| + GLuint queries_[2]; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(GLARBTimerTrace); |
| +}; |
| + |
| } // namespace gles2 |
| } // namespace gpu |