Bug 1960254 - Remove D3D11ShareHandleImage::MaybeCreateNV12ImageAndSetData() r=gfx-reviewers,lsalzman

D3D11ShareHandleImage::MaybeCreateNV12ImageAndSetData() is no longer used.

Differential Revision: https://phabricator.services.mozilla.com/D245370
This commit is contained in:
sotaro
2025-04-14 05:05:47 +00:00
parent 54025f3acc
commit 475d5fa49e
2 changed files with 0 additions and 134 deletions

View File

@@ -24,136 +24,6 @@ namespace layers {
using namespace gfx;
/* static */
RefPtr<D3D11ShareHandleImage>
D3D11ShareHandleImage::MaybeCreateNV12ImageAndSetData(
KnowsCompositor* aKnowsCompositor, ImageContainer* aContainer,
const PlanarYCbCrData& aData) {
MOZ_ASSERT(aKnowsCompositor);
MOZ_ASSERT(aContainer);
if (!aKnowsCompositor || !aContainer) {
return nullptr;
}
// Check if data could be used with NV12
if (aData.YPictureSize().width % 2 != 0 ||
aData.YPictureSize().height % 2 != 0 || aData.mYSkip != 0 ||
aData.mCbSkip != 0 || aData.mCrSkip != 0 ||
aData.mColorDepth != gfx::ColorDepth::COLOR_8 ||
aData.mColorRange != gfx::ColorRange::LIMITED ||
aData.mChromaSubsampling !=
gfx::ChromaSubsampling::HALF_WIDTH_AND_HEIGHT) {
return nullptr;
}
RefPtr<D3D11ShareHandleImage> image =
new D3D11ShareHandleImage(aData.YPictureSize(), aData.mPictureRect,
ToColorSpace2(aData.mYUVColorSpace),
aData.mColorRange, aData.mColorDepth);
RefPtr<D3D11RecycleAllocator> allocator =
aContainer->GetD3D11RecycleAllocator(aKnowsCompositor,
gfx::SurfaceFormat::NV12);
if (!allocator) {
return nullptr;
}
auto syncObject = allocator->GetSyncObject();
if (!syncObject) {
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
return nullptr;
}
MOZ_ASSERT(allocator->GetUsableSurfaceFormat() == gfx::SurfaceFormat::NV12);
if (allocator->GetUsableSurfaceFormat() != gfx::SurfaceFormat::NV12) {
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
return nullptr;
}
RefPtr<ID3D11Texture2D> stagingTexture =
allocator->GetStagingTextureNV12(aData.YPictureSize());
if (!stagingTexture) {
return nullptr;
}
bool ok = image->AllocateTexture(allocator, allocator->mDevice);
if (!ok) {
return nullptr;
}
RefPtr<TextureClient> client = image->GetTextureClient(nullptr);
if (!client) {
return nullptr;
}
client->AddFlags(TextureFlags::SOFTWARE_DECODED_VIDEO);
// The texture does not have keyed mutex. When keyed mutex exists, the texture
// could not be used for video overlay. Then it needs manual synchronization
RefPtr<ID3D11Texture2D> texture = image->GetTexture();
if (!texture) {
return nullptr;
}
RefPtr<ID3D11DeviceContext> context;
allocator->mDevice->GetImmediateContext(getter_AddRefs(context));
if (!context) {
return nullptr;
}
RefPtr<ID3D10Multithread> mt;
HRESULT hr = allocator->mDevice->QueryInterface(
(ID3D10Multithread**)getter_AddRefs(mt));
if (FAILED(hr) || !mt) {
gfxCriticalError() << "Multithread safety interface not supported. " << hr;
return nullptr;
}
if (!mt->GetMultithreadProtected()) {
gfxCriticalError() << "Device used not marked as multithread-safe.";
return nullptr;
}
D3D11MTAutoEnter mtAutoEnter(mt.forget());
AutoLockD3D11Texture lockSt(stagingTexture);
D3D11_MAP mapType = D3D11_MAP_WRITE;
D3D11_MAPPED_SUBRESOURCE mappedResource;
hr = context->Map(stagingTexture, 0, mapType, 0, &mappedResource);
if (FAILED(hr)) {
gfxCriticalNoteOnce << "Mapping D3D11 staging texture failed: "
<< gfx::hexa(hr);
return nullptr;
}
const size_t destStride = mappedResource.RowPitch;
uint8_t* yDestPlaneStart = reinterpret_cast<uint8_t*>(mappedResource.pData);
uint8_t* uvDestPlaneStart = reinterpret_cast<uint8_t*>(mappedResource.pData) +
destStride * aData.YPictureSize().height;
// Convert I420 to NV12,
libyuv::I420ToNV12(aData.mYChannel, aData.mYStride, aData.mCbChannel,
aData.mCbCrStride, aData.mCrChannel, aData.mCbCrStride,
yDestPlaneStart, destStride, uvDestPlaneStart, destStride,
aData.YDataSize().width, aData.YDataSize().height);
context->Unmap(stagingTexture, 0);
context->CopyResource(texture, stagingTexture);
context->Flush();
client->SyncWithObject(syncObject);
if (!syncObject->Synchronize(true)) {
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
return nullptr;
}
return image;
}
D3D11ShareHandleImage::D3D11ShareHandleImage(const gfx::IntSize& aSize,
const gfx::IntRect& aRect,
gfx::ColorSpace2 aColorSpace,

View File

@@ -68,10 +68,6 @@ class D3D11RecycleAllocator final : public TextureClientRecycleAllocator {
// resource is ready to use.
class D3D11ShareHandleImage final : public Image {
public:
static RefPtr<D3D11ShareHandleImage> MaybeCreateNV12ImageAndSetData(
KnowsCompositor* aAllocator, ImageContainer* aContainer,
const PlanarYCbCrData& aData);
D3D11ShareHandleImage(const gfx::IntSize& aSize, const gfx::IntRect& aRect,
gfx::ColorSpace2 aColorSpace,
gfx::ColorRange aColorRange,