Chromium Code Reviews| Index: gpu/command_buffer/service/gpu_tracer.cc |
| diff --git a/gpu/command_buffer/service/gpu_tracer.cc b/gpu/command_buffer/service/gpu_tracer.cc |
| index c9bb50938ba499ef99511929af1c4f92af7346d9..dbd3980942d53606ab073cce1b7ed7fefbc0bbe6 100644 |
| --- a/gpu/command_buffer/service/gpu_tracer.cc |
| +++ b/gpu/command_buffer/service/gpu_tracer.cc |
| @@ -69,11 +69,11 @@ class GPUTracerImpl |
| : public GPUTracer, |
| public base::SupportsWeakPtr<GPUTracerImpl> { |
| public: |
| - GPUTracerImpl() |
| - : gpu_category_enabled_( |
| - TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED("gpu")), |
| - process_posted_(false) { |
| - } |
| + explicit GPUTracerImpl(base::WeakPtr<gles2::GLES2Decoder> decoder) |
| + : GPUTracer(decoder), |
| + gpu_category_enabled_( |
| + TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED("gpu")), |
| + process_posted_(false) {} |
| virtual ~GPUTracerImpl() {} |
| // Implementation of gpu::gles2::GPUTracer |
| @@ -103,7 +103,7 @@ class GPUTracerImpl |
| class GPUTracerARBTimerQuery : public GPUTracerImpl { |
| public: |
| - GPUTracerARBTimerQuery(); |
| + explicit GPUTracerARBTimerQuery(base::WeakPtr<gles2::GLES2Decoder> decoder); |
| virtual ~GPUTracerARBTimerQuery(); |
| // Implementation of GPUTracerImpl |
| @@ -204,6 +204,9 @@ bool GPUTracerImpl::End() { |
| void GPUTracerImpl::Process() { |
| process_posted_ = false; |
| + // Make owning decoder's GL context current |
| + decoder_->MakeCurrent(); |
|
piman
2014/01/09 02:10:33
note: MakeCurrent can fail (e.g. lost context). In
vmiura
2014/01/09 02:57:02
Done.
In this case I will skip all GL calls, incl
|
| + |
| while (!traces_.empty() && traces_.front()->IsAvailable()) { |
| traces_.front()->Process(); |
| traces_.pop_front(); |
| @@ -233,10 +236,9 @@ void GPUTracerImpl::IssueProcessTask() { |
| base::TimeDelta::FromMilliseconds(kProcessInterval)); |
| } |
| -GPUTracerARBTimerQuery::GPUTracerARBTimerQuery() |
| - : GPUTracerImpl(), |
| - timer_offset_(0), |
| - last_offset_check_(0) { |
| +GPUTracerARBTimerQuery::GPUTracerARBTimerQuery( |
| + base::WeakPtr<gles2::GLES2Decoder> decoder) |
| + : GPUTracerImpl(decoder), timer_offset_(0), last_offset_check_(0) { |
| CalculateTimerOffset(); |
| outputter_ = TraceOutputter::Create("GL_ARB_timer_query"); |
| } |
| @@ -278,11 +280,17 @@ void GPUTracerARBTimerQuery::CalculateTimerOffset() { |
| last_offset_check_ = system_now.ToInternalValue(); |
| } |
| -scoped_ptr<GPUTracer> GPUTracer::Create() { |
| +GPUTracer::GPUTracer(base::WeakPtr<gles2::GLES2Decoder> decoder) |
| + : decoder_(decoder) {} |
| + |
| +GPUTracer::~GPUTracer() {} |
| + |
| +scoped_ptr<GPUTracer> GPUTracer::Create( |
| + base::WeakPtr<gles2::GLES2Decoder> decoder) { |
| if (gfx::g_driver_gl.ext.b_GL_ARB_timer_query) { |
| - return scoped_ptr<GPUTracer>(new GPUTracerARBTimerQuery()); |
| + return scoped_ptr<GPUTracer>(new GPUTracerARBTimerQuery(decoder)); |
| } |
| - return scoped_ptr<GPUTracer>(new GPUTracerImpl()); |
| + return scoped_ptr<GPUTracer>(new GPUTracerImpl(decoder)); |
| } |
| } // namespace gles2 |