diff options
author | Anton Fedchin <anightik@gmail.com> | 2018-02-08 14:27:07 +0300 |
---|---|---|
committer | Anton Fedchin <anightik@gmail.com> | 2018-02-08 14:39:06 +0300 |
commit | 80652d90b81def401e2a019fd8550f87cfc59b45 (patch) | |
tree | 50618e52bafd1e248e0ce9c0ad862569b7759e2d | |
parent | 3a06da4e65d9a3abf29bf7548b47420445edf9df (diff) |
[VideoPlayer] Rendercapture: use ComPtr instead of raw pointers.
-rw-r--r-- | xbmc/cores/VideoPlayer/VideoRenderers/RenderCapture.cpp | 18 | ||||
-rw-r--r-- | xbmc/cores/VideoPlayer/VideoRenderers/RenderCapture.h | 3 |
2 files changed, 11 insertions, 10 deletions
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/RenderCapture.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/RenderCapture.cpp index ae010a539a..8622c434c9 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/RenderCapture.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/RenderCapture.cpp @@ -304,8 +304,8 @@ int CRenderCaptureDX::GetCaptureFormat() void CRenderCaptureDX::BeginRender() { - ID3D11DeviceContext* pContext = DX::DeviceResources::Get()->GetD3DContext(); - ID3D11Device* pDevice = DX::DeviceResources::Get()->GetD3DDevice(); + Microsoft::WRL::ComPtr<ID3D11DeviceContext> pContext = DX::DeviceResources::Get()->GetD3DContext(); + Microsoft::WRL::ComPtr<ID3D11Device> pDevice = DX::DeviceResources::Get()->GetD3DDevice(); CD3D11_QUERY_DESC queryDesc(D3D11_QUERY_EVENT); if (!m_asyncChecked) @@ -358,20 +358,20 @@ void CRenderCaptureDX::BeginRender() //generate an occlusion query if we don't have one if (!m_query) { - result = pDevice->CreateQuery(&queryDesc, &m_query); + result = pDevice->CreateQuery(&queryDesc, m_query.ReleaseAndGetAddressOf()); if (FAILED(result)) { CLog::LogF(LOGERROR, "CreateQuery failed %s", DX::GetErrorDescription(result).c_str()); m_asyncSupported = false; - SAFE_RELEASE(m_query); + m_query = nullptr; } } } else { //don't use an occlusion query, clean up any old one - SAFE_RELEASE(m_query); + m_query = nullptr; } } @@ -380,13 +380,13 @@ void CRenderCaptureDX::EndRender() // send commands to the GPU queue auto deviceResources = DX::DeviceResources::Get(); deviceResources->FinishCommandList(); - ID3D11DeviceContext* pContext = deviceResources->GetImmediateContext(); + Microsoft::WRL::ComPtr<ID3D11DeviceContext> pContext = deviceResources->GetImmediateContext(); pContext->CopyResource(m_copyTex.Get(), m_renderTex.Get()); if (m_query) { - pContext->End(m_query); + pContext->End(m_query.Get()); } if (m_flags & CAPTUREFLAG_IMMEDIATELY) @@ -400,7 +400,7 @@ void CRenderCaptureDX::ReadOut() if (m_query) { //if the result of the occlusion query is available, the data is probably also written into m_copySurface - HRESULT result = DX::DeviceResources::Get()->GetImmediateContext()->GetData(m_query, nullptr, 0, 0); + HRESULT result = DX::DeviceResources::Get()->GetImmediateContext()->GetData(m_query.Get(), nullptr, 0, 0); if (SUCCEEDED(result)) { if (S_OK == result) @@ -453,7 +453,7 @@ void CRenderCaptureDX::CleanupDX() { m_renderTex.Release(); m_copyTex.Release(); - SAFE_RELEASE(m_query); + m_query = nullptr; m_surfaceWidth = 0; m_surfaceHeight = 0; } diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/RenderCapture.h b/xbmc/cores/VideoPlayer/VideoRenderers/RenderCapture.h index 035da2de90..915fb64feb 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/RenderCapture.h +++ b/xbmc/cores/VideoPlayer/VideoRenderers/RenderCapture.h @@ -24,6 +24,7 @@ #ifdef HAS_DX #include "guilib/D3DResource.h" + #include <wrl/client.h> #endif #include "threads/Event.h" @@ -194,7 +195,7 @@ class CRenderCaptureDX : public CRenderCaptureBase, public ID3DResource unsigned int m_surfaceWidth; unsigned int m_surfaceHeight; - ID3D11Query* m_query; + Microsoft::WRL::ComPtr<ID3D11Query> m_query; CD3DTexture m_renderTex; CD3DTexture m_copyTex; }; |