| 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 #include "gpu/command_buffer/service/gpu_tracer.h" | 5 #include "gpu/command_buffer/service/gpu_tracer.h" |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 glDeleteQueries(2, queries_); | 230 glDeleteQueries(2, queries_); |
| 231 | 231 |
| 232 TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP0("gpu", name().c_str(), | 232 TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP0("gpu", name().c_str(), |
| 233 this, outputter_->Id(), start_time_); | 233 this, outputter_->Id(), start_time_); |
| 234 TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP0("gpu", name().c_str(), | 234 TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP0("gpu", name().c_str(), |
| 235 this, outputter_->Id(), end_time_); | 235 this, outputter_->Id(), end_time_); |
| 236 } | 236 } |
| 237 | 237 |
| 238 bool GPUTracerImpl::Begin(const std::string& name) { | 238 bool GPUTracerImpl::Begin(const std::string& name) { |
| 239 // Make sure we are not nesting trace commands. | 239 // Make sure we are not nesting trace commands. |
| 240 if (current_trace_) | 240 if (current_trace_.get()) |
| 241 return false; | 241 return false; |
| 242 | 242 |
| 243 current_trace_ = CreateTrace(name); | 243 current_trace_ = CreateTrace(name); |
| 244 current_trace_->Start(); | 244 current_trace_->Start(); |
| 245 return true; | 245 return true; |
| 246 } | 246 } |
| 247 | 247 |
| 248 bool GPUTracerImpl::End() { | 248 bool GPUTracerImpl::End() { |
| 249 if (!current_trace_) | 249 if (!current_trace_.get()) |
| 250 return false; | 250 return false; |
| 251 | 251 |
| 252 current_trace_->End(); | 252 current_trace_->End(); |
| 253 if (current_trace_->IsProcessable()) | 253 if (current_trace_->IsProcessable()) |
| 254 traces_.push_back(current_trace_); | 254 traces_.push_back(current_trace_); |
| 255 current_trace_ = NULL; | 255 current_trace_ = NULL; |
| 256 | 256 |
| 257 IssueProcessTask(); | 257 IssueProcessTask(); |
| 258 return true; | 258 return true; |
| 259 } | 259 } |
| 260 | 260 |
| 261 void GPUTracerImpl::Process() { | 261 void GPUTracerImpl::Process() { |
| 262 process_posted_ = false; | 262 process_posted_ = false; |
| 263 | 263 |
| 264 while (!traces_.empty() && traces_.front()->IsAvailable()) { | 264 while (!traces_.empty() && traces_.front()->IsAvailable()) { |
| 265 traces_.front()->Process(); | 265 traces_.front()->Process(); |
| 266 traces_.pop_front(); | 266 traces_.pop_front(); |
| 267 } | 267 } |
| 268 | 268 |
| 269 IssueProcessTask(); | 269 IssueProcessTask(); |
| 270 } | 270 } |
| 271 | 271 |
| 272 const std::string& GPUTracerImpl::CurrentName() const { | 272 const std::string& GPUTracerImpl::CurrentName() const { |
| 273 if (!current_trace_) | 273 if (!current_trace_.get()) |
| 274 return EmptyString(); | 274 return EmptyString(); |
| 275 return current_trace_->name(); | 275 return current_trace_->name(); |
| 276 } | 276 } |
| 277 | 277 |
| 278 scoped_refptr<Trace> GPUTracerImpl::CreateTrace(const std::string& name) { | 278 scoped_refptr<Trace> GPUTracerImpl::CreateTrace(const std::string& name) { |
| 279 return new NoopTrace(name); | 279 return new NoopTrace(name); |
| 280 } | 280 } |
| 281 | 281 |
| 282 void GPUTracerImpl::IssueProcessTask() { | 282 void GPUTracerImpl::IssueProcessTask() { |
| 283 if (traces_.empty() || process_posted_) | 283 if (traces_.empty() || process_posted_) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 } // namespace | 338 } // namespace |
| 339 | 339 |
| 340 scoped_ptr<GPUTracer> GPUTracer::Create() { | 340 scoped_ptr<GPUTracer> GPUTracer::Create() { |
| 341 if (gfx::g_driver_gl.ext.b_GL_ARB_timer_query) | 341 if (gfx::g_driver_gl.ext.b_GL_ARB_timer_query) |
| 342 return scoped_ptr<GPUTracer>(new GPUTracerARBTimerQuery()); | 342 return scoped_ptr<GPUTracer>(new GPUTracerARBTimerQuery()); |
| 343 return scoped_ptr<GPUTracer>(new GPUTracerImpl()); | 343 return scoped_ptr<GPUTracer>(new GPUTracerImpl()); |
| 344 } | 344 } |
| 345 | 345 |
| 346 } // namespace gles2 | 346 } // namespace gles2 |
| 347 } // namespace gpu | 347 } // namespace gpu |
| OLD | NEW |