File: compositor_observer.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (114 lines) | stat: -rw-r--r-- 4,815 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_COMPOSITOR_COMPOSITOR_OBSERVER_H_
#define UI_COMPOSITOR_COMPOSITOR_OBSERVER_H_

#include "base/containers/flat_set.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/viz/common/surfaces/frame_sink_id.h"
#include "ui/base/ozone_buildflags.h"
#include "ui/compositor/compositor_export.h"

namespace viz {
class SurfaceInfo;
}

namespace gfx {
class Size;
struct PresentationFeedback;
}  // namespace gfx

namespace ui {

class Compositor;

// A compositor observer is notified when compositing completes.
class COMPOSITOR_EXPORT CompositorObserver {
 public:
  virtual ~CompositorObserver() = default;

  // A commit proxies information from the main thread to the compositor
  // thread. It typically happens when some state changes that will require a
  // composite. In the multi-threaded case, many commits may happen between
  // two successive composites. In the single-threaded, a single commit
  // between two composites (just before the composite as part of the
  // composite cycle). If the compositor is locked, it will not send this
  // this signal.
  virtual void OnCompositingDidCommit(Compositor* compositor) {}

  // Called when compositing started: it has taken all the layer changes into
  // account and has issued the graphics commands.
  virtual void OnCompositingStarted(Compositor* compositor,
                                    base::TimeTicks start_time) {}

  // This is an inaccurate signal that has been used to represent that content
  // was displayed. This actually maps to the removal of backpressure by the
  // GPU. This can be signalled when the GPU attempts to Draw; when a submitted
  // frame, that has not drawn, is being replaced by a newer one; or merged with
  // future OnBeginFrames.
  //
  // To determine when presentation occurred see `OnDidPresentCompositorFrame`.
  virtual void OnCompositingAckDeprecated(Compositor* compositor) {}

  // Called when a child of the compositor is resizing.
  virtual void OnCompositingChildResizing(Compositor* compositor) {}

#if BUILDFLAG(IS_LINUX) && BUILDFLAG(IS_OZONE_X11)
  // Called when a swap with new size is completed.
  virtual void OnCompositingCompleteSwapWithNewSize(ui::Compositor* compositor,
                                                    const gfx::Size& size) {}
#endif  // BUILDFLAG(IS_LINUX) && BUILDFLAG(IS_OZONE_X11)

  // Called at the top of the compositor's destructor, to give observers a
  // chance to remove themselves.
  virtual void OnCompositingShuttingDown(Compositor* compositor) {}

  // Called when the presentation feedback was received from the viz.
  virtual void OnDidPresentCompositorFrame(
      uint32_t frame_token,
      const gfx::PresentationFeedback& feedback) {}

  // Called when first AnimationObserver was added to the compositor.
  virtual void OnFirstAnimationStarted(Compositor* compositor) {}

  // Called on first BeginMainFrame after the last animation has finished.
  // This presents "animations finished" event from user point of view.
  // When animations are temporary stopped and restarted in between painting
  // two frames technically animations have stopped, but users will never
  // notice it because animations are immediately restarted. This way we delay
  // "Last Animation Ended" notification to the BeginMainFrame stage so that it
  // only fires if there was a frame painted without animations.
  // See go/report-ux-metrics-at-painting for details.
  virtual void OnFirstNonAnimatedFrameStarted(Compositor* compositor) {}

  virtual void OnFrameSinksToThrottleUpdated(
      const base::flat_set<viz::FrameSinkId>& ids) {}

  // Called at the end of the BeginMainFrame.
  virtual void OnDidBeginMainFrame(Compositor* compositor) {}

  // Called when the compositor visibility is about to change, but before it is
  // changed.
  virtual void OnCompositorVisibilityChanging(Compositor* compositor,
                                              bool visible) {}

  // Called when the compositor visibility has changed.
  virtual void OnCompositorVisibilityChanged(Compositor* compositor,
                                             bool visible) {}

  // Called when the compositor receives a new refresh rate preference.
  virtual void OnSetPreferredRefreshRate(Compositor* compositor,
                                         float refresh_rate) {}

  // Called when a CompositorFrame with a new SurfaceId activates for the first
  // time.
  virtual void OnFirstSurfaceActivation(Compositor* compositor,
                                        const viz::SurfaceInfo& surface_info) {}
};

}  // namespace ui

#endif  // UI_COMPOSITOR_COMPOSITOR_OBSERVER_H_