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

Side by Side Diff: cc/output/begin_frame_args.cc

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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/output/begin_frame_args.h ('k') | cc/output/begin_frame_args_unittest.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 6
7 #include "base/debug/trace_event_argument.h" 7 #include "base/debug/trace_event_argument.h"
8 #include "ui/gfx/frame_time.h" 8 #include "ui/gfx/frame_time.h"
9 9
10 namespace cc { 10 namespace cc {
11 11
12 const char* BeginFrameArgs::TypeToString(BeginFrameArgsType type) {
13 switch (type) {
14 case BeginFrameArgs::INVALID:
15 return "INVALID";
16 case BeginFrameArgs::NORMAL:
17 return "NORMAL";
18 case BeginFrameArgs::SYNCHRONOUS:
19 return "SYNCHRONOUS";
20 case BeginFrameArgs::MISSED:
21 return "MISSED";
22 }
23 NOTREACHED();
24 return "???";
25 }
26
12 BeginFrameArgs::BeginFrameArgs() 27 BeginFrameArgs::BeginFrameArgs()
13 : frame_time(base::TimeTicks()), 28 : frame_time(base::TimeTicks()),
14 deadline(base::TimeTicks()), 29 deadline(base::TimeTicks()),
15 interval(base::TimeDelta::FromMicroseconds(-1)), 30 interval(base::TimeDelta::FromMicroseconds(-1)),
16 type(BeginFrameArgs::INVALID) { 31 type(BeginFrameArgs::INVALID) {
17 } 32 }
18 33
19 BeginFrameArgs::BeginFrameArgs(base::TimeTicks frame_time, 34 BeginFrameArgs::BeginFrameArgs(base::TimeTicks frame_time,
20 base::TimeTicks deadline, 35 base::TimeTicks deadline,
21 base::TimeDelta interval, 36 base::TimeDelta interval,
22 BeginFrameArgs::BeginFrameArgsType type) 37 BeginFrameArgs::BeginFrameArgsType type)
23 : frame_time(frame_time), 38 : frame_time(frame_time),
24 deadline(deadline), 39 deadline(deadline),
25 interval(interval), 40 interval(interval),
26 type(type) { 41 type(type) {
27 } 42 }
28 43
29 BeginFrameArgs BeginFrameArgs::CreateTyped( 44 BeginFrameArgs BeginFrameArgs::Create(base::TimeTicks frame_time,
30 base::TimeTicks frame_time, 45 base::TimeTicks deadline,
31 base::TimeTicks deadline, 46 base::TimeDelta interval,
32 base::TimeDelta interval, 47 BeginFrameArgs::BeginFrameArgsType type) {
33 BeginFrameArgs::BeginFrameArgsType type) {
34 DCHECK_NE(type, BeginFrameArgs::INVALID); 48 DCHECK_NE(type, BeginFrameArgs::INVALID);
35 return BeginFrameArgs(frame_time, deadline, interval, type); 49 return BeginFrameArgs(frame_time, deadline, interval, type);
36 } 50 }
37 51
38 BeginFrameArgs BeginFrameArgs::Create(base::TimeTicks frame_time,
39 base::TimeTicks deadline,
40 base::TimeDelta interval) {
41 return CreateTyped(frame_time, deadline, interval, BeginFrameArgs::NORMAL);
42 }
43
44 scoped_refptr<base::debug::ConvertableToTraceFormat> BeginFrameArgs::AsValue() 52 scoped_refptr<base::debug::ConvertableToTraceFormat> BeginFrameArgs::AsValue()
45 const { 53 const {
46 scoped_refptr<base::debug::TracedValue> state = 54 scoped_refptr<base::debug::TracedValue> state =
47 new base::debug::TracedValue(); 55 new base::debug::TracedValue();
48 AsValueInto(state.get()); 56 AsValueInto(state.get());
49 return state; 57 return state;
50 } 58 }
51 59
52 void BeginFrameArgs::AsValueInto(base::debug::TracedValue* state) const { 60 void BeginFrameArgs::AsValueInto(base::debug::TracedValue* state) const {
53 state->SetString("type", "BeginFrameArgs"); 61 state->SetString("type", "BeginFrameArgs");
54 switch (type) { 62 state->SetString("subtype", TypeToString(type));
55 case BeginFrameArgs::INVALID:
56 state->SetString("subtype", "INVALID");
57 break;
58 case BeginFrameArgs::NORMAL:
59 state->SetString("subtype", "NORMAL");
60 break;
61 case BeginFrameArgs::SYNCHRONOUS:
62 state->SetString("subtype", "SYNCHRONOUS");
63 break;
64 case BeginFrameArgs::MISSED:
65 state->SetString("subtype", "MISSED");
66 break;
67 }
68 state->SetDouble("frame_time_us", frame_time.ToInternalValue()); 63 state->SetDouble("frame_time_us", frame_time.ToInternalValue());
69 state->SetDouble("deadline_us", deadline.ToInternalValue()); 64 state->SetDouble("deadline_us", deadline.ToInternalValue());
70 state->SetDouble("interval_us", interval.InMicroseconds()); 65 state->SetDouble("interval_us", interval.InMicroseconds());
71 } 66 }
72 67
73 BeginFrameArgs BeginFrameArgs::CreateForSynchronousCompositor(
74 base::TimeTicks now) {
75 // For WebView/SynchronousCompositor, we always want to draw immediately,
76 // so we set the deadline to 0 and guess that the interval is 16 milliseconds.
77 if (now.is_null())
78 now = gfx::FrameTime::Now();
79 return CreateTyped(
80 now, base::TimeTicks(), DefaultInterval(), BeginFrameArgs::SYNCHRONOUS);
81 }
82
83 // This is a hard-coded deadline adjustment that assumes 60Hz, to be used in 68 // This is a hard-coded deadline adjustment that assumes 60Hz, to be used in
84 // cases where a good estimated draw time is not known. Using 1/3 of the vsync 69 // cases where a good estimated draw time is not known. Using 1/3 of the vsync
85 // as the default adjustment gives the Browser the last 1/3 of a frame to 70 // as the default adjustment gives the Browser the last 1/3 of a frame to
86 // produce output, the Renderer Impl thread the middle 1/3 of a frame to produce 71 // produce output, the Renderer Impl thread the middle 1/3 of a frame to produce
87 // ouput, and the Renderer Main thread the first 1/3 of a frame to produce 72 // ouput, and the Renderer Main thread the first 1/3 of a frame to produce
88 // output. 73 // output.
89 base::TimeDelta BeginFrameArgs::DefaultEstimatedParentDrawTime() { 74 base::TimeDelta BeginFrameArgs::DefaultEstimatedParentDrawTime() {
90 return base::TimeDelta::FromMicroseconds(16666 / 3); 75 return base::TimeDelta::FromMicroseconds(16666 / 3);
91 } 76 }
92 77
93 base::TimeDelta BeginFrameArgs::DefaultInterval() { 78 base::TimeDelta BeginFrameArgs::DefaultInterval() {
94 return base::TimeDelta::FromMicroseconds(16666); 79 return base::TimeDelta::FromMicroseconds(16666);
95 } 80 }
96 81
97 base::TimeDelta BeginFrameArgs::DefaultRetroactiveBeginFramePeriod() { 82 base::TimeDelta BeginFrameArgs::DefaultRetroactiveBeginFramePeriod() {
98 return base::TimeDelta::FromMicroseconds(4444); 83 return base::TimeDelta::FromMicroseconds(4444);
99 } 84 }
100 85
101 } // namespace cc 86 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/begin_frame_args.h ('k') | cc/output/begin_frame_args_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698