From 6bcf419d2e8f739b432d4790d1ba9d48ab65365b Mon Sep 17 00:00:00 2001 From: fcolin Date: Fri, 18 Nov 2011 12:14:12 +0000 Subject: --- ARMFCaptureD3D/device.h | 93 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 ARMFCaptureD3D/device.h (limited to 'ARMFCaptureD3D/device.h') diff --git a/ARMFCaptureD3D/device.h b/ARMFCaptureD3D/device.h new file mode 100644 index 0000000..3be3c16 --- /dev/null +++ b/ARMFCaptureD3D/device.h @@ -0,0 +1,93 @@ +////////////////////////////////////////////////////////////////////////// +// +// device.h: Manages the Direct3D device +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +////////////////////////////////////////////////////////////////////////// + + +#pragma once + +// Function pointer for the function that transforms the image. + +typedef void (*IMAGE_TRANSFORM_FN)( + BYTE* pDest, + LONG lDestStride, + const BYTE* pSrc, + LONG lSrcStride, + DWORD dwWidthInPixels, + DWORD dwHeightInPixels + ); + + +// DrawDevice class + +class DrawDevice +{ +private: + + HWND m_hwnd; +#ifdef DX9 + IDirect3D9 *m_pD3D; + IDirect3DDevice9 *m_pDevice; + IDirect3DSwapChain9 *m_pSwapChain; + IDirect3DVertexBuffer9 *m_pVertexBuffer; + IDirect3DIndexBuffer9 *m_pIndexBuffer; + + D3DPRESENT_PARAMETERS m_d3dpp; + + // Format information + D3DFORMAT m_format; +#else + //IDirect3D9 *m_pD3D; + ID3D11Device *m_pDevice; + ID3D11DeviceContext *m_pDeviceContext; + IDXGISwapChain *m_pSwapChain; + + DXGI_SWAP_CHAIN_DESC m_d3dpp; + + // Format information + DXGI_FORMAT m_format; +#endif + UINT m_width; + UINT m_height; + LONG m_lDefaultStride; + MFRatio m_PixelAR; + MFVideoInterlaceMode m_interlace; + RECT m_rcDest; // Destination rectangle + + // Drawing + IMAGE_TRANSFORM_FN m_convertFn; // Function to convert the video to RGB32 + +private: + + HRESULT TestCooperativeLevel(); + HRESULT SetConversionFunction(REFGUID subtype); + HRESULT CreateSwapChains(); + void UpdateDestinationRect(); + +public: + + DrawDevice(); + virtual ~DrawDevice(); + + HRESULT CreateDevice(HWND hwnd); + HRESULT ResetDevice(); + void DestroyDevice(); + + HRESULT SetVideoType(IMFMediaType *pType); + HRESULT DrawFrame(IMFMediaBuffer *pBuffer); + + HRESULT RenderObjects(); + + // What video formats we accept + BOOL IsFormatSupported(REFGUID subtype) const; + HRESULT GetFormat(DWORD index, GUID *pSubtype) const; + void GetSize(UINT* width, UINT *height) const; +}; -- cgit v1.1