/*
 * Copyright (C) 2023 Mohamad Al-Jaf
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#ifdef __WIDL__
#pragma winrt ns_prefix
#endif

import "inspectable.idl";
import "asyncinfo.idl";
import "eventtoken.idl";
import "windowscontracts.idl";
import "windows.foundation.idl";
import "windows.foundation.numerics.idl";
import "windows.graphics.directx.idl";
import "windows.graphics.directx.direct3d11.idl";
import "windows.perception.idl";
import "windows.perception.spatial.idl";
import "windows.ui.core.idl";

namespace Windows.Perception {
    runtimeclass PerceptionTimestamp;
}

namespace Windows.Graphics.Holographic {
    typedef enum HolographicFramePresentResult HolographicFramePresentResult;
    typedef enum HolographicFramePresentWaitBehavior HolographicFramePresentWaitBehavior;

    typedef struct HolographicAdapterId HolographicAdapterId;
    typedef struct HolographicStereoTransform HolographicStereoTransform;

    interface IHolographicCamera;
    interface IHolographicCameraPose;
    interface IHolographicCameraRenderingParameters;
    interface IHolographicFrame;
    interface IHolographicFramePrediction;
    interface IHolographicSpaceStatics;
    interface IHolographicSpaceStatics2;
    interface IHolographicSpaceStatics3;
    interface IHolographicSpaceCameraAddedEventArgs;
    interface IHolographicSpaceCameraRemovedEventArgs;

    runtimeclass HolographicCamera;
    runtimeclass HolographicCameraPose;
    runtimeclass HolographicCameraRenderingParameters;
    runtimeclass HolographicFrame;
    runtimeclass HolographicFramePrediction;
    runtimeclass HolographicSpace;
    runtimeclass HolographicSpaceCameraAddedEventArgs;
    runtimeclass HolographicSpaceCameraRemovedEventArgs;

    declare {
        interface Windows.Foundation.Collections.IVectorView<Windows.Graphics.Holographic.HolographicCamera *>;
        interface Windows.Foundation.Collections.IVectorView<Windows.Graphics.Holographic.HolographicCameraPose *>;
        interface Windows.Foundation.IReference<Windows.Graphics.Holographic.HolographicStereoTransform>;
        interface Windows.Foundation.TypedEventHandler<Windows.Graphics.Holographic.HolographicSpace *, IInspectable *>;
        interface Windows.Foundation.TypedEventHandler<Windows.Graphics.Holographic.HolographicSpace *, Windows.Graphics.Holographic.HolographicSpaceCameraAddedEventArgs *>;
        interface Windows.Foundation.TypedEventHandler<Windows.Graphics.Holographic.HolographicSpace *, Windows.Graphics.Holographic.HolographicSpaceCameraRemovedEventArgs *>;
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0)
    ]
    enum HolographicFramePresentResult
    {
        Success       = 0,
        DeviceRemoved = 1,
    };

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0)
    ]
    enum HolographicFramePresentWaitBehavior
    {
        WaitForFrameToFinish      = 0,
        DoNotWaitForFrameToFinish = 1,
    };

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0)
    ]
    struct HolographicAdapterId
    {
        UINT32 LowPart;
        INT32 HighPart;
    };

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0)
    ]
    struct HolographicStereoTransform
    {
        Windows.Foundation.Numerics.Matrix4x4 Left;
        Windows.Foundation.Numerics.Matrix4x4 Right;
    };

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0),
        exclusiveto(Windows.Graphics.Holographic.HolographicCamera),
        uuid(e4e98445-9bed-4980-9ba0-e87680d1cb74)
    ]
    interface IHolographicCamera : IInspectable
    {
        [propget] HRESULT RenderTargetSize([out, retval] Windows.Foundation.Size *value);
        [propget] HRESULT ViewportScaleFactor([out, retval] DOUBLE *value);
        [propput] HRESULT ViewportScaleFactor([in] DOUBLE value);
        [propget] HRESULT IsStereo([out, retval] boolean *value);
        [propget] HRESULT Id([out, retval] UINT32 *value);
        HRESULT SetNearPlaneDistance([in] DOUBLE value);
        HRESULT SetFarPlaneDistance([in] DOUBLE value);
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0),
        exclusiveto(Windows.Graphics.Holographic.HolographicCameraPose),
        uuid(0d7d7e30-12de-45bd-912b-c7f6561599d1)
    ]
    interface IHolographicCameraPose : IInspectable
    {
        [propget] HRESULT HolographicCamera([out, retval] Windows.Graphics.Holographic.HolographicCamera **value);
        [propget] HRESULT Viewport([out, retval] Windows.Foundation.Rect *value);
        HRESULT TryGetViewTransform([in] Windows.Perception.Spatial.SpatialCoordinateSystem *coordinate_system, [out, retval] Windows.Foundation.IReference<Windows.Graphics.Holographic.HolographicStereoTransform> **value);
        [propget] HRESULT ProjectionTransform([out, retval] Windows.Graphics.Holographic.HolographicStereoTransform *value);
        HRESULT TryGetCullingFrustum([in] Windows.Perception.Spatial.SpatialCoordinateSystem *coordinate_system, [out, retval] Windows.Foundation.IReference<Windows.Perception.Spatial.SpatialBoundingFrustum> **value);
        HRESULT TryGetVisibleFrustum([in] Windows.Perception.Spatial.SpatialCoordinateSystem* coordinateSystem, [out, retval] Windows.Foundation.IReference<Windows.Perception.Spatial.SpatialBoundingFrustum> **value);
        [propget] HRESULT NearPlaneDistance([out, retval] DOUBLE *value);
        [propget] HRESULT FarPlaneDistance([out, retval] DOUBLE *value);
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0),
        exclusiveto(Windows.Graphics.Holographic.HolographicCameraRenderingParameters),
        uuid(8eac2ed1-5bf4-4e16-8236-ae0800c11d0d)
    ]
    interface IHolographicCameraRenderingParameters : IInspectable
    {
        [overload("SetFocusPoint")] HRESULT SetFocusPoint([in] Windows.Perception.Spatial.SpatialCoordinateSystem *coordinate_system, [in] Windows.Foundation.Numerics.Vector3 position);
        [overload("SetFocusPoint")] HRESULT SetFocusPointWithNormal([in] Windows.Perception.Spatial.SpatialCoordinateSystem *coordinate_system, [in] Windows.Foundation.Numerics.Vector3 position, [in] Windows.Foundation.Numerics.Vector3 normal);
        [overload("SetFocusPoint")] HRESULT SetFocusPointWithNormalLinearVelocity([in] Windows.Perception.Spatial.SpatialCoordinateSystem *coordinate_system, [in] Windows.Foundation.Numerics.Vector3 position, [in] Windows.Foundation.Numerics.Vector3 normal, [in] Windows.Foundation.Numerics.Vector3 linearVelocity);
        [propget] HRESULT Direct3D11Device([out, retval] Windows.Graphics.DirectX.Direct3D11.IDirect3DDevice **value);
        [propget] HRESULT Direct3D11BackBuffer([out, retval] Windows.Graphics.DirectX.Direct3D11.IDirect3DSurface **value);
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0),
        exclusiveto(Windows.Graphics.Holographic.HolographicFrame),
        uuid(c6988eb6-a8b9-3054-a6eb-d624b6536375)
    ]
    interface IHolographicFrame : IInspectable
    {
        [propget] HRESULT AddedCameras([out, retval] Windows.Foundation.Collections.IVectorView<Windows.Graphics.Holographic.HolographicCamera *> **value);
        [propget] HRESULT RemovedCameras([out, retval] Windows.Foundation.Collections.IVectorView<Windows.Graphics.Holographic.HolographicCamera *> **value);
        HRESULT GetRenderingParameters([in] Windows.Graphics.Holographic.HolographicCameraPose *camera_pose, [out, retval] Windows.Graphics.Holographic.HolographicCameraRenderingParameters **value);
        [propget] HRESULT Duration([out, retval] Windows.Foundation.TimeSpan *value);
        [propget] HRESULT CurrentPrediction([out, retval] Windows.Graphics.Holographic.HolographicFramePrediction **value);
        HRESULT UpdateCurrentPrediction();
        [overload("PresentUsingCurrentPrediction")] HRESULT PresentUsingCurrentPrediction([out, retval] Windows.Graphics.Holographic.HolographicFramePresentResult *result);
        [overload("PresentUsingCurrentPrediction")] HRESULT PresentUsingCurrentPredictionWithBehavior([in] Windows.Graphics.Holographic.HolographicFramePresentWaitBehavior wait_behavior, [out, retval] Windows.Graphics.Holographic.HolographicFramePresentResult *result);
        HRESULT WaitForFrameToFinish();
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0),
        exclusiveto(Windows.Graphics.Holographic.HolographicFramePrediction),
        uuid(520f4de1-5c0a-4e79-a81e-6abe02bb2739)
    ]
    interface IHolographicFramePrediction : IInspectable
    {
        [propget] HRESULT CameraPoses([out, retval] Windows.Foundation.Collections.IVectorView<Windows.Graphics.Holographic.HolographicCameraPose *> **value);
        [propget] HRESULT Timestamp([out, retval] Windows.Perception.PerceptionTimestamp **value);
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0),
        exclusiveto(Windows.Graphics.Holographic.HolographicSpace),
        uuid(4380dba6-5e78-434f-807c-3433d1efe8b7)
    ]
    interface IHolographicSpace : IInspectable
    {
        [propget] HRESULT PrimaryAdapterId([out, retval] Windows.Graphics.Holographic.HolographicAdapterId *value);
        HRESULT SetDirect3D11Device([in] Windows.Graphics.DirectX.Direct3D11.IDirect3DDevice *value);
        [eventadd] HRESULT CameraAdded(
            [in] Windows.Foundation.TypedEventHandler<Windows.Graphics.Holographic.HolographicSpace *, Windows.Graphics.Holographic.HolographicSpaceCameraAddedEventArgs *> *handler,
            [out, retval] EventRegistrationToken *cookie
        );
        [eventremove] HRESULT CameraAdded([in] EventRegistrationToken cookie);
        [eventadd] HRESULT CameraRemoved(
            [in] Windows.Foundation.TypedEventHandler<Windows.Graphics.Holographic.HolographicSpace *, Windows.Graphics.Holographic.HolographicSpaceCameraRemovedEventArgs *> *handler,
            [out, retval] EventRegistrationToken *cookie
        );
        [eventremove] HRESULT CameraRemoved([in] EventRegistrationToken cookie);
        HRESULT CreateNextFrame([out, retval] Windows.Graphics.Holographic.HolographicFrame **value);
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 4.0),
        exclusiveto(Windows.Graphics.Holographic.HolographicSpace),
        uuid(0e777088-75fc-48af-8758-0652f6f07c59)
    ]
    interface IHolographicSpaceStatics2 : IInspectable
    {
        [propget] HRESULT IsSupported([out, retval] boolean *value);
        [propget] HRESULT IsAvailable([out, retval] boolean *value);
        [eventadd] HRESULT IsAvailableChanged([in] Windows.Foundation.EventHandler<IInspectable *> *handler, [out, retval] EventRegistrationToken *token);
        [eventremove] HRESULT IsAvailableChanged([in] EventRegistrationToken token);
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 5.0),
        exclusiveto(Windows.Graphics.Holographic.HolographicSpace),
        uuid(3b00de3d-b1a3-4dfe-8e79-fec5909e6df8)
    ]
    interface IHolographicSpaceStatics3 : IInspectable
    {
        [propget] HRESULT IsConfigured([out, retval] boolean *value);
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0),
        exclusiveto(Windows.Graphics.Holographic.HolographicSpaceCameraAddedEventArgs),
        uuid(58f1da35-bbb3-3c8f-993d-6c80e7feb99f)
    ]
    interface IHolographicSpaceCameraAddedEventArgs : IInspectable
    {
        [propget] HRESULT Camera([out, retval] Windows.Graphics.Holographic.HolographicCamera **value);
        HRESULT GetDeferral([out, retval] Windows.Foundation.Deferral **value);
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0),
        exclusiveto(Windows.Graphics.Holographic.HolographicSpaceCameraRemovedEventArgs),
        uuid(805444a8-f2ae-322e-8da9-836a0a95a4c1)
    ]
    interface IHolographicSpaceCameraRemovedEventArgs : IInspectable
    {
        [propget] HRESULT Camera([out, retval] Windows.Graphics.Holographic.HolographicCamera **value);
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0),
        marshaling_behavior(agile),
        threading(both)
    ]
    runtimeclass HolographicCamera
    {
        [default] interface Windows.Graphics.Holographic.IHolographicCamera;
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0),
        marshaling_behavior(agile),
        threading(both)
    ]
    runtimeclass HolographicCameraPose
    {
        [default] interface Windows.Graphics.Holographic.IHolographicCameraPose;
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0),
        marshaling_behavior(agile),
        threading(both)
    ]
    runtimeclass HolographicCameraRenderingParameters
    {
        [default] interface Windows.Graphics.Holographic.IHolographicCameraRenderingParameters;
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0),
        marshaling_behavior(agile),
        threading(both)
    ]
    runtimeclass HolographicFrame
    {
        [default] interface Windows.Graphics.Holographic.IHolographicFrame;
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0),
        marshaling_behavior(agile),
        threading(both)
    ]
    runtimeclass HolographicFramePrediction
    {
        [default] interface Windows.Graphics.Holographic.IHolographicFramePrediction;
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0),
        marshaling_behavior(agile),
        /* static(Windows.Graphics.Holographic.IHolographicSpaceStatics, Windows.Foundation.UniversalApiContract, 2.0), */
        static(Windows.Graphics.Holographic.IHolographicSpaceStatics2, Windows.Foundation.UniversalApiContract, 4.0),
        static(Windows.Graphics.Holographic.IHolographicSpaceStatics3, Windows.Foundation.UniversalApiContract, 5.0),
        threading(both)
    ]
    runtimeclass HolographicSpace
    {
        [default] interface Windows.Graphics.Holographic.IHolographicSpace;
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0),
        marshaling_behavior(agile),
        threading(both)
    ]
    runtimeclass HolographicSpaceCameraAddedEventArgs
    {
        [default] interface Windows.Graphics.Holographic.IHolographicSpaceCameraAddedEventArgs;
    }

    [
        contract(Windows.Foundation.UniversalApiContract, 2.0),
        marshaling_behavior(agile),
        threading(both)
    ]
    runtimeclass HolographicSpaceCameraRemovedEventArgs
    {
        [default] interface Windows.Graphics.Holographic.IHolographicSpaceCameraRemovedEventArgs;
    }
}
