1 // Copyright 2021 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CC_METRICS_FRAME_INFO_H_
6 #define CC_METRICS_FRAME_INFO_H_
8 #include "base/time/time.h"
9 #include "cc/cc_export.h"
13 struct CC_EXPORT FrameInfo {
14 enum class FrameFinalState {
18 // A `presented all` frame contains all the desired update for this vsync.
19 // Note that this doesn't necessarily mean the frame included updates from
20 // both the main and the compositor thread. For example, if there's only a
21 // main-thread animation running, and the animation update was included in
22 // the frame produced, then it's `presented all`, although the compositor
23 // thread did not have any updates for this frame.
26 // A `partial update` frame contains updates from a compositor frame, but
27 // misses the update from the main-thread for the same vsync. However, it is
28 // still possible for such a `partial update` frame to contain new update
29 // from an earlier main-thread.
31 // `kPresentedPartialOldMain` represents a partial update frame without any
32 // new update from the main-thread.
33 // `kPresentedPartialNewMain` represents a partial update frame with some
34 // new update from the main-thread.
35 kPresentedPartialOldMain,
36 kPresentedPartialNewMain,
38 FrameFinalState final_state = FrameFinalState::kNoUpdateDesired;
40 enum class SmoothThread {
46 SmoothThread smooth_thread = SmoothThread::kSmoothNone;
48 enum class MainThreadResponse {
52 MainThreadResponse main_thread_response = MainThreadResponse::kIncluded;
54 enum class SmoothEffectDrivingThread { kMain, kCompositor, kUnknown };
55 SmoothEffectDrivingThread scroll_thread = SmoothEffectDrivingThread::kUnknown;
57 bool has_missing_content = false;
59 // The total latency for the frame. If the frame had to be 'split' (i.e.
60 // compositor-thread update and main-thread updates were presented in separate
61 // frames), then this contains the maximum latency of the two updates.
62 base::TimeDelta total_latency;
64 bool IsDroppedAffectingSmoothness() const;
65 void MergeWith(const FrameInfo& info);
67 bool Validate() const;
69 // Returns whether any update from the compositor/main thread was dropped, and
70 // whether the update was part of a smooth sequence.
71 bool WasSmoothCompositorUpdateDropped() const;
72 bool WasSmoothMainUpdateDropped() const;
73 bool WasSmoothMainUpdateExpected() const;
75 bool IsScrollPrioritizeFrameDropped() const;
78 bool was_merged = false;
79 bool compositor_update_was_dropped = false;
80 bool main_update_was_dropped = false;
85 #endif // CC_METRICS_FRAME_INFO_H_