blob: 4cdc627c02062f52a72d2374d73f2d8e36e542c9 [file] [log] [blame]
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module viz.mojom;
[EnableIf=is_chromeos_ash]
import "ash/components/arc/mojom/protected_buffer_manager.mojom";
[EnableIf=is_chromeos_ash]
import "ash/components/arc/mojom/video_decode_accelerator.mojom";
[EnableIf=is_chromeos_ash]
import "ash/components/arc/mojom/video_decoder.mojom";
[EnableIf=is_chromeos_ash]
import "ash/components/arc/mojom/video_encode_accelerator.mojom";
[EnableIf=is_chromeos_ash]
import "ash/components/arc/mojom/video_protected_buffer_allocator.mojom";
[EnableIf=is_chromeos_ash]
import "components/chromeos_camera/common/mjpeg_decode_accelerator.mojom";
[EnableIf=is_chromeos_ash]
import "components/chromeos_camera/common/jpeg_encode_accelerator.mojom";
import "gpu/ipc/common/device_perf_info.mojom";
import "gpu/ipc/common/dx_diag_node.mojom";
import "gpu/ipc/common/gpu_disk_cache_type.mojom";
import "gpu/ipc/common/gpu_feature_info.mojom";
import "gpu/ipc/common/gpu_info.mojom";
import "gpu/ipc/common/gpu_peak_memory.mojom";
import "gpu/ipc/common/memory_stats.mojom";
import "gpu/ipc/common/client_gmb_interface.mojom";
import "gpu/ipc/common/surface_handle.mojom";
import "gpu/ipc/common/sync_token.mojom";
import "media/mojo/mojom/video_encode_accelerator.mojom";
import "mojo/public/mojom/base/byte_string.mojom";
import "mojo/public/mojom/base/process_id.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "ui/gfx/mojom/buffer_types.mojom";
import "ui/gl/mojom/gpu_preference.mojom";
import "mojo/public/mojom/base/memory_pressure_level.mojom";
import "mojo/public/mojom/base/shared_memory.mojom";
[EnableIf=is_win]
import "mojo/public/mojom/base/unguessable_token.mojom";
[EnableIf=is_win]
import "ui/gfx/mojom/dxgi_info.mojom";
interface GpuService {
// Tells the GPU service to create a new channel for communication with a
// client. The GPU service responds with an IPC handle. |gpu_info| and
// |gpu_feature_info| are returned so that if this method is called
// synchronously they are available (since the PostTask for
// GpuHost::DidInitialize might not be dispatched yet.
[Sync, NoInterrupt]
EstablishGpuChannel(int32 client_id,
uint64 client_tracing_id,
bool is_gpu_host)
=> (handle<message_pipe>? channel_handle,
gpu.mojom.GpuInfo gpu_info,
gpu.mojom.GpuFeatureInfo gpu_feature_info);
// Tells the GPU service the PID of whatever client process is controlling the
// GpuChannel established by a prior EstablishGpuChannel() call with the given
// `client_id`.
SetChannelClientPid(int32 client_id, mojo_base.mojom.ProcessId client_pid);
// Tells the GPU service an assigned cache handle. Note that for each type of
// handle per client only one unique handle is expected.
SetChannelDiskCacheHandle(int32 client_id,
gpu.mojom.GpuDiskCacheHandle cache_handle);
// Called by the browser when the last reference to a GPU disk cache handle
// is gone. Results in the GPU process purging the in memory copy.
OnDiskCacheHandleDestoyed(gpu.mojom.GpuDiskCacheHandle cache_handle);
// Tells the GPU process to close the channel identified by |client_id|.
// If no channel can be identified, do nothing.
CloseChannel(int32 client_id);
// Create a new ARC VideoDecodeAccelerator and binds it to |vda|.
[EnableIf=enable_arc_media]
CreateArcVideoDecodeAccelerator(
pending_receiver<arc.mojom.VideoDecodeAccelerator> vda);
// Create a new ARC VideoDecoder and binds it to |vd|.
[EnableIf=enable_arc_media]
CreateArcVideoDecoder(
pending_receiver<arc.mojom.VideoDecoder> vd);
// Create a new ARC VideoEncodeAccelerator and binds it to |vea|.
[EnableIf=enable_arc_media]
CreateArcVideoEncodeAccelerator(
pending_receiver<arc.mojom.VideoEncodeAccelerator> vea);
// Create a new ARC VideoProtectedBufferAllocator and binds it to |pba|.
[EnableIf=enable_arc_media ]
CreateArcVideoProtectedBufferAllocator(
pending_receiver<arc.mojom.VideoProtectedBufferAllocator> pba);
// Create a new ARC ProtectedBufferManager and binds it to |pbm|.
[EnableIf=enable_arc_media ]
CreateArcProtectedBufferManager(
pending_receiver<arc.mojom.ProtectedBufferManager> pbm);
// Creates a new MjpegDecodeAccelerator and binds it to |jda|.
[EnableIf=is_chromeos_ash]
CreateJpegDecodeAccelerator(
pending_receiver<chromeos_camera.mojom.MjpegDecodeAccelerator> jda);
// Creates a new JpegEncodeAccelerator and binds it to |jea|.
[EnableIf=is_chromeos_ash]
CreateJpegEncodeAccelerator(
pending_receiver<chromeos_camera.mojom.JpegEncodeAccelerator> jea);
// Registers a DCOMP surface handle and returns a token. The token will then
// be used by MediaFoundationRendererClient to call DCOMPTexture to set the
// surface in GLImageDCOMPSurface. Null token will be returned upon failure.
// Also see media/mojo/mojom/dcomp_surface_registry.mojom.
[EnableIf=is_win]
RegisterDCOMPSurfaceHandle(handle<platform> surface_handle)
=> (mojo_base.mojom.UnguessableToken? token);
// Unregisters the DCOMP surface handle associated with `token`. This is to
// avoid handle leak in case the handle is not taken during a playback, e.g.
// user closes tab immediately after playback start. No-op if the handle has
// already been taken. Also see media/mojo/mojom/dcomp_surface_registry.mojom.
[EnableIf=is_win]
UnregisterDCOMPSurfaceHandle(mojo_base.mojom.UnguessableToken token);
// Binds the pending receiver.
BindClientGmbInterface(
pending_receiver<gpu.mojom.ClientGmbInterface> receiver, int32 client_id);
// Creates a VideoEncodeAcceleratorProvider and binds it to |vea_provider|.
CreateVideoEncodeAcceleratorProvider(
pending_receiver<media.mojom.VideoEncodeAcceleratorProvider>
vea_provider);
[Sync, NoInterrupt]
CreateGpuMemoryBuffer(gfx.mojom.GpuMemoryBufferId id,
gfx.mojom.Size size,
gfx.mojom.BufferFormat format,
gfx.mojom.BufferUsage usage,
int32 client_id,
gpu.mojom.SurfaceHandle surface_handle)
=> (gfx.mojom.GpuMemoryBufferHandle buffer_handle);
DestroyGpuMemoryBuffer(gfx.mojom.GpuMemoryBufferId id,
int32 client_id);
// Copies GMB pixel data to |shared_memory|.
// Returns |true| if the copy has succeeded.
CopyGpuMemoryBuffer(gfx.mojom.GpuMemoryBufferHandle buffer_handle,
mojo_base.mojom.UnsafeSharedMemoryRegion shared_memory)
=> (bool success);
// Returns current video memory usage.
GetVideoMemoryUsageStats() => (gpu.mojom.VideoMemoryUsageStats stats);
// Starts tracking the peak GPU memory until GetPeakMemoryUsage is called.
// To be associated with |sequence_num|, repeated calls with the same value
// are ignored.
StartPeakMemoryMonitor(uint32 sequence_num);
// Ends tracking the peak GPU memory for the associated |sequence_num|.
// Returning the value of the peak seen since StartPeakMemoryMonitorProcess.
GetPeakMemoryUsage(uint32 sequence_num) => (uint64 memory_usage,
map<gpu.mojom.GpuPeakMemoryAllocationSource, uint64>
memory_per_allocation_source);
// Requests that the GPU process query DXGI adapter and output information
// and return it.
[EnableIf=is_win]
RequestDXGIInfo() => (gfx.mojom.DXGIInfo dxgi_info);
// Notify GPU that a cached blob was loaded from disk for the particular
// handle. The handle is used to map 1:1 to an actual file path on disk in the
// host since multiple clients may be using the same physical disk path. Note
// that this method is used only from a trusted process.
LoadedBlob(gpu.mojom.GpuDiskCacheHandle cache_handle,
string key,
mojo_base.mojom.ByteString data);
// Tells GPU to wake up the GPU because we're about to draw.
WakeUpGpu();
// Tells GPU that host has seen a GPU switch. This can happen when the display
// is reconfigured, for example.
GpuSwitched(gl.mojom.GpuPreference active_gpu_heuristic);
// Tells GPU that host has seen a monitor being plugged in.
DisplayAdded();
// Tells GPU that host has seen a monitor being unplugged.
DisplayRemoved();
// Tells GPU that host has seen the display metrics changed.
DisplayMetricsChanged();
// Tells GPU that all GPU channels are to be destroyed.
DestroyAllChannels();
// Called by the browser shortly after the application is backgrounded. The
// GPU can use this message to perform appropriate cleanup. Sent with a
// slight delay to prevent thrashing if the app is rapidly backgrounded
// foregrounded.
OnBackgroundCleanup();
// Called by the browser immediately after the application is backgrounded.
OnBackgrounded();
// Called by the browser immediately after the application is foregrounded.
OnForegrounded();
// Called by the browser when the system is under memory pressure.
[EnableIf=is_not_android]
OnMemoryPressure(mojo_base.mojom.MemoryPressureLevel level);
// Begin a batch of layer tree changes.
[EnableIf=is_apple]
BeginCATransaction();
// Commit a batch of layer tree changes atomically. Returns after the commit
// completes.
[EnableIf=is_apple]
CommitCATransaction() => ();
// Write out the accumulated code profiling profile to the configured file.
// The callback is invoked once the profile has been flushed to disk.
[EnableIf=use_clang_profiling_inside_sandbox]
WriteClangProfilingProfile() => ();
// Requests Dawn Info for about:gpu.
GetDawnInfo() => (array<string> dawn_info_list);
Crash();
Hang();
ThrowJavaException();
};