OLD | NEW |
---|---|
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 #ifndef CC_OUTPUT_BEGIN_FRAME_ARGS_H_ | 5 #ifndef CC_OUTPUT_BEGIN_FRAME_ARGS_H_ |
6 #define CC_OUTPUT_BEGIN_FRAME_ARGS_H_ | 6 #define CC_OUTPUT_BEGIN_FRAME_ARGS_H_ |
7 | 7 |
8 #include <stdint.h> | |
9 | |
8 #include <memory> | 10 #include <memory> |
9 | 11 |
10 #include "base/location.h" | 12 #include "base/location.h" |
11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
12 #include "base/time/time.h" | 14 #include "base/time/time.h" |
13 #include "base/values.h" | 15 #include "base/values.h" |
14 #include "cc/base/cc_export.h" | 16 #include "cc/base/cc_export.h" |
15 | 17 |
16 namespace base { | 18 namespace base { |
17 namespace trace_event { | 19 namespace trace_event { |
(...skipping 24 matching lines...) Expand all Loading... | |
42 enum BeginFrameArgsType { | 44 enum BeginFrameArgsType { |
43 INVALID, | 45 INVALID, |
44 NORMAL, | 46 NORMAL, |
45 MISSED, | 47 MISSED, |
46 // Not a real type, but used by the IPC system. Should always remain the | 48 // Not a real type, but used by the IPC system. Should always remain the |
47 // *last* value in this enum. | 49 // *last* value in this enum. |
48 BEGIN_FRAME_ARGS_TYPE_MAX, | 50 BEGIN_FRAME_ARGS_TYPE_MAX, |
49 }; | 51 }; |
50 static const char* TypeToString(BeginFrameArgsType type); | 52 static const char* TypeToString(BeginFrameArgsType type); |
51 | 53 |
54 static const uint64_t kInvalidFrameNumber; | |
55 static const uint64_t kStartingFrameNumber; | |
56 | |
52 // Creates an invalid set of values. | 57 // Creates an invalid set of values. |
53 BeginFrameArgs(); | 58 BeginFrameArgs(); |
54 | 59 |
55 #ifdef NDEBUG | 60 #ifdef NDEBUG |
56 typedef const void* CreationLocation; | 61 typedef const void* CreationLocation; |
57 #else | 62 #else |
58 typedef const tracked_objects::Location& CreationLocation; | 63 typedef const tracked_objects::Location& CreationLocation; |
59 tracked_objects::Location created_from; | 64 tracked_objects::Location created_from; |
60 #endif | 65 #endif |
61 | 66 |
62 // You should be able to find all instances where a BeginFrame has been | 67 // You should be able to find all instances where a BeginFrame has been |
63 // created by searching for "BeginFrameArgs::Create". | 68 // created by searching for "BeginFrameArgs::Create". |
64 // The location argument should **always** be BEGINFRAME_FROM_HERE macro. | 69 // The location argument should **always** be BEGINFRAME_FROM_HERE macro. |
65 static BeginFrameArgs Create(CreationLocation location, | 70 static BeginFrameArgs Create(CreationLocation location, |
71 uint64_t source_id, | |
72 uint64_t sequence_number, | |
66 base::TimeTicks frame_time, | 73 base::TimeTicks frame_time, |
67 base::TimeTicks deadline, | 74 base::TimeTicks deadline, |
68 base::TimeDelta interval, | 75 base::TimeDelta interval, |
69 BeginFrameArgsType type); | 76 BeginFrameArgsType type); |
70 | 77 |
71 // This is the default delta that will be used to adjust the deadline when | 78 // This is the default delta that will be used to adjust the deadline when |
72 // proper draw-time estimations are not yet available. | 79 // proper draw-time estimations are not yet available. |
73 static base::TimeDelta DefaultEstimatedParentDrawTime(); | 80 static base::TimeDelta DefaultEstimatedParentDrawTime(); |
74 | 81 |
75 // This is the default interval to use to avoid sprinkling the code with | 82 // This is the default interval to use to avoid sprinkling the code with |
76 // magic numbers. | 83 // magic numbers. |
77 static base::TimeDelta DefaultInterval(); | 84 static base::TimeDelta DefaultInterval(); |
78 | 85 |
79 bool IsValid() const { return interval >= base::TimeDelta(); } | 86 bool IsValid() const { return interval >= base::TimeDelta(); } |
80 | 87 |
81 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> AsValue() const; | 88 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> AsValue() const; |
82 void AsValueInto(base::trace_event::TracedValue* dict) const; | 89 void AsValueInto(base::trace_event::TracedValue* dict) const; |
83 | 90 |
91 uint64_t source_id; | |
92 uint64_t sequence_number; | |
84 base::TimeTicks frame_time; | 93 base::TimeTicks frame_time; |
85 base::TimeTicks deadline; | 94 base::TimeTicks deadline; |
86 base::TimeDelta interval; | 95 base::TimeDelta interval; |
87 BeginFrameArgsType type; | 96 BeginFrameArgsType type; |
88 bool on_critical_path; | 97 bool on_critical_path; |
89 | 98 |
90 private: | 99 private: |
91 BeginFrameArgs(base::TimeTicks frame_time, | 100 BeginFrameArgs(uint64_t source_id, |
101 uint64_t sequence_number, | |
102 base::TimeTicks frame_time, | |
92 base::TimeTicks deadline, | 103 base::TimeTicks deadline, |
93 base::TimeDelta interval, | 104 base::TimeDelta interval, |
94 BeginFrameArgsType type); | 105 BeginFrameArgsType type); |
95 }; | 106 }; |
96 | 107 |
108 // Sent by a BeginFrameObserver as acknowledgment of completing a BeginFrame. | |
109 struct CC_EXPORT BeginFrameAck { | |
110 BeginFrameAck(); | |
111 BeginFrameAck(uint64_t source_id, | |
112 uint64_t sequence_number, | |
113 uint64_t latest_confirmed_frame, | |
114 uint32_t remaining_frames, | |
115 bool has_damages); | |
116 | |
117 // Source identifier of the BeginFrame that is acknowledged. | |
brianderson
2016/12/09 01:08:11
In this comment, can you explain why the source_id
Eric Seckler
2016/12/09 16:47:16
Done. Also added a comment to BeginFrameArgs.
| |
118 uint64_t source_id; | |
119 | |
120 // Sequence number of the BeginFrame that is acknowledged. | |
121 uint64_t sequence_number; | |
122 | |
123 // Sequence number of the latest BeginFrame that was positively acknowledged | |
124 // (confirmed) by the observer. | |
125 // | |
126 // There are two scenarios for a positive acknowledgment: | |
127 // a) All of the observer's pending updates led to successful damages (e.g. a | |
128 // CompositorFrame or a damaged surface). | |
129 // b) The observer did not have any updates and thus did not need to | |
130 // produce damages. | |
131 // A negative acknowledgment, in contrast, describes a situation in which the | |
132 // observer had pending updates, but was unable to successfully produce | |
133 // corresponding damages for all its updates in time. | |
134 // | |
135 // As a result, |latest_confirmed_frame| describes the "staleness" of the last | |
136 // damages that were produced by the observer. Note that even if | |
137 // |has_damages == true|, the damages produced as a result of the acknowledged | |
138 // BeginFrame may be stale (|latest_confirmed_frame < sequence_number|). In | |
139 // such a case, the damages that were produced may contain updates from | |
140 // previous BeginFrames or only part of this BeginFrame's updates. | |
141 // | |
142 // Observers aggregate the |latest_confirmed_frame| of their children: The | |
143 // compositor Scheduler indicates the latest BeginFrame that both impl and | |
144 // main thread confirmed. Likewise, the DisplayScheduler indicates the minimum | |
145 // |latest_confirmed_frame| that all its BeginFrameObservers acknowledged. | |
146 uint64_t latest_confirmed_frame; | |
147 | |
148 // Number of BeginFrames queued at the observer at time of acknowledgment. | |
149 uint32_t remaining_frames; | |
150 | |
151 // |true| if the observer has produced damages (e.g. sent a CompositorFrame or | |
152 // damaged a surface) as part of responding to the BeginFrame. | |
153 bool has_damages; | |
154 }; | |
155 | |
97 } // namespace cc | 156 } // namespace cc |
98 | 157 |
99 #endif // CC_OUTPUT_BEGIN_FRAME_ARGS_H_ | 158 #endif // CC_OUTPUT_BEGIN_FRAME_ARGS_H_ |
OLD | NEW |