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 "ui/gl/gl_surface.h" | 5 #include "ui/gl/gl_surface.h" |
6 | 6 |
7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
13 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
14 #include "ui/gfx/frame_time.h" | 14 |
15 #include "ui/gfx/native_widget_types.h" | 15 #include "ui/gfx/native_widget_types.h" |
16 #include "ui/gl/gl_bindings.h" | 16 #include "ui/gl/gl_bindings.h" |
17 #include "ui/gl/gl_implementation.h" | 17 #include "ui/gl/gl_implementation.h" |
18 #include "ui/gl/gl_surface_egl.h" | 18 #include "ui/gl/gl_surface_egl.h" |
19 #include "ui/gl/gl_surface_osmesa.h" | 19 #include "ui/gl/gl_surface_osmesa.h" |
20 #include "ui/gl/gl_surface_stub.h" | 20 #include "ui/gl/gl_surface_stub.h" |
21 #include "ui/gl/gl_surface_wgl.h" | 21 #include "ui/gl/gl_surface_wgl.h" |
22 | 22 |
23 // From ANGLE's egl/eglext.h. | 23 // From ANGLE's egl/eglext.h. |
24 #if !defined(EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE) | 24 #if !defined(EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 base::TimeDelta rate_interval; | 82 base::TimeDelta rate_interval; |
83 if (timing_info.rateRefresh.uiDenominator > 0 && | 83 if (timing_info.rateRefresh.uiDenominator > 0 && |
84 timing_info.rateRefresh.uiNumerator > 0) { | 84 timing_info.rateRefresh.uiNumerator > 0) { |
85 // Swap the numerator/denominator to convert frequency to period. | 85 // Swap the numerator/denominator to convert frequency to period. |
86 rate_interval = base::TimeDelta::FromMicroseconds( | 86 rate_interval = base::TimeDelta::FromMicroseconds( |
87 timing_info.rateRefresh.uiDenominator * | 87 timing_info.rateRefresh.uiDenominator * |
88 base::Time::kMicrosecondsPerSecond / | 88 base::Time::kMicrosecondsPerSecond / |
89 timing_info.rateRefresh.uiNumerator); | 89 timing_info.rateRefresh.uiNumerator); |
90 } | 90 } |
91 | 91 |
92 if (gfx::FrameTime::TimestampsAreHighRes()) { | 92 if (base::TimeTicks::IsHighResolution()) { |
93 // qpcRefreshPeriod is very accurate but noisy, and must be used with | 93 // qpcRefreshPeriod is very accurate but noisy, and must be used with |
94 // a high resolution timebase to avoid frequently missing Vsync. | 94 // a high resolution timebase to avoid frequently missing Vsync. |
95 timebase = gfx::FrameTime::FromQPCValue( | 95 timebase = base::TimeTicks::FromQPCValue( |
96 static_cast<LONGLONG>(timing_info.qpcVBlank)); | 96 static_cast<LONGLONG>(timing_info.qpcVBlank)); |
97 interval = base::TimeDelta::FromQPCValue( | 97 interval = base::TimeDelta::FromQPCValue( |
98 static_cast<LONGLONG>(timing_info.qpcRefreshPeriod)); | 98 static_cast<LONGLONG>(timing_info.qpcRefreshPeriod)); |
99 // Check for interval values that are impossibly low. A 29 microsecond | 99 // Check for interval values that are impossibly low. A 29 microsecond |
100 // interval was seen (from a qpcRefreshPeriod of 60). | 100 // interval was seen (from a qpcRefreshPeriod of 60). |
101 if (interval < base::TimeDelta::FromMilliseconds(1)) { | 101 if (interval < base::TimeDelta::FromMilliseconds(1)) { |
102 interval = rate_interval; | 102 interval = rate_interval; |
103 } | 103 } |
104 // Check for the qpcRefreshPeriod interval being improbably small | 104 // Check for the qpcRefreshPeriod interval being improbably small |
105 // compared to the rateRefresh calculated interval, as another | 105 // compared to the rateRefresh calculated interval, as another |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 NOTREACHED(); | 357 NOTREACHED(); |
358 return NULL; | 358 return NULL; |
359 } | 359 } |
360 } | 360 } |
361 | 361 |
362 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { | 362 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { |
363 return GetDC(NULL); | 363 return GetDC(NULL); |
364 } | 364 } |
365 | 365 |
366 } // namespace gfx | 366 } // namespace gfx |
OLD | NEW |