Bug 1757111 - Report cropped YCbCr sizes in RenderExternalTextureHost. r=jrmuizel

I had assumed in bug 1750858 that we would only need to modify RenderBufferTextureHost.
It turns out macOS will also still use the ffmpeg decoder and so RenderExternalTextureHost
must report cropped YCbCr sizes as well.

Differential Revision: https://phabricator.services.mozilla.com/D139679
This commit is contained in:
Lee Salzman 2022-02-26 21:12:35 +00:00
Родитель d854f45476
Коммит 0e447bde60
2 изменённых файлов: 14 добавлений и 10 удалений

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

@ -73,16 +73,17 @@ wr::WrExternalImage RenderBufferTextureHost::Lock(
}
} else {
const layers::YCbCrDescriptor& desc = mDescriptor.get_YCbCrDescriptor();
auto cbcrSize = layers::ImageDataSerializer::GetCroppedCbCrSize(desc);
mYSurface = gfx::Factory::CreateWrappingDataSourceSurface(
layers::ImageDataSerializer::GetYChannel(GetBuffer(), desc),
desc.yStride(), desc.ySize(), gfx::SurfaceFormat::A8);
desc.yStride(), desc.display().Size(), gfx::SurfaceFormat::A8);
mCbSurface = gfx::Factory::CreateWrappingDataSourceSurface(
layers::ImageDataSerializer::GetCbChannel(GetBuffer(), desc),
desc.cbCrStride(), desc.cbCrSize(), gfx::SurfaceFormat::A8);
desc.cbCrStride(), cbcrSize, gfx::SurfaceFormat::A8);
mCrSurface = gfx::Factory::CreateWrappingDataSourceSurface(
layers::ImageDataSerializer::GetCrChannel(GetBuffer(), desc),
desc.cbCrStride(), desc.cbCrSize(), gfx::SurfaceFormat::A8);
desc.cbCrStride(), cbcrSize, gfx::SurfaceFormat::A8);
if (NS_WARN_IF(!mYSurface || !mCbSurface || !mCrSurface)) {
mYSurface = mCbSurface = mCrSurface = nullptr;
gfxCriticalNote << "YCbCr Surface is null";

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

@ -25,7 +25,7 @@ RenderExternalTextureHost::RenderExternalTextureHost(
switch (mDescriptor.type()) {
case layers::BufferDescriptor::TYCbCrDescriptor: {
const layers::YCbCrDescriptor& ycbcr = mDescriptor.get_YCbCrDescriptor();
mSize = ycbcr.ySize();
mSize = ycbcr.display().Size();
mFormat = gfx::SurfaceFormat::YUV;
break;
}
@ -63,16 +63,17 @@ bool RenderExternalTextureHost::CreateSurfaces() {
const layers::YCbCrDescriptor& desc = mDescriptor.get_YCbCrDescriptor();
const gfx::SurfaceFormat surfaceFormat =
SurfaceFormatForColorDepth(desc.colorDepth());
auto cbcrSize = layers::ImageDataSerializer::GetCroppedCbCrSize(desc);
mSurfaces[0] = gfx::Factory::CreateWrappingDataSourceSurface(
layers::ImageDataSerializer::GetYChannel(GetBuffer(), desc),
desc.yStride(), desc.ySize(), surfaceFormat);
desc.yStride(), desc.display().Size(), surfaceFormat);
mSurfaces[1] = gfx::Factory::CreateWrappingDataSourceSurface(
layers::ImageDataSerializer::GetCbChannel(GetBuffer(), desc),
desc.cbCrStride(), desc.cbCrSize(), surfaceFormat);
desc.cbCrStride(), cbcrSize, surfaceFormat);
mSurfaces[2] = gfx::Factory::CreateWrappingDataSourceSurface(
layers::ImageDataSerializer::GetCrChannel(GetBuffer(), desc),
desc.cbCrStride(), desc.cbCrSize(), surfaceFormat);
desc.cbCrStride(), cbcrSize, surfaceFormat);
}
for (size_t i = 0; i < PlaneCount(); ++i) {
@ -239,19 +240,21 @@ bool RenderExternalTextureHost::MapPlane(RenderCompositor* aCompositor,
aPlaneInfo.mData =
layers::ImageDataSerializer::GetYChannel(mBuffer, desc);
aPlaneInfo.mStride = desc.yStride();
aPlaneInfo.mSize = desc.ySize();
aPlaneInfo.mSize = desc.display().Size();
break;
case 1:
aPlaneInfo.mData =
layers::ImageDataSerializer::GetCbChannel(mBuffer, desc);
aPlaneInfo.mStride = desc.cbCrStride();
aPlaneInfo.mSize = desc.cbCrSize();
aPlaneInfo.mSize =
layers::ImageDataSerializer::GetCroppedCbCrSize(desc);
break;
case 2:
aPlaneInfo.mData =
layers::ImageDataSerializer::GetCrChannel(mBuffer, desc);
aPlaneInfo.mStride = desc.cbCrStride();
aPlaneInfo.mSize = desc.cbCrSize();
aPlaneInfo.mSize =
layers::ImageDataSerializer::GetCroppedCbCrSize(desc);
break;
}
break;