VideoProcessorD3D11.h (2639B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef MOZILLA_GFX_VideoProcessorD3D11_H 8 #define MOZILLA_GFX_VideoProcessorD3D11_H 9 10 #include <d3d11.h> 11 12 #include "mozilla/gfx/2D.h" 13 #include "mozilla/RefPtr.h" 14 #include "nsISupportsImpl.h" 15 16 struct ID3D11Device; 17 struct ID3D11DeviceContext; 18 struct ID3D11Texture2D; 19 struct ID3D11VideoDevice; 20 struct ID3D11VideoContext; 21 struct ID3D11VideoContext1; 22 struct ID3D11VideoProcessor; 23 struct ID3D11VideoProcessorEnumerator; 24 struct ID3D11VideoProcessorOutputView; 25 26 namespace mozilla { 27 namespace layers { 28 29 class DXGITextureHostD3D11; 30 31 // 32 // A class for wrapping ID3D11VideoProcessor. 33 // 34 // The class can be used for converting NV12 video frame to RGB 35 class VideoProcessorD3D11 { 36 public: 37 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoProcessorD3D11); 38 39 static RefPtr<VideoProcessorD3D11> Create(ID3D11Device* aDevice); 40 41 HRESULT Init(const gfx::IntSize& aSize); 42 43 struct InputTextureInfo { 44 InputTextureInfo(gfx::ColorSpace2 aColorSpace, gfx::ColorRange aColorRange, 45 uint32_t aIndex, ID3D11Texture2D* aTexture) 46 : mColorSpace(aColorSpace), 47 mColorRange(aColorRange), 48 mIndex(aIndex), 49 mTexture(aTexture) {} 50 const gfx::ColorSpace2 mColorSpace; 51 const gfx::ColorRange mColorRange; 52 const uint32_t mIndex; 53 ID3D11Texture2D* mTexture; 54 }; 55 bool CallVideoProcessorBlt(InputTextureInfo& aTextureInfo, 56 ID3D11Texture2D* aOutputTexture); 57 gfx::IntSize GetSize() const { return mSize; } 58 59 protected: 60 VideoProcessorD3D11(ID3D11Device* aDevice, 61 ID3D11DeviceContext* aDeviceContext, 62 ID3D11VideoDevice* aVideoDevice, 63 ID3D11VideoContext* aVideoContext, 64 ID3D11VideoContext1* aVideoContext1); 65 ~VideoProcessorD3D11(); 66 67 public: 68 const RefPtr<ID3D11Device> mDevice; 69 const RefPtr<ID3D11DeviceContext> mDeviceContext; 70 const RefPtr<ID3D11VideoDevice> mVideoDevice; 71 const RefPtr<ID3D11VideoContext> mVideoContext; 72 const RefPtr<ID3D11VideoContext1> mVideoContext1; 73 74 protected: 75 gfx::IntSize mSize; 76 RefPtr<ID3D11VideoProcessor> mVideoProcessor; 77 RefPtr<ID3D11VideoProcessorEnumerator> mVideoProcessorEnumerator; 78 bool mContentIsHDR = false; 79 }; 80 81 } // namespace layers 82 } // namespace mozilla 83 84 #endif // MOZILLA_GFX_VideoProcessorD3D11_H