frame_sink_manager.mojom 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. // Copyright 2016 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. module viz.mojom;
  5. import "gpu/ipc/common/surface_handle.mojom";
  6. import "mojo/public/mojom/base/time.mojom";
  7. import "services/viz/privileged/mojom/compositing/display_private.mojom";
  8. import "services/viz/privileged/mojom/compositing/external_begin_frame_controller.mojom";
  9. import "services/viz/privileged/mojom/compositing/frame_sink_video_capture.mojom";
  10. import "services/viz/privileged/mojom/compositing/renderer_settings.mojom";
  11. import "services/viz/public/mojom/compositing/compositor_frame_sink.mojom";
  12. import "services/viz/public/mojom/compositing/copy_output_request.mojom";
  13. import "services/viz/public/mojom/compositing/frame_sink_bundle.mojom";
  14. import "services/viz/public/mojom/compositing/frame_sink_bundle_id.mojom";
  15. import "services/viz/public/mojom/compositing/frame_sink_id.mojom";
  16. import "services/viz/public/mojom/compositing/local_surface_id.mojom";
  17. import "services/viz/public/mojom/compositing/surface_id.mojom";
  18. import "services/viz/public/mojom/compositing/surface_info.mojom";
  19. import "services/viz/public/mojom/hit_test/aggregated_hit_test_region.mojom";
  20. import "ui/gfx/geometry/mojom/geometry.mojom";
  21. import "services/viz/public/mojom/compositing/video_detector_observer.mojom";
  22. // Initialization parameters for a RootCompositorFrameSink.
  23. struct RootCompositorFrameSinkParams {
  24. FrameSinkId frame_sink_id;
  25. gpu.mojom.SurfaceHandle widget;
  26. bool gpu_compositing = true;
  27. RendererSettings renderer_settings;
  28. bool send_swap_size_notifications = false;
  29. // Disables begin frame rate limiting for the display compositor.
  30. bool disable_frame_rate_limit = false;
  31. [EnableIf=is_android]
  32. float refresh_rate;
  33. [EnableIf=is_win]
  34. bool set_present_duration_allowed = false;
  35. pending_associated_receiver<CompositorFrameSink> compositor_frame_sink;
  36. pending_remote<CompositorFrameSinkClient> compositor_frame_sink_client;
  37. pending_associated_receiver<DisplayPrivate> display_private;
  38. pending_remote<DisplayClient> display_client;
  39. pending_associated_receiver<ExternalBeginFrameController>?
  40. external_begin_frame_controller;
  41. };
  42. // The FrameSinkManager interface is a privileged interface that allows the
  43. // frame sink manager host (browser or window server) to create
  44. // CompositorFrameSinks. Clients acquire a CompositorFrameSink connection
  45. // through the frame sink manager host. Clients request a CompositorFrameSink
  46. // interface, and implement a CompositorFrameSinkClient interface. The frame
  47. // sink manager host holds one or more display CompositorFrameSinks that are
  48. // tied to a valid |surface_handle| and Display. All other
  49. // CompositorFrameSinks must be parented by another CompositorFrameSink.
  50. // FrameSinkIds are fixed for a given client and are determined ahead of time.
  51. // Thus, a client will typically simply request a CompositorFrameSink from the
  52. // frame sink manager host which will forward the request to the frame sink
  53. // manager.
  54. interface FrameSinkManager {
  55. // Starts the scope of temporary references tied to this |frame_sink_id|.
  56. // Temporary references tied to this |frame_sink_id| will be dropped on
  57. // InvalidateFrameSinkId.This must be called before Create(Root)
  58. // CompositorFrameSink() is called. |report_activation| indicates whether
  59. // the Viz host is interested in FirstSurfaceActivation notifications of
  60. // surfaces from this |frame_sink_id|.
  61. RegisterFrameSinkId(FrameSinkId frame_sink_id, bool report_activation);
  62. // Invalidates |frame_sink_id| which cleans up any unsatisified surface
  63. // sequences or dangling temporary references assigned to it. If there is a
  64. // CompositorFrameSink for |frame_sink_id| then it will be destroyed and the
  65. // message pipe to the client will be closed.
  66. InvalidateFrameSinkId(FrameSinkId frame_sink_id);
  67. // |debug_label| is used when printing out the surface hierarchy so we know
  68. // which clients are contributing which surfaces.
  69. SetFrameSinkDebugLabel(FrameSinkId frame_sink_id, string debug_label);
  70. // Create a CompositorFrameSink for a privileged client (e.g. WindowServer).
  71. // This is only used by privileged clients. The client can call methods that
  72. // talks to the Display (e.g. ResizeDisplay(), SetDisplayVisible(), etc).
  73. // If |force_software_compositing| is true, then the resulting display
  74. // compositor will not use Gpu acceleration even if it would by default.
  75. // If |external_begin_frames_controller| and
  76. // |external_begin_frames_controller_client| are set, the resulting display
  77. // will be driven by a BeginFrameSource controlled by the client via the
  78. // ExternalBeginFrameController.
  79. CreateRootCompositorFrameSink(RootCompositorFrameSinkParams params);
  80. // Used by unprivileged clients to create a new FrameSinkBundle in the
  81. // service. Each bundle can be used to communicate aggregate notifications and
  82. // requests to and from any frame sinks belonging to the same client.
  83. CreateFrameSinkBundle(FrameSinkBundleId bundle_id,
  84. pending_receiver<FrameSinkBundle> receiver,
  85. pending_remote<FrameSinkBundleClient> client);
  86. // CreateCompositorFrameSink is used by unprivileged clients. This
  87. // CompositorFrameSink is not a root, and has to be parented by another
  88. // CompositorFrameSink in order to appear on screen.
  89. //
  90. // If `bundle_id` is provided, the new frame sink is added to the identified
  91. // bundle. This means its client will receive OnBeginFrame() and various
  92. // other notifications exclusively through the corresponding FrameSinkBundle,
  93. // in batch with notifications for other bundled frame sinks; it also means
  94. // the client can submit frames for this sink in batch with other bundled
  95. // sinks using the FrameSinkBundle interface.
  96. CreateCompositorFrameSink(
  97. FrameSinkId frame_sink_id,
  98. FrameSinkBundleId? bundle_id,
  99. pending_receiver<CompositorFrameSink> compositor_frame_sink,
  100. pending_remote<CompositorFrameSinkClient> compositor_frame_sink_client);
  101. // Destroys CompositorFrameSink created by Create[Root]CompositorFrameSink().
  102. // This function should only be used synchronously for destroying root
  103. // CompositorFrameSinks to ensure the GL context/surface is destroyed before
  104. // the platform window.
  105. [Sync, NoInterrupt]
  106. DestroyCompositorFrameSink(FrameSinkId frame_sink_id) => ();
  107. // Set up a BeginFrame relationship between two FrameSinkIds. In this case,
  108. // the child inherits the viz::BeginFrameSource from the parent if it doesn't
  109. // already have a viz::BeginFrameSource.
  110. RegisterFrameSinkHierarchy(FrameSinkId parent_frame_sink_id,
  111. FrameSinkId child_frame_sink_id);
  112. // Removes a BeginFrame relationship between two FrameSinkIds.
  113. UnregisterFrameSinkHierarchy(FrameSinkId parent_frame_sink_id,
  114. FrameSinkId child_frame_sink_id);
  115. // Requests viz to notify |observer| whenever video activity is detected in
  116. // one of the clients. See viz::VideoDetector.
  117. AddVideoDetectorObserver(pending_remote<VideoDetectorObserver> observer);
  118. // Creates a FrameSinkVideoCapturer instance.
  119. CreateVideoCapturer(pending_receiver<FrameSinkVideoCapturer> receiver);
  120. // Marks the given SurfaceIds for destruction.
  121. EvictSurfaces(array<SurfaceId> surface_ids);
  122. // Throttles the frame sinks specified by |frame_sink_ids| and all their
  123. // descendant sinks to send BeginFrames at an interval of |interval|. This
  124. // operation clears out any previous throttling operation on any frame sinks.
  125. Throttle(array<FrameSinkId> frame_sink_ids,
  126. mojo_base.mojom.TimeDelta interval);
  127. // Throttles all current and future frame sinks to send BeginFrames at an
  128. // interval at least as long as |interval|. Because there is a single viz
  129. // process, which itself contains a single host frame sink manager, calling
  130. // this multiple times from anywhere will apply the throttling described by
  131. // the latest call.
  132. StartThrottlingAllFrameSinks(mojo_base.mojom.TimeDelta interval);
  133. // Disables the global throttling triggered by StartThrottlingAllFrameSinks().
  134. // If throttling is already disabled, this has no effect.
  135. StopThrottlingAllFrameSinks();
  136. // Takes a snapshot of |surface_id| or a newer surface with the same
  137. // FrameSinkId. The request will be queued up until such surface exists and is
  138. // reachable from the root surface.
  139. RequestCopyOfOutput(SurfaceId surface_id, CopyOutputRequest request);
  140. // Caches the back buffer for the |root_frame_sink_id|. The back buffer is
  141. // keyed using |cache_id| and evicted when EvictBackBuffer with the same id is
  142. // called.
  143. CacheBackBuffer(uint32 cache_id, FrameSinkId root_frame_sink_id);
  144. [Sync]
  145. EvictBackBuffer(uint32 cache_id) => ();
  146. // This allows dynamic manipulation of the viz debug options stored in
  147. // |debug_settings| (show_overdraw_feedback, etc.).
  148. UpdateDebugRendererSettings(DebugRendererSettings debug_settings);
  149. };
  150. // The FrameSinkManagerClient interface is implemented by the Display
  151. // Compositor Host, a stable, and privileged peer service to the display
  152. // compositor. The frame sink manager host is either the browser process in
  153. // Chrome or the window server process.
  154. interface FrameSinkManagerClient {
  155. // Called by the frame sink manager when a CompositorFrame with a new
  156. // SurfaceId activates for the first time.
  157. OnFirstSurfaceActivation(SurfaceInfo surface_info);
  158. // Sends new |hit_test_data| to the client.
  159. OnAggregatedHitTestRegionListUpdated(
  160. FrameSinkId frame_sink_id, array<AggregatedHitTestRegion> hit_test_data);
  161. // Sends |frame_sink_id|, |frame_token|, and |activation_time| to the client
  162. // when a surface of the provided |frame_sink_id| activates.
  163. OnFrameTokenChanged(FrameSinkId frame_sink_id, uint32 frame_token,
  164. mojo_base.mojom.TimeTicks activation_time);
  165. };