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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 return disjoint_counter_; | 44 return disjoint_counter_; |
45 } | 45 } |
46 | 46 |
47 int64 GPUTiming::CalculateTimerOffset(base::Callback<int64(void)> cpu_time) { | 47 int64 GPUTiming::CalculateTimerOffset(base::Callback<int64(void)> cpu_time) { |
48 if (!offset_valid_) { | 48 if (!offset_valid_) { |
49 if (timer_type_ == kTimerTypeDisjoint || timer_type_ == kTimerTypeARB) { | 49 if (timer_type_ == kTimerTypeDisjoint || timer_type_ == kTimerTypeARB) { |
50 GLint64 gl_now = 0; | 50 GLint64 gl_now = 0; |
51 glGetInteger64v(GL_TIMESTAMP, &gl_now); | 51 glGetInteger64v(GL_TIMESTAMP, &gl_now); |
52 int64 now = | 52 int64 now = |
53 cpu_time.is_null() | 53 cpu_time.is_null() |
54 ? base::TimeTicks::NowFromSystemTraceTime().ToInternalValue() | 54 ? (base::TraceTicks::Now() - base::TraceTicks()).InMicroseconds() |
55 : cpu_time.Run(); | 55 : cpu_time.Run(); |
56 offset_ = now - gl_now / base::Time::kNanosecondsPerMicrosecond; | 56 offset_ = now - gl_now / base::Time::kNanosecondsPerMicrosecond; |
57 offset_valid_ = (timer_type_ == kTimerTypeARB); | 57 offset_valid_ = (timer_type_ == kTimerTypeARB); |
58 } else { | 58 } else { |
59 // TODO(dyen): figure out how to calculate the offset for EXT_Timer_Query. | 59 // TODO(dyen): figure out how to calculate the offset for EXT_Timer_Query. |
60 offset_ = 0; | 60 offset_ = 0; |
61 offset_valid_ = true; | 61 offset_valid_ = true; |
62 } | 62 } |
63 } | 63 } |
64 return offset_; | 64 return offset_; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 248 |
249 void GPUTimingClient::SetCpuTimeForTesting( | 249 void GPUTimingClient::SetCpuTimeForTesting( |
250 const base::Callback<int64(void)>& cpu_time) { | 250 const base::Callback<int64(void)>& cpu_time) { |
251 cpu_time_for_testing_ = cpu_time; | 251 cpu_time_for_testing_ = cpu_time; |
252 } | 252 } |
253 | 253 |
254 GPUTimingClient::~GPUTimingClient() { | 254 GPUTimingClient::~GPUTimingClient() { |
255 } | 255 } |
256 | 256 |
257 } // namespace gfx | 257 } // namespace gfx |
OLD | NEW |