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

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

Issue 2527283003: cc: Introduce BeginFrame sequence numbers and acknowledgements.
Patch Set: Address Brian's comments. Created 4 years 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/trace_event/trace_event_argument.h" 7 #include "base/trace_event/trace_event_argument.h"
8 #include "cc/proto/base_conversions.h" 8 #include "cc/proto/base_conversions.h"
9 9
10 namespace cc { 10 namespace cc {
11 11
12 const char* BeginFrameArgs::TypeToString(BeginFrameArgsType type) { 12 const char* BeginFrameArgs::TypeToString(BeginFrameArgsType type) {
13 switch (type) { 13 switch (type) {
14 case BeginFrameArgs::INVALID: 14 case BeginFrameArgs::INVALID:
15 return "INVALID"; 15 return "INVALID";
16 case BeginFrameArgs::NORMAL: 16 case BeginFrameArgs::NORMAL:
17 return "NORMAL"; 17 return "NORMAL";
18 case BeginFrameArgs::MISSED: 18 case BeginFrameArgs::MISSED:
19 return "MISSED"; 19 return "MISSED";
20 case BeginFrameArgs::BEGIN_FRAME_ARGS_TYPE_MAX: 20 case BeginFrameArgs::BEGIN_FRAME_ARGS_TYPE_MAX:
21 return "BEGIN_FRAME_ARGS_TYPE_MAX"; 21 return "BEGIN_FRAME_ARGS_TYPE_MAX";
22 } 22 }
23 NOTREACHED(); 23 NOTREACHED();
24 return "???"; 24 return "???";
25 } 25 }
26 26
27 const uint64_t BeginFrameArgs::kInvalidFrameNumber = 0;
28 const uint64_t BeginFrameArgs::kStartingFrameNumber = 1;
29
27 BeginFrameArgs::BeginFrameArgs() 30 BeginFrameArgs::BeginFrameArgs()
28 : frame_time(base::TimeTicks()), 31 : source_id(0),
32 sequence_number(kInvalidFrameNumber),
33 frame_time(base::TimeTicks()),
29 deadline(base::TimeTicks()), 34 deadline(base::TimeTicks()),
30 interval(base::TimeDelta::FromMicroseconds(-1)), 35 interval(base::TimeDelta::FromMicroseconds(-1)),
31 type(BeginFrameArgs::INVALID), 36 type(BeginFrameArgs::INVALID),
32 on_critical_path(true) { 37 on_critical_path(true) {}
33 }
34 38
35 BeginFrameArgs::BeginFrameArgs(base::TimeTicks frame_time, 39 BeginFrameArgs::BeginFrameArgs(uint64_t source_id,
40 uint64_t sequence_number,
41 base::TimeTicks frame_time,
36 base::TimeTicks deadline, 42 base::TimeTicks deadline,
37 base::TimeDelta interval, 43 base::TimeDelta interval,
38 BeginFrameArgs::BeginFrameArgsType type) 44 BeginFrameArgs::BeginFrameArgsType type)
39 : frame_time(frame_time), 45 : source_id(source_id),
46 sequence_number(sequence_number),
47 frame_time(frame_time),
40 deadline(deadline), 48 deadline(deadline),
41 interval(interval), 49 interval(interval),
42 type(type), 50 type(type),
43 on_critical_path(true) { 51 on_critical_path(true) {
52 DCHECK_LT(kInvalidFrameNumber, sequence_number);
44 } 53 }
45 54
46 BeginFrameArgs BeginFrameArgs::Create(BeginFrameArgs::CreationLocation location, 55 BeginFrameArgs BeginFrameArgs::Create(BeginFrameArgs::CreationLocation location,
56 uint64_t source_id,
57 uint64_t sequence_number,
47 base::TimeTicks frame_time, 58 base::TimeTicks frame_time,
48 base::TimeTicks deadline, 59 base::TimeTicks deadline,
49 base::TimeDelta interval, 60 base::TimeDelta interval,
50 BeginFrameArgs::BeginFrameArgsType type) { 61 BeginFrameArgs::BeginFrameArgsType type) {
51 DCHECK_NE(type, BeginFrameArgs::INVALID); 62 DCHECK_NE(type, BeginFrameArgs::INVALID);
52 DCHECK_NE(type, BeginFrameArgs::BEGIN_FRAME_ARGS_TYPE_MAX); 63 DCHECK_NE(type, BeginFrameArgs::BEGIN_FRAME_ARGS_TYPE_MAX);
53 #ifdef NDEBUG 64 #ifdef NDEBUG
54 return BeginFrameArgs(frame_time, deadline, interval, type); 65 return BeginFrameArgs(source_id, sequence_number, frame_time, deadline,
66 interval, type);
55 #else 67 #else
56 BeginFrameArgs args = BeginFrameArgs(frame_time, deadline, interval, type); 68 BeginFrameArgs args(source_id, sequence_number, frame_time, deadline,
69 interval, type);
57 args.created_from = location; 70 args.created_from = location;
58 return args; 71 return args;
59 #endif 72 #endif
60 } 73 }
61 74
62 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 75 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
63 BeginFrameArgs::AsValue() const { 76 BeginFrameArgs::AsValue() const {
64 std::unique_ptr<base::trace_event::TracedValue> state( 77 std::unique_ptr<base::trace_event::TracedValue> state(
65 new base::trace_event::TracedValue()); 78 new base::trace_event::TracedValue());
66 AsValueInto(state.get()); 79 AsValueInto(state.get());
67 return std::move(state); 80 return std::move(state);
68 } 81 }
69 82
70 void BeginFrameArgs::AsValueInto(base::trace_event::TracedValue* state) const { 83 void BeginFrameArgs::AsValueInto(base::trace_event::TracedValue* state) const {
71 state->SetString("type", "BeginFrameArgs"); 84 state->SetString("type", "BeginFrameArgs");
72 state->SetString("subtype", TypeToString(type)); 85 state->SetString("subtype", TypeToString(type));
86 state->SetInteger("source_id", source_id);
87 state->SetInteger("sequence_number", sequence_number);
73 state->SetDouble("frame_time_us", frame_time.ToInternalValue()); 88 state->SetDouble("frame_time_us", frame_time.ToInternalValue());
74 state->SetDouble("deadline_us", deadline.ToInternalValue()); 89 state->SetDouble("deadline_us", deadline.ToInternalValue());
75 state->SetDouble("interval_us", interval.InMicroseconds()); 90 state->SetDouble("interval_us", interval.InMicroseconds());
76 #ifndef NDEBUG 91 #ifndef NDEBUG
77 state->SetString("created_from", created_from.ToString()); 92 state->SetString("created_from", created_from.ToString());
78 #endif 93 #endif
79 state->SetBoolean("on_critical_path", on_critical_path); 94 state->SetBoolean("on_critical_path", on_critical_path);
80 } 95 }
81 96
82 // This is a hard-coded deadline adjustment that assumes 60Hz, to be used in 97 // This is a hard-coded deadline adjustment that assumes 60Hz, to be used in
83 // cases where a good estimated draw time is not known. Using 1/3 of the vsync 98 // cases where a good estimated draw time is not known. Using 1/3 of the vsync
84 // as the default adjustment gives the Browser the last 1/3 of a frame to 99 // as the default adjustment gives the Browser the last 1/3 of a frame to
85 // produce output, the Renderer Impl thread the middle 1/3 of a frame to produce 100 // produce output, the Renderer Impl thread the middle 1/3 of a frame to produce
86 // ouput, and the Renderer Main thread the first 1/3 of a frame to produce 101 // ouput, and the Renderer Main thread the first 1/3 of a frame to produce
87 // output. 102 // output.
88 base::TimeDelta BeginFrameArgs::DefaultEstimatedParentDrawTime() { 103 base::TimeDelta BeginFrameArgs::DefaultEstimatedParentDrawTime() {
89 return base::TimeDelta::FromMicroseconds(16666 / 3); 104 return base::TimeDelta::FromMicroseconds(16666 / 3);
90 } 105 }
91 106
92 base::TimeDelta BeginFrameArgs::DefaultInterval() { 107 base::TimeDelta BeginFrameArgs::DefaultInterval() {
93 return base::TimeDelta::FromMicroseconds(16666); 108 return base::TimeDelta::FromMicroseconds(16666);
94 } 109 }
95 110
111 BeginFrameAck::BeginFrameAck()
112 : source_id(0),
113 sequence_number(BeginFrameArgs::kInvalidFrameNumber),
114 latest_confirmed_frame(BeginFrameArgs::kInvalidFrameNumber),
115 remaining_frames(0),
116 has_damage(false) {}
117
118 BeginFrameAck::BeginFrameAck(uint64_t source_id,
119 uint64_t sequence_number,
120 uint64_t latest_confirmed_frame,
121 uint32_t remaining_frames,
122 bool has_damage)
123 : source_id(source_id),
124 sequence_number(sequence_number),
125 latest_confirmed_frame(latest_confirmed_frame),
126 remaining_frames(remaining_frames),
127 has_damage(has_damage) {
128 DCHECK_LT(BeginFrameArgs::kInvalidFrameNumber, sequence_number);
129 }
130
96 } // namespace cc 131 } // 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