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 // |source_id| and |sequence_number| identify a BeginFrame within a single |
| 92 // process and are set by the original BeginFrameSource that created the |
| 93 // BeginFrameArgs. When |source_id| of consecutive BeginFrameArgs changes, |
| 94 // observers should expect the continuity of |sequence_number| to break. |
| 95 uint64_t source_id; |
| 96 uint64_t sequence_number; |
| 97 |
84 base::TimeTicks frame_time; | 98 base::TimeTicks frame_time; |
85 base::TimeTicks deadline; | 99 base::TimeTicks deadline; |
86 base::TimeDelta interval; | 100 base::TimeDelta interval; |
87 BeginFrameArgsType type; | 101 BeginFrameArgsType type; |
88 bool on_critical_path; | 102 bool on_critical_path; |
89 | 103 |
90 private: | 104 private: |
91 BeginFrameArgs(base::TimeTicks frame_time, | 105 BeginFrameArgs(uint64_t source_id, |
| 106 uint64_t sequence_number, |
| 107 base::TimeTicks frame_time, |
92 base::TimeTicks deadline, | 108 base::TimeTicks deadline, |
93 base::TimeDelta interval, | 109 base::TimeDelta interval, |
94 BeginFrameArgsType type); | 110 BeginFrameArgsType type); |
95 }; | 111 }; |
96 | 112 |
| 113 // Sent by a BeginFrameObserver as acknowledgment of completing a BeginFrame. |
| 114 struct CC_EXPORT BeginFrameAck { |
| 115 BeginFrameAck(); |
| 116 BeginFrameAck(uint64_t source_id, |
| 117 uint64_t sequence_number, |
| 118 uint64_t latest_confirmed_frame, |
| 119 uint32_t remaining_frames, |
| 120 bool has_damage); |
| 121 |
| 122 // Source identifier of the BeginFrame that is acknowledged. The |
| 123 // BeginFrameSource that receives the acknowledgment uses this to discard |
| 124 // BeginFrameAcks for BeginFrames sent by a different source. Such a situation |
| 125 // may occur when the BeginFrameSource of the observer changes while a |
| 126 // BeginFrame from the old source is still in flight. |
| 127 uint64_t source_id; |
| 128 |
| 129 // Sequence number of the BeginFrame that is acknowledged. |
| 130 uint64_t sequence_number; |
| 131 |
| 132 // Sequence number of the latest BeginFrame that was positively acknowledged |
| 133 // (confirmed) by the observer. |
| 134 // |
| 135 // There are two scenarios for a positive acknowledgment: |
| 136 // a) All of the observer's pending updates led to successful damage (e.g. a |
| 137 // CompositorFrame or a damaged surface). |
| 138 // b) The observer did not have any updates and thus did not need to |
| 139 // produce damage. |
| 140 // A negative acknowledgment, in contrast, describes a situation in which the |
| 141 // observer had pending updates, but was unable to successfully produce |
| 142 // corresponding damage for all its updates in time. |
| 143 // |
| 144 // As a result, |latest_confirmed_frame| describes the "staleness" of the last |
| 145 // damage that was produced by the observer. Note that even if |
| 146 // |has_damage == true|, the damage produced as a result of the acknowledged |
| 147 // BeginFrame may be stale (|latest_confirmed_frame < sequence_number|). In |
| 148 // such a case, the damage that was produced may contain updates from previous |
| 149 // BeginFrames or only part of this BeginFrame's updates. |
| 150 // |
| 151 // Observers aggregate the |latest_confirmed_frame| of their children: The |
| 152 // compositor Scheduler indicates the latest BeginFrame that both impl and |
| 153 // main thread confirmed. Likewise, the DisplayScheduler indicates the minimum |
| 154 // |latest_confirmed_frame| that all its BeginFrameObservers acknowledged. |
| 155 uint64_t latest_confirmed_frame; |
| 156 |
| 157 // Number of BeginFrames queued at the observer at time of acknowledgment. |
| 158 uint32_t remaining_frames; |
| 159 |
| 160 // |true| if the observer has produced damage (e.g. sent a CompositorFrame or |
| 161 // damaged a surface) as part of responding to the BeginFrame. |
| 162 bool has_damage; |
| 163 }; |
| 164 |
97 } // namespace cc | 165 } // namespace cc |
98 | 166 |
99 #endif // CC_OUTPUT_BEGIN_FRAME_ARGS_H_ | 167 #endif // CC_OUTPUT_BEGIN_FRAME_ARGS_H_ |
OLD | NEW |