Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: ui/gl/gl_surface_win.cc

Issue 27710005: cc: Use HighResNow as timebase if it is fast and reliable (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix DCHECK Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/gfx.gyp ('k') | ui/surface/accelerated_surface_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/debug/trace_event.h" 9 #include "base/debug/trace_event.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/win/windows_version.h" 12 #include "base/win/windows_version.h"
13 #include "third_party/mesa/src/include/GL/osmesa.h" 13 #include "third_party/mesa/src/include/GL/osmesa.h"
14 #include "ui/gfx/frame_time.h"
14 #include "ui/gl/gl_bindings.h" 15 #include "ui/gl/gl_bindings.h"
15 #include "ui/gl/gl_implementation.h" 16 #include "ui/gl/gl_implementation.h"
16 #include "ui/gl/gl_surface_egl.h" 17 #include "ui/gl/gl_surface_egl.h"
17 #include "ui/gl/gl_surface_osmesa.h" 18 #include "ui/gl/gl_surface_osmesa.h"
18 #include "ui/gl/gl_surface_stub.h" 19 #include "ui/gl/gl_surface_stub.h"
19 #include "ui/gl/gl_surface_wgl.h" 20 #include "ui/gl/gl_surface_wgl.h"
20 21
21 namespace gfx { 22 namespace gfx {
22 23
23 // This OSMesa GL surface can use GDI to swap the contents of the buffer to a 24 // This OSMesa GL surface can use GDI to swap the contents of the buffer to a
(...skipping 25 matching lines...) Expand all
49 virtual ~DWMVSyncProvider() {} 50 virtual ~DWMVSyncProvider() {}
50 51
51 virtual void GetVSyncParameters(const UpdateVSyncCallback& callback) { 52 virtual void GetVSyncParameters(const UpdateVSyncCallback& callback) {
52 TRACE_EVENT0("gpu", "DWMVSyncProvider::GetVSyncParameters"); 53 TRACE_EVENT0("gpu", "DWMVSyncProvider::GetVSyncParameters");
53 DWM_TIMING_INFO timing_info; 54 DWM_TIMING_INFO timing_info;
54 timing_info.cbSize = sizeof(timing_info); 55 timing_info.cbSize = sizeof(timing_info);
55 HRESULT result = DwmGetCompositionTimingInfo(NULL, &timing_info); 56 HRESULT result = DwmGetCompositionTimingInfo(NULL, &timing_info);
56 if (result != S_OK) 57 if (result != S_OK)
57 return; 58 return;
58 59
59 base::TimeTicks timebase = base::TimeTicks::FromQPCValue( 60 base::TimeTicks timebase;
60 static_cast<LONGLONG>(timing_info.qpcVBlank)); 61 // If FrameTime is not high resolution, we do not want to translate the
62 // QPC value provided by DWM into the low-resolution timebase, which
63 // would be error prone and jittery. As a fallback, we assume the timebase
64 // is zero.
65 if (gfx::FrameTime::TimestampsAreHighRes()) {
66 timebase = gfx::FrameTime::FromQPCValue(
67 static_cast<LONGLONG>(timing_info.qpcVBlank));
68 }
69
61 // Swap the numerator/denominator to convert frequency to period. 70 // Swap the numerator/denominator to convert frequency to period.
62 if (timing_info.rateRefresh.uiDenominator > 0 && 71 if (timing_info.rateRefresh.uiDenominator > 0 &&
63 timing_info.rateRefresh.uiNumerator > 0) { 72 timing_info.rateRefresh.uiNumerator > 0) {
64 base::TimeDelta interval = base::TimeDelta::FromMicroseconds( 73 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(
65 timing_info.rateRefresh.uiDenominator * 74 timing_info.rateRefresh.uiDenominator *
66 base::Time::kMicrosecondsPerSecond / 75 base::Time::kMicrosecondsPerSecond /
67 timing_info.rateRefresh.uiNumerator); 76 timing_info.rateRefresh.uiNumerator);
68 callback.Run(timebase, interval); 77 callback.Run(timebase, interval);
69 } 78 }
70 } 79 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 282 }
274 case kGLImplementationMockGL: 283 case kGLImplementationMockGL:
275 return new GLSurfaceStub; 284 return new GLSurfaceStub;
276 default: 285 default:
277 NOTREACHED(); 286 NOTREACHED();
278 return NULL; 287 return NULL;
279 } 288 }
280 } 289 }
281 290
282 } // namespace gfx 291 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/gfx.gyp ('k') | ui/surface/accelerated_surface_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698