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

Side by Side Diff: cc/output/begin_frame_args.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 | « cc/layers/delegated_renderer_layer_impl_unittest.cc ('k') | cc/output/output_surface.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "cc/output/begin_frame_args.h" 5 #include "cc/output/begin_frame_args.h"
6 #include "ui/gfx/frame_time.h"
6 7
7 namespace cc { 8 namespace cc {
8 9
9 BeginFrameArgs::BeginFrameArgs() 10 BeginFrameArgs::BeginFrameArgs()
10 : frame_time(base::TimeTicks()), 11 : frame_time(base::TimeTicks()),
11 deadline(base::TimeTicks()), 12 deadline(base::TimeTicks()),
12 interval(base::TimeDelta::FromMicroseconds(-1)) { 13 interval(base::TimeDelta::FromMicroseconds(-1)) {
13 } 14 }
14 15
15 BeginFrameArgs::BeginFrameArgs(base::TimeTicks frame_time, 16 BeginFrameArgs::BeginFrameArgs(base::TimeTicks frame_time,
16 base::TimeTicks deadline, 17 base::TimeTicks deadline,
17 base::TimeDelta interval) 18 base::TimeDelta interval)
18 : frame_time(frame_time), 19 : frame_time(frame_time),
19 deadline(deadline), 20 deadline(deadline),
20 interval(interval) 21 interval(interval)
21 {} 22 {}
22 23
23 BeginFrameArgs BeginFrameArgs::Create(base::TimeTicks frame_time, 24 BeginFrameArgs BeginFrameArgs::Create(base::TimeTicks frame_time,
24 base::TimeTicks deadline, 25 base::TimeTicks deadline,
25 base::TimeDelta interval) { 26 base::TimeDelta interval) {
26 return BeginFrameArgs(frame_time, deadline, interval); 27 return BeginFrameArgs(frame_time, deadline, interval);
27 } 28 }
28 29
29 BeginFrameArgs BeginFrameArgs::CreateForSynchronousCompositor() { 30 BeginFrameArgs BeginFrameArgs::CreateForSynchronousCompositor() {
30 // For WebView/SynchronousCompositor, we always want to draw immediately, 31 // For WebView/SynchronousCompositor, we always want to draw immediately,
31 // so we set the deadline to 0 and guess that the interval is 16 milliseconds. 32 // so we set the deadline to 0 and guess that the interval is 16 milliseconds.
32 return BeginFrameArgs(base::TimeTicks::Now(), 33 return BeginFrameArgs(gfx::FrameTime::Now(),
33 base::TimeTicks(), 34 base::TimeTicks(),
34 DefaultInterval()); 35 DefaultInterval());
35 } 36 }
36 37
37 BeginFrameArgs BeginFrameArgs::CreateForTesting() { 38 BeginFrameArgs BeginFrameArgs::CreateForTesting() {
38 base::TimeTicks now = base::TimeTicks::Now(); 39 base::TimeTicks now = gfx::FrameTime::Now();
39 return BeginFrameArgs(now, 40 return BeginFrameArgs(now,
40 now + (DefaultInterval() / 2), 41 now + (DefaultInterval() / 2),
41 DefaultInterval()); 42 DefaultInterval());
42 } 43 }
43 44
44 BeginFrameArgs BeginFrameArgs::CreateExpiredForTesting() { 45 BeginFrameArgs BeginFrameArgs::CreateExpiredForTesting() {
45 base::TimeTicks now = base::TimeTicks::Now(); 46 base::TimeTicks now = gfx::FrameTime::Now();
46 return BeginFrameArgs(now, 47 return BeginFrameArgs(now,
47 now - DefaultInterval(), 48 now - DefaultInterval(),
48 DefaultInterval()); 49 DefaultInterval());
49 } 50 }
50 51
51 // This is a hard-coded deadline adjustment that assumes 60Hz, to be used in 52 // This is a hard-coded deadline adjustment that assumes 60Hz, to be used in
52 // cases where a good estimated draw time is not known. Using 1/3 of the vsync 53 // cases where a good estimated draw time is not known. Using 1/3 of the vsync
53 // as the default adjustment gives the Browser the last 1/3 of a frame to 54 // as the default adjustment gives the Browser the last 1/3 of a frame to
54 // produce output, the Renderer Impl thread the middle 1/3 of a frame to produce 55 // produce output, the Renderer Impl thread the middle 1/3 of a frame to produce
55 // ouput, and the Renderer Main thread the first 1/3 of a frame to produce 56 // ouput, and the Renderer Main thread the first 1/3 of a frame to produce
56 // output. 57 // output.
57 base::TimeDelta BeginFrameArgs::DefaultDeadlineAdjustment() { 58 base::TimeDelta BeginFrameArgs::DefaultDeadlineAdjustment() {
58 return base::TimeDelta::FromMicroseconds(-16666 / 3); 59 return base::TimeDelta::FromMicroseconds(-16666 / 3);
59 } 60 }
60 61
61 base::TimeDelta BeginFrameArgs::DefaultInterval() { 62 base::TimeDelta BeginFrameArgs::DefaultInterval() {
62 return base::TimeDelta::FromMicroseconds(16666); 63 return base::TimeDelta::FromMicroseconds(16666);
63 } 64 }
64 65
65 base::TimeDelta BeginFrameArgs::DefaultRetroactiveBeginFramePeriod() { 66 base::TimeDelta BeginFrameArgs::DefaultRetroactiveBeginFramePeriod() {
66 return base::TimeDelta::FromMicroseconds(4444); 67 return base::TimeDelta::FromMicroseconds(4444);
67 } 68 }
68 69
69 } // namespace cc 70 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/delegated_renderer_layer_impl_unittest.cc ('k') | cc/output/output_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698