blob: 075bfdef4601d09c39229bdbaada60c70fd26bd6 [file] [log] [blame]
// Copyright 2015 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 device.mojom;
import "mojo/common/time.mojom";
import "gpu/ipc/common/mailbox_holder.mojom";
import "gpu/ipc/common/sync_token.mojom";
import "ui/gfx/geometry/mojo/geometry.mojom";
// A field of view, given by 4 degrees describing the view from a center point.
struct VRFieldOfView {
float upDegrees;
float downDegrees;
float leftDegrees;
float rightDegrees;
};
// A display's position, orientation, velocity, and acceleration state at the
// given timestamp.
struct VRPose {
array<float, 4>? orientation;
array<float, 3>? position;
array<float, 3>? angularVelocity;
array<float, 3>? linearVelocity;
array<float, 3>? angularAcceleration;
array<float, 3>? linearAcceleration;
};
struct VRDisplayCapabilities {
bool hasPosition;
bool hasExternalDisplay;
bool canPresent;
};
// Information about the optical properties for an eye in a VRDisplay.
struct VREyeParameters {
VRFieldOfView fieldOfView;
array<float, 3> offset;
uint32 renderWidth;
uint32 renderHeight;
};
struct VRStageParameters {
array<float, 16> standingTransform;
float sizeX;
float sizeZ;
};
struct VRDisplayInfo {
uint32 index;
string displayName;
VRDisplayCapabilities capabilities;
VRStageParameters? stageParameters;
VREyeParameters leftEye;
VREyeParameters rightEye;
};
enum VRDisplayEventReason {
NONE = 0,
NAVIGATION = 1,
MOUNTED = 2,
UNMOUNTED = 3
};
// TODO(shaobo.yan@intel.com) : Add comments to describe these interfaces about
// how to use and where they live.
interface VRService {
// TODO(shaobo.yan@intel.com, crbug/701027): Use a factory function which
// takes a VRServiceClient so we will never have a half-initialized VRService.
SetClient(VRServiceClient client) => (uint32 number_of_connected_devices);
// Inform the service that the page is listening for vrdisplayactivate events.
SetListeningForActivate(bool listening);
};
interface VRServiceClient {
OnDisplayConnected(VRDisplay display, VRDisplayClient& request,
VRDisplayInfo display_info);
};
interface VRSubmitFrameClient {
OnSubmitFrameTransferred();
OnSubmitFrameRendered();
};
// Represents a physical VR device that can be used to present WebVR content, or get orientation
// data (VRPose) when not presenting (aka magic window).
interface VRDisplay {
RequestPresent(bool secure_origin, VRSubmitFrameClient client,
VRPresentationProvider& request) => (bool success);
ExitPresent();
GetNextMagicWindowPose() => (VRPose? pose);
};
// Provides the necessary functionality for a presenting WebVR page to draw frames for a VrDisplay.
interface VRPresentationProvider {
enum VSyncStatus { SUCCESS, CLOSING };
// The frameId maps a VSync to a frame arriving from the compositor. IDs will
// be reused after the frame arrives from the compositor. Negative IDs imply
// no mapping.
GetVSync() => (VRPose? pose, mojo.common.mojom.TimeDelta time, int16 frame_id,
VSyncStatus status);
SubmitFrame(int16 frame_id, gpu.mojom.MailboxHolder mailbox_holder);
UpdateLayerBounds(int16 frame_id, gfx.mojom.RectF left_bounds,
gfx.mojom.RectF right_bounds, gfx.mojom.Size source_size);
};
interface VRDisplayClient {
OnChanged(VRDisplayInfo display);
OnExitPresent();
OnBlur();
OnFocus();
OnActivate(VRDisplayEventReason reason) => (bool will_not_present);
OnDeactivate(VRDisplayEventReason reason);
};