| // Copyright 2017 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| module content.mojom; |
| |
| import "mojo/public/mojom/base/time.mojom"; |
| import "ui/gfx/geometry/mojo/geometry.mojom"; |
| import "services/viz/public/interfaces/compositing/begin_frame_args.mojom"; |
| import "services/viz/public/interfaces/compositing/compositor_frame.mojom"; |
| import "services/viz/public/interfaces/compositing/compositor_frame_metadata.mojom"; |
| import "services/viz/public/interfaces/compositing/returned_resource.mojom"; |
| |
| [Native] |
| struct SyncCompositorDemandDrawHwParams; |
| |
| [Native] |
| struct SyncCompositorSetSharedMemoryParams; |
| |
| [Native] |
| struct SyncCompositorDemandDrawSwParams; |
| |
| [Native] |
| struct SyncCompositorCommonRendererParams; |
| |
| // The SynchronousCompositor is an interface that is used by Android Webview |
| // which must control the compositor synchronously. It does this so that |
| // java UI is drawn in lock step with content renderer by the webview. |
| // The SynchronousCompositor is an associated interface with WidgetInputHandler |
| // because input must be delivered in order with the compositing events. |
| interface SynchronousCompositor { |
| // Computes the scroll at given time. |
| ComputeScroll(mojo_base.mojom.TimeTicks time); |
| |
| // Hardware draw asynchronously, ReturnFrame will return the result on |
| // the associated SynchronousCompositorControlHost. |
| DemandDrawHwAsync(SyncCompositorDemandDrawHwParams draw_params); |
| |
| // Synchronously hardware draws. |
| [Sync] |
| DemandDrawHw(SyncCompositorDemandDrawHwParams draw_params) => |
| (SyncCompositorCommonRendererParams result, |
| uint32 layer_tree_frame_sink_id, |
| uint32 metadata_version, |
| viz.mojom.CompositorFrame? frame); |
| |
| // Synchronously sets the shared memory used for resourceless software |
| // drawing. This mode just has the renderer send over a single bitmap of the |
| // final frame, rather than sending over individual tiles (ie. resources) |
| // that are then composited by the browser. |
| [Sync] SetSharedMemory(SyncCompositorSetSharedMemoryParams params) => |
| (bool success, SyncCompositorCommonRendererParams result); |
| |
| // Synchronously does a software based draw. |
| [Sync] DemandDrawSw(SyncCompositorDemandDrawSwParams draw_params) => |
| (SyncCompositorCommonRendererParams result, |
| uint32 metadata_version, |
| viz.mojom.CompositorFrameMetadata? meta_data); |
| |
| // Instead of drawing, allow the compositor to finish the frame and update |
| // tiles if needed. |
| WillSkipDraw(); |
| |
| // Zero out the shared memory. This is necessary since most of the time, |
| // viewport size doesn't change between draws, it's cheaper to zero out |
| // and reuse the shared memory, instead of allocating and mapping a new |
| // one each frame. |
| ZeroSharedMemory(); |
| |
| // Synchronously zoom by adjusting the page scale factor by delta around |
| // the anchor point. |
| [Sync] ZoomBy(float delta, gfx.mojom.Point anchor) => |
| (SyncCompositorCommonRendererParams result); |
| |
| // Adjust the memory policy of the compositor. Explicitly how much the |
| // compositor can use without changing visibility. ie. The limit on |
| // amount of memory used for caching tiles. |
| SetMemoryPolicy(uint32 bytes_limit); |
| |
| // Attempt to reclaim resources. |
| ReclaimResources(uint32 layer_tree_frame_sink_id, |
| array<viz.mojom.ReturnedResource> resources); |
| |
| // Adjust the scroll to the given offset. |
| SetScroll(gfx.mojom.ScrollOffset offset); |
| |
| // BeginFrame, update will be pushed via SynchronousCompositorControlHost |
| // BeginFrameResponse. |
| BeginFrame(viz.mojom.BeginFrameArgs args); |
| |
| // Indicates BeginFrame messages are paused. |
| SetBeginFrameSourcePaused(bool paused); |
| }; |
| |
| // Interface that runs on the UI thread of the browser. To be used |
| // for responses to most messages. |
| interface SynchronousCompositorHost { |
| // Indicates the layer tree was created. |
| LayerTreeFrameSinkCreated(); |
| |
| // Notification of new compositor information. |
| UpdateState(SyncCompositorCommonRendererParams params); |
| |
| // Notifies the that a begin frame is needed or not. |
| SetNeedsBeginFrames(bool needs_begin_frames); |
| }; |
| |
| // Interface that runs on the IO thread of the browser. To be used for responses |
| // to messages that need to wait for the response to be available before |
| // execution continues. Typically the browser UI thread will dispatch some |
| // messages asynchronously via the SynchronousCompositor interface but then |
| // reach a point at which a response must be available. For example the |
| // BeginFrame is sent to all attached WebViews but before the Android VSync |
| // execution flow (from java) returns the responses from BeginFrames must be |
| // received. |
| interface SynchronousCompositorControlHost { |
| // Response from DrawHwAsync. |
| ReturnFrame(uint32 layer_tree_frame_sink_id, |
| uint32 metadata_version, |
| viz.mojom.CompositorFrame? frame); |
| |
| // Response from BeginFrame. |
| BeginFrameResponse(SyncCompositorCommonRendererParams params); |
| }; |