// Copyright 2016 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.

enum VREye {
    "left",
    "right"
};

// http://mozvr.github.io/webvr-spec/webvr.html#vrdisplay
[
    RuntimeEnabled=WebVR
] interface VRDisplay {
    // An identifier for this device unique across VRDisplays.
    readonly attribute unsigned long displayId;

    // A user-readable name identifying the device.
    readonly attribute DOMString displayName;

    readonly attribute boolean isConnected;
    readonly attribute boolean isPresenting;

    // [Constant]?
    readonly attribute VRDisplayCapabilities capabilities;

    readonly attribute VRStageParameters stageParameters;

    VRPose getPose();
    VRPose getImmediatePose();
    void resetPose();

    VREyeParameters getEyeParameters(VREye whichEye);

    long requestAnimationFrame(FrameRequestCallback callback);
    void cancelAnimationFrame(long handle);

    // Begin presenting to the VRDisplay. Must be called in response to a user gesture.
    // Repeat calls while already presenting will update the VRLayer being displayed.
    [CallWith=ScriptState] Promise requestPresent(sequence<VRLayer> layers);

    // Stops presenting to the VRDisplay.
    [CallWith=ScriptState] Promise exitPresent();

    // Get the sources currently being presented.
    sequence<VRLayer> getLayers();

    // The VRLayer provided to the `VRDisplay` will be captured and presented
    // in the HMD. Calling this function has the same effect on the source
    // canvas as any other operation that uses its source image, and canvases
    // created without preserveDrawingBuffer set to true will be cleared.
    void submitFrame(optional VRPose pose = null);
};
