[M108 Migration][VD] Avoid pending frame counter becoming negative
[platform/framework/web/chromium-efl.git] / cc / metrics / frame_info.h
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.
4
5 #ifndef CC_METRICS_FRAME_INFO_H_
6 #define CC_METRICS_FRAME_INFO_H_
7
8 #include "base/time/time.h"
9 #include "cc/cc_export.h"
10
11 namespace cc {
12
13 struct CC_EXPORT FrameInfo {
14   enum class FrameFinalState {
15     kNoUpdateDesired,
16     kDropped,
17
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.
24     kPresentedAll,
25
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.
30     //
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,
37   };
38   FrameFinalState final_state = FrameFinalState::kNoUpdateDesired;
39
40   enum class SmoothThread {
41     kSmoothNone,
42     kSmoothCompositor,
43     kSmoothMain,
44     kSmoothBoth
45   };
46   SmoothThread smooth_thread = SmoothThread::kSmoothNone;
47
48   enum class MainThreadResponse {
49     kIncluded,
50     kMissing,
51   };
52   MainThreadResponse main_thread_response = MainThreadResponse::kIncluded;
53
54   enum class SmoothEffectDrivingThread { kMain, kCompositor, kUnknown };
55   SmoothEffectDrivingThread scroll_thread = SmoothEffectDrivingThread::kUnknown;
56
57   bool has_missing_content = false;
58
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;
63
64   bool IsDroppedAffectingSmoothness() const;
65   void MergeWith(const FrameInfo& info);
66
67   bool Validate() const;
68
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;
74
75   bool IsScrollPrioritizeFrameDropped() const;
76
77  private:
78   bool was_merged = false;
79   bool compositor_update_was_dropped = false;
80   bool main_update_was_dropped = false;
81 };
82
83 }  // namespace cc
84
85 #endif  // CC_METRICS_FRAME_INFO_H_