D3D11TextureWrapper.h (1749B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 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 __D3D11TextureWrapper_h__ 8 #define __D3D11TextureWrapper_h__ 9 10 #include <functional> 11 12 #include "mozilla/gfx/Types.h" 13 14 struct AVFrame; 15 struct AVBufferRef; 16 struct ID3D11Texture2D; 17 18 namespace mozilla { 19 20 struct FFmpegLibWrapper; 21 22 // D3D11TextureWrapper manages the lifecycle of hardware buffers used 23 // by the FFVPX hardware decoder when zero-copy decoding is enabled. By 24 // adding a reference to the hardware buffer, it prevents the FFVPX decoder 25 // from reusing the buffer too early (while it is still being used for display), 26 // which can help avoid significant playback stutter. 27 class D3D11TextureWrapper final { 28 public: 29 D3D11TextureWrapper(AVFrame* aAVFrame, const FFmpegLibWrapper* aLib, 30 ID3D11Texture2D* aTexture, 31 const gfx::SurfaceFormat aFormat, 32 const unsigned int aArrayIdx, 33 std::function<void()>&& aReleaseMethod); 34 D3D11TextureWrapper(D3D11TextureWrapper&& aWrapper) = delete; 35 D3D11TextureWrapper(const D3D11TextureWrapper&& aWrapper) = delete; 36 37 ~D3D11TextureWrapper(); 38 39 ID3D11Texture2D* GetTexture() const { return mTexture; } 40 41 const gfx::SurfaceFormat mFormat; 42 const unsigned int mArrayIdx; 43 const std::function<void()> mReleaseMethod; 44 45 private: 46 const FFmpegLibWrapper* mLib; 47 ID3D11Texture2D* mTexture; 48 AVBufferRef* mHWAVBuffer; 49 }; 50 51 } // namespace mozilla 52 53 #endif // __D3D11TextureWrapper_h__