From 51e92d4e5d3fbef202ded73307dd76c85aa99254 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Mon, 18 Apr 2016 14:45:56 -0700 Subject: [PATCH] Use IID_PPV_ARGS macro --- DirectXTex/DirectXTexD3D11.cpp | 12 ++++++++---- DirectXTex/DirectXTexUtil.cpp | 8 +++----- ScreenGrab/ScreenGrab.cpp | 12 +++++++----- Texconv/texconv.cpp | 2 +- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/DirectXTex/DirectXTexD3D11.cpp b/DirectXTex/DirectXTexD3D11.cpp index b78f8c7..824aa29 100644 --- a/DirectXTex/DirectXTexD3D11.cpp +++ b/DirectXTex/DirectXTexD3D11.cpp @@ -19,6 +19,10 @@ #include #endif +#ifndef IID_GRAPHICS_PPV_ARGS +#define IID_GRAPHICS_PPV_ARGS(x) IID_PPV_ARGS(x) +#endif + using Microsoft::WRL::ComPtr; namespace DirectX @@ -43,7 +47,7 @@ static HRESULT _Capture( _In_ ID3D11DeviceContext* pContext, _In_ ID3D11Resource return hr; ComPtr d3dContextX; - hr = pContext->QueryInterface( __uuidof(ID3D11DeviceContextX), reinterpret_cast( d3dContextX.GetAddressOf() ) ); + hr = pContext->QueryInterface( IID_GRAPHICS_PPV_ARGS( d3dContextX.GetAddressOf() ) ); if ( FAILED(hr) ) return hr; @@ -698,7 +702,7 @@ HRESULT CaptureTexture( ID3D11Device* pDevice, ID3D11DeviceContext* pContext, ID case D3D11_RESOURCE_DIMENSION_TEXTURE1D: { ComPtr pTexture; - hr = pSource->QueryInterface( __uuidof(ID3D11Texture1D), reinterpret_cast( pTexture.GetAddressOf() ) ); + hr = pSource->QueryInterface( IID_GRAPHICS_PPV_ARGS( pTexture.GetAddressOf() ) ); if ( FAILED(hr) ) break; @@ -742,7 +746,7 @@ HRESULT CaptureTexture( ID3D11Device* pDevice, ID3D11DeviceContext* pContext, ID case D3D11_RESOURCE_DIMENSION_TEXTURE2D: { ComPtr pTexture; - hr = pSource->QueryInterface( __uuidof(ID3D11Texture2D), reinterpret_cast( pTexture.GetAddressOf() ) ); + hr = pSource->QueryInterface( IID_GRAPHICS_PPV_ARGS( pTexture.GetAddressOf() ) ); if ( FAILED(hr) ) break; @@ -843,7 +847,7 @@ HRESULT CaptureTexture( ID3D11Device* pDevice, ID3D11DeviceContext* pContext, ID case D3D11_RESOURCE_DIMENSION_TEXTURE3D: { ComPtr pTexture; - hr = pSource->QueryInterface( __uuidof(ID3D11Texture3D), reinterpret_cast( pTexture.GetAddressOf() ) ); + hr = pSource->QueryInterface( IID_GRAPHICS_PPV_ARGS( pTexture.GetAddressOf() ) ); if ( FAILED(hr) ) break; diff --git a/DirectXTex/DirectXTexUtil.cpp b/DirectXTex/DirectXTexUtil.cpp index dc3077b..e67e931 100644 --- a/DirectXTex/DirectXTexUtil.cpp +++ b/DirectXTex/DirectXTexUtil.cpp @@ -259,8 +259,7 @@ IWICImagingFactory* GetWICFactory(bool& iswic2) CLSID_WICImagingFactory1, nullptr, CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory), - (LPVOID*)&g_Factory + IID_PPV_ARGS(&g_Factory) ); if (FAILED(hr)) @@ -274,8 +273,7 @@ IWICImagingFactory* GetWICFactory(bool& iswic2) CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory), - (LPVOID*)&g_Factory + IID_PPV_ARGS(&g_Factory) ); g_WIC2 = false; @@ -305,7 +303,7 @@ void SetWICFactory(_In_opt_ IWICImagingFactory* pWIC) { #if(_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) ComPtr wic2; - HRESULT hr = pWIC->QueryInterface(_uuidof(IWICImagingFactory2), reinterpret_cast(wic2.GetAddressOf())); + HRESULT hr = pWIC->QueryInterface(IID_PPV_ARGS(wic2.GetAddressOf())); if (SUCCEEDED(hr)) { iswic2 = true; diff --git a/ScreenGrab/ScreenGrab.cpp b/ScreenGrab/ScreenGrab.cpp index e5d054f..4519b73 100644 --- a/ScreenGrab/ScreenGrab.cpp +++ b/ScreenGrab/ScreenGrab.cpp @@ -37,6 +37,10 @@ #include "ScreenGrab.h" +#ifndef IID_GRAPHICS_PPV_ARGS +#define IID_GRAPHICS_PPV_ARGS(x) IID_PPV_ARGS(x) +#endif + using Microsoft::WRL::ComPtr; //-------------------------------------------------------------------------------------- @@ -614,7 +618,7 @@ static HRESULT CaptureTexture( _In_ ID3D11DeviceContext* pContext, return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); ComPtr pTexture; - HRESULT hr = pSource->QueryInterface( __uuidof(ID3D11Texture2D), reinterpret_cast( pTexture.GetAddressOf() ) ); + HRESULT hr = pSource->QueryInterface( IID_GRAPHICS_PPV_ARGS( pTexture.GetAddressOf() ) ); if ( FAILED(hr) ) return hr; @@ -726,8 +730,7 @@ static IWICImagingFactory* _GetWIC() CLSID_WICImagingFactory1, nullptr, CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory), - (LPVOID*)&s_Factory + IID_PPV_ARGS(&s_Factory) ); if ( FAILED(hr) ) @@ -741,8 +744,7 @@ static IWICImagingFactory* _GetWIC() CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory), - (LPVOID*)&s_Factory + IID_PPV_ARGS(&s_Factory) ); if ( FAILED(hr) ) diff --git a/Texconv/texconv.cpp b/Texconv/texconv.cpp index 31015ba..22cefbe 100644 --- a/Texconv/texconv.cpp +++ b/Texconv/texconv.cpp @@ -568,7 +568,7 @@ bool CreateDevice( _Outptr_ ID3D11Device** pDevice ) if ( SUCCEEDED(hr) ) { ComPtr dxgiDevice; - hr = (*pDevice)->QueryInterface( __uuidof( IDXGIDevice ), reinterpret_cast< void** >( dxgiDevice.GetAddressOf() ) ); + hr = (*pDevice)->QueryInterface( IID_PPV_ARGS( dxgiDevice.GetAddressOf() ) ); if ( SUCCEEDED(hr) ) { ComPtr pAdapter;