| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 "ui/gl/gpu_timing.h" | 5 #include "ui/gl/gpu_timing.h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "ui/gl/gl_bindings.h" | 8 #include "ui/gl/gl_bindings.h" |
| 9 #include "ui/gl/gl_context.h" | 9 #include "ui/gl/gl_context.h" |
| 10 #include "ui/gl/gl_version_info.h" | 10 #include "ui/gl/gl_version_info.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 return false; | 202 return false; |
| 203 } | 203 } |
| 204 | 204 |
| 205 int64 GPUTimingClient::CalculateTimerOffset() { | 205 int64 GPUTimingClient::CalculateTimerOffset() { |
| 206 DCHECK(IsTimerOffsetAvailable()); | 206 DCHECK(IsTimerOffsetAvailable()); |
| 207 if (!offset_valid_) { | 207 if (!offset_valid_) { |
| 208 GLint64 gl_now = 0; | 208 GLint64 gl_now = 0; |
| 209 glGetInteger64v(GL_TIMESTAMP, &gl_now); | 209 glGetInteger64v(GL_TIMESTAMP, &gl_now); |
| 210 int64 now = | 210 int64 now = |
| 211 cpu_time_for_testing_.is_null() | 211 cpu_time_for_testing_.is_null() |
| 212 ? base::TimeTicks::NowFromSystemTraceTime().ToInternalValue() | 212 ? (base::TraceTicks::Now() - base::TraceTicks()).InMicroseconds() |
| 213 : cpu_time_for_testing_.Run(); | 213 : cpu_time_for_testing_.Run(); |
| 214 offset_ = now - gl_now / base::Time::kNanosecondsPerMicrosecond; | 214 offset_ = now - gl_now / base::Time::kNanosecondsPerMicrosecond; |
| 215 offset_valid_ = timer_type_ == GPUTiming::kTimerTypeARB; | 215 offset_valid_ = timer_type_ == GPUTiming::kTimerTypeARB; |
| 216 } | 216 } |
| 217 return offset_; | 217 return offset_; |
| 218 } | 218 } |
| 219 | 219 |
| 220 void GPUTimingClient::InvalidateTimerOffset() { | 220 void GPUTimingClient::InvalidateTimerOffset() { |
| 221 offset_valid_ = false; | 221 offset_valid_ = false; |
| 222 } | 222 } |
| 223 | 223 |
| 224 void GPUTimingClient::SetCpuTimeForTesting( | 224 void GPUTimingClient::SetCpuTimeForTesting( |
| 225 const base::Callback<int64(void)>& cpu_time) { | 225 const base::Callback<int64(void)>& cpu_time) { |
| 226 cpu_time_for_testing_ = cpu_time; | 226 cpu_time_for_testing_ = cpu_time; |
| 227 } | 227 } |
| 228 | 228 |
| 229 GPUTimingClient::~GPUTimingClient() { | 229 GPUTimingClient::~GPUTimingClient() { |
| 230 } | 230 } |
| 231 | 231 |
| 232 } // namespace gfx | 232 } // namespace gfx |
| OLD | NEW |