Bug 1856520 - Set DXGI_SWAP_CHAIN_FLAG_DISPLAY_ONLY to Video swap chain of video overlay when video is DRM protected on Windows r=gfx-reviewers,lsalzman

DRM info is delivered from SharedPlanarYCbCrImage to DCSurfaceVideo

Differential Revision: https://phabricator.services.mozilla.com/D190141
This commit is contained in:
sotaro 2023-10-05 03:43:01 +00:00
Родитель a2f943610b
Коммит ab881cf89b
6 изменённых файлов: 19 добавлений и 2 удалений

Просмотреть файл

@ -125,7 +125,7 @@ class Image {
int32_t GetSerial() const { return mSerial; }
bool IsDRM() const { return mIsDRM; }
void SetIsDRM(bool aIsDRM) { mIsDRM = aIsDRM; }
virtual void SetIsDRM(bool aIsDRM) { mIsDRM = aIsDRM; }
virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() = 0;

Просмотреть файл

@ -947,6 +947,9 @@ void DXGITextureHostD3D11::CreateRenderTexture(
if (mFlags & TextureFlags::SOFTWARE_DECODED_VIDEO) {
texture->SetIsSoftwareDecodedVideo();
}
if (mFlags & TextureFlags::DRM_SOURCE) {
texture->SetIsFromDRMSource(/* aIsFromDRMSource */ true);
}
wr::RenderThread::Get()->RegisterExternalImage(aExternalImageId,
texture.forget());
}

Просмотреть файл

@ -170,5 +170,12 @@ bool SharedPlanarYCbCrImage::CreateEmptyBuffer(const PlanarYCbCrData& aData,
return mBufferSize > 0;
}
void SharedPlanarYCbCrImage::SetIsDRM(bool aIsDRM) {
Image::SetIsDRM(aIsDRM);
if (mTextureClient) {
mTextureClient->AddFlags(TextureFlags::DRM_SOURCE);
}
}
} // namespace layers
} // namespace mozilla

Просмотреть файл

@ -41,6 +41,7 @@ class SharedPlanarYCbCrImage : public PlanarYCbCrImage {
bool CreateEmptyBuffer(const Data& aData, const gfx::IntSize& aYSize,
const gfx::IntSize& aCbCrSize) override;
void SetIsDRM(bool aIsDRM) override;
bool IsValid() const override;
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override {

Просмотреть файл

@ -1186,6 +1186,7 @@ bool DCSurfaceVideo::CalculateSwapChainSize(gfx::Matrix& aTransform) {
bool needsToPresent = mPrevTexture != mRenderTextureHost;
gfx::IntSize swapChainSize = mVideoSize;
gfx::Matrix transform = aTransform;
const bool isDRM = mRenderTextureHost->IsFromDRMSource();
// When video is rendered to axis aligned integer rectangle, video scaling
// could be done by VideoProcessor
@ -1214,11 +1215,12 @@ bool DCSurfaceVideo::CalculateSwapChainSize(gfx::Matrix& aTransform) {
transform = gfx::Matrix::Translation(aTransform.GetTranslation());
}
if (!mVideoSwapChain || mSwapChainSize != swapChainSize) {
if (!mVideoSwapChain || mSwapChainSize != swapChainSize || mIsDRM != isDRM) {
needsToPresent = true;
ReleaseDecodeSwapChainResources();
// Update mSwapChainSize before creating SwapChain
mSwapChainSize = swapChainSize;
mIsDRM = isDRM;
auto swapChainFormat = GetSwapChainFormat();
bool useYUVSwapChain = IsYUVSwapChainFormat(swapChainFormat);
@ -1367,6 +1369,9 @@ bool DCSurfaceVideo::CreateVideoSwapChain() {
if (IsYUVSwapChainFormat(swapChainFormat)) {
desc.Flags |= DXGI_SWAP_CHAIN_FLAG_YUV_VIDEO;
}
if (mIsDRM) {
desc.Flags |= DXGI_SWAP_CHAIN_FLAG_DISPLAY_ONLY;
}
desc.AlphaMode = DXGI_ALPHA_MODE_IGNORE;
HRESULT hr;

Просмотреть файл

@ -400,6 +400,7 @@ class DCSurfaceVideo : public DCSurface {
gfx::IntSize mVideoSize;
gfx::IntSize mSwapChainSize;
DXGI_FORMAT mSwapChainFormat = DXGI_FORMAT_B8G8R8A8_UNORM;
bool mIsDRM = false;
bool mFailedYuvSwapChain = false;
RefPtr<RenderTextureHost> mRenderTextureHost;
RefPtr<RenderTextureHost> mPrevTexture;