blob: aa01db13d72803a4ca693aa08d16614f73c423ea [file] [log] [blame]
// 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/shared_memory.mojom";
import "mojo/public/mojom/base/time.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";
import "ui/gfx/geometry/mojo/geometry.mojom";
import "ui/gfx/mojo/presentation_feedback.mojom";
[Native]
struct SyncCompositorDemandDrawHwParams;
[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(mojo_base.mojom.WritableSharedMemoryRegion shm_region) =>
(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.
// |presentations| is a map from frame token to PresentationFeedback.
// Frame token is an incrementing id generated by untrusted viz client
// (renderer) and sent to viz service (browser) in a frame (see
// CompositorFrameMetadata). PresentationFeedback contains info of viz server
// displaying frames, such as time of display. Note that the viz server might
// choose to skip display some of the previously submitted frames; however,
// feedback about all previously submitted frames will be sent back once a
// new frame is displayed.
BeginFrame(viz.mojom.BeginFrameArgs args,
map<uint32, gfx.mojom.PresentationFeedback> presentations);
// 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);
};