/*
 * Copyright 2015 Martell Malone
 *
 * 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
 */

import "dxgi1_2.idl";

cpp_quote("#define DXGI_CREATE_FACTORY_DEBUG   0x1")

typedef struct DXGI_DECODE_SWAP_CHAIN_DESC
{
    UINT Flags;
} DXGI_DECODE_SWAP_CHAIN_DESC;

typedef enum DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS
{
    DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAG_NOMINAL_RANGE = 0x1,
    DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAG_BT709         = 0x2,
    DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAG_xvYCC         = 0x4,
} DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS;

[
    object,
    local,
    uuid(2633066b-4514-4c7a-8fd8-12ea98059d18)
]
interface IDXGIDecodeSwapChain : IUnknown
{
    HRESULT PresentBuffer(
        UINT buffer,
        UINT sync,
        UINT flags
    );

    HRESULT SetSourceRect(
        const RECT* rect
    );

    HRESULT SetTargetRect(
        const RECT* rect
    );

    HRESULT SetDestSize(
        UINT width,
        UINT height
    );

    HRESULT GetSourceRect(
        [out] RECT* rect
    );

    HRESULT GetTargetRect(
        [out] RECT* rect
    );

    HRESULT GetDestSize(
        [out] UINT* width,
        [out] UINT* height
    );

    HRESULT SetColorSpace(
        DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS colorSpace
    );

    DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS GetColorSpace();
}

[
    object,
    local,
    uuid(41e7d1f2-a591-4f7b-a2e5-fa9c843e1c12)
]
interface IDXGIFactoryMedia :IUnknown
{
    HRESULT CreateSwapChainForCompositionSurfaceHandle(
        [in] IUnknown* device,
        [in] HANDLE surface,
        [in] const DXGI_SWAP_CHAIN_DESC1* desc,
        [in] IDXGIOutput* output,
        [out] IDXGISwapChain1** swapchain
    );

    HRESULT CreateDecodeSwapChainForCompositionSurfaceHandle(
        [in] IUnknown* device,
        [in] HANDLE surface,
        [in] DXGI_DECODE_SWAP_CHAIN_DESC* desc,
        [in] IDXGIResource* buffer,
        [in] IDXGIOutput* output,
        [out] IDXGIDecodeSwapChain** swapchain
    );
}

typedef enum DXGI_FRAME_PRESENTATION_MODE
{
    DXGI_FRAME_PRESENTATION_MODE_COMPOSED = 0,
    DXGI_FRAME_PRESENTATION_MODE_OVERLAY = 1,
    DXGI_FRAME_PRESENTATION_MODE_NONE = 2,
} DXGI_FRAME_PRESENTATION_MODE;

typedef struct DXGI_FRAME_STATISTICS_MEDIA
{
    UINT PresentCount;
    UINT PresentRefreshCount;
    UINT SyncRefreshCount;
    LARGE_INTEGER SyncQPCTime;
    LARGE_INTEGER SyncGPUTime;
    DXGI_FRAME_PRESENTATION_MODE CompositionMode;
    UINT ApprovedPresentDuration;
} DXGI_FRAME_STATISTICS_MEDIA;

[
    object,
    local,
    uuid(dd95b90b-f05f-4f6a-bd65-25bfb264bd84)
]
interface IDXGISwapChainMedia : IUnknown
{
    HRESULT GetFrameStatisticsMedia(
        [out] DXGI_FRAME_STATISTICS_MEDIA* pStats
    );

    HRESULT SetPresentDuration(
        UINT duration
    );

    HRESULT CheckPresentDurationSupport(
        UINT duration,
        [out] UINT* smallerduration,
        [out] UINT* largerduration
    );
};

typedef enum DXGI_OVERLAY_SUPPORT_FLAG
{
    DXGI_OVERLAY_SUPPORT_FLAG_DIRECT   = 0x1,
    DXGI_OVERLAY_SUPPORT_FLAG_SCALING  = 0x2
} DXGI_OVERLAY_SUPPORT_FLAG;

[
    object,
    local,
    uuid(6007896c-3244-4afd-bf18-a6d3beda5023)
]
interface IDXGIDevice3 : IDXGIDevice2
{
    void Trim();
}

[
    object,
    local,
    uuid(595e39d1-2724-4663-99b1-da969de28364)
]
interface IDXGIOutput2 : IDXGIOutput1
{
    BOOL SupportsOverlays();
}

[
    object,
    local,
    uuid(8a6bb301-7e7e-41F4-a8e0-5b32f7f99b18)
]
interface IDXGIOutput3 : IDXGIOutput2
{
    HRESULT CheckOverlaySupport(
        [in] DXGI_FORMAT format,
        [out, in] IUnknown* device,
        [out] UINT* flags
    );
}

[local] HRESULT __stdcall CreateDXGIFactory2(UINT Flags, REFIID riid, void **factory);

typedef struct DXGI_MATRIX_3X2_F
{
    float _11;
    float _12;
    float _21;
    float _22;
    float _31;
    float _32;
} DXGI_MATRIX_3X2_F;

[
    object,
    local,
    uuid(a8be2ac4-199f-4946-b331-79599fb98de7)
]
interface IDXGISwapChain2 : IDXGISwapChain1
{
    HRESULT SetSourceSize(
        UINT width,
        UINT height
    );

    HRESULT GetSourceSize(
        [out] UINT* width,
        [out] UINT* height
    );

    HRESULT SetMaximumFrameLatency(
        UINT max_latency
    );

    HRESULT GetMaximumFrameLatency(
        [out] UINT* max_latency
    );

    HANDLE  GetFrameLatencyWaitableObject();

    HRESULT SetMatrixTransform(
        const DXGI_MATRIX_3X2_F* matrix
    );

    HRESULT GetMatrixTransform(
        [out] DXGI_MATRIX_3X2_F* matrix
    );
}

[
    object,
    local,
    uuid(25483823-cd46-4c7d-86ca-47aa95b837bd)
]
interface IDXGIFactory3 : IDXGIFactory2
{
    UINT GetCreationFlags();
}
