зеркало из https://github.com/mozilla/gecko-dev.git
Bug 656185 - Part 4 - Upload the entire image for PlanarYCbCrImageD3D10 to a texture and clip using texture coordinates. r=Bas
This commit is contained in:
Родитель
a1491697a0
Коммит
ef4adc6afb
|
@ -348,11 +348,24 @@ ImageLayerD3D10::RenderLayer()
|
||||||
(float)yuvImage->mSize.width,
|
(float)yuvImage->mSize.width,
|
||||||
(float)yuvImage->mSize.height)
|
(float)yuvImage->mSize.height)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
effect()->GetVariableByName("vTextureCoords")->AsVector()->SetFloatVector(
|
||||||
|
ShaderConstantRectD3D10(
|
||||||
|
(float)yuvImage->mData.mPicX / yuvImage->mData.mYSize.width,
|
||||||
|
(float)yuvImage->mData.mPicY / yuvImage->mData.mYSize.height,
|
||||||
|
(float)yuvImage->mData.mPicSize.width / yuvImage->mData.mYSize.width,
|
||||||
|
(float)yuvImage->mData.mPicSize.height / yuvImage->mData.mYSize.height)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
technique->GetPassByIndex(0)->Apply(0);
|
technique->GetPassByIndex(0)->Apply(0);
|
||||||
device()->Draw(4, 0);
|
device()->Draw(4, 0);
|
||||||
|
|
||||||
|
if (image->GetFormat() == Image::PLANAR_YCBCR) {
|
||||||
|
effect()->GetVariableByName("vTextureCoords")->AsVector()->
|
||||||
|
SetFloatVector(ShaderConstantRectD3D10(0, 0, 1.0f, 1.0f));
|
||||||
|
}
|
||||||
|
|
||||||
GetContainer()->NotifyPaintedImage(image);
|
GetContainer()->NotifyPaintedImage(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,75 +379,8 @@ PlanarYCbCrImageD3D10::PlanarYCbCrImageD3D10(ID3D10Device1 *aDevice)
|
||||||
void
|
void
|
||||||
PlanarYCbCrImageD3D10::SetData(const PlanarYCbCrImage::Data &aData)
|
PlanarYCbCrImageD3D10::SetData(const PlanarYCbCrImage::Data &aData)
|
||||||
{
|
{
|
||||||
// XXX - For D3D10Ex we really should just copy to systemmem surfaces here.
|
PRUint32 dummy;
|
||||||
// For now, we copy the data
|
mBuffer = CopyData(mData, mSize, dummy, aData);
|
||||||
int width_shift = 0;
|
|
||||||
int height_shift = 0;
|
|
||||||
if (aData.mYSize.width == aData.mCbCrSize.width &&
|
|
||||||
aData.mYSize.height == aData.mCbCrSize.height) {
|
|
||||||
// YV24 format
|
|
||||||
width_shift = 0;
|
|
||||||
height_shift = 0;
|
|
||||||
mType = gfx::YV24;
|
|
||||||
} else if (aData.mYSize.width / 2 == aData.mCbCrSize.width &&
|
|
||||||
aData.mYSize.height == aData.mCbCrSize.height) {
|
|
||||||
// YV16 format
|
|
||||||
width_shift = 1;
|
|
||||||
height_shift = 0;
|
|
||||||
mType = gfx::YV16;
|
|
||||||
} else if (aData.mYSize.width / 2 == aData.mCbCrSize.width &&
|
|
||||||
aData.mYSize.height / 2 == aData.mCbCrSize.height ) {
|
|
||||||
// YV12 format
|
|
||||||
width_shift = 1;
|
|
||||||
height_shift = 1;
|
|
||||||
mType = gfx::YV12;
|
|
||||||
} else {
|
|
||||||
NS_ERROR("YCbCr format not supported");
|
|
||||||
}
|
|
||||||
|
|
||||||
mData = aData;
|
|
||||||
mData.mCbCrStride = mData.mCbCrSize.width = aData.mPicSize.width >> width_shift;
|
|
||||||
// Round up the values for width and height to make sure we sample enough data
|
|
||||||
// for the last pixel - See bug 590735
|
|
||||||
if (width_shift && (aData.mPicSize.width & 1)) {
|
|
||||||
mData.mCbCrStride++;
|
|
||||||
mData.mCbCrSize.width++;
|
|
||||||
}
|
|
||||||
mData.mCbCrSize.height = aData.mPicSize.height >> height_shift;
|
|
||||||
if (height_shift && (aData.mPicSize.height & 1)) {
|
|
||||||
mData.mCbCrSize.height++;
|
|
||||||
}
|
|
||||||
mData.mYSize = aData.mPicSize;
|
|
||||||
mData.mYStride = mData.mYSize.width;
|
|
||||||
|
|
||||||
mBuffer = new PRUint8[mData.mCbCrStride * mData.mCbCrSize.height * 2 +
|
|
||||||
mData.mYStride * mData.mYSize.height];
|
|
||||||
mData.mYChannel = mBuffer;
|
|
||||||
mData.mCbChannel = mData.mYChannel + mData.mYStride * mData.mYSize.height;
|
|
||||||
mData.mCrChannel = mData.mCbChannel + mData.mCbCrStride * mData.mCbCrSize.height;
|
|
||||||
|
|
||||||
int cbcr_x = aData.mPicX >> width_shift;
|
|
||||||
int cbcr_y = aData.mPicY >> height_shift;
|
|
||||||
|
|
||||||
for (int i = 0; i < mData.mYSize.height; i++) {
|
|
||||||
memcpy(mData.mYChannel + i * mData.mYStride,
|
|
||||||
aData.mYChannel + ((aData.mPicY + i) * aData.mYStride) + aData.mPicX,
|
|
||||||
mData.mYStride);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < mData.mCbCrSize.height; i++) {
|
|
||||||
memcpy(mData.mCbChannel + i * mData.mCbCrStride,
|
|
||||||
aData.mCbChannel + ((cbcr_y + i) * aData.mCbCrStride) + cbcr_x,
|
|
||||||
mData.mCbCrStride);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < mData.mCbCrSize.height; i++) {
|
|
||||||
memcpy(mData.mCrChannel + i * mData.mCbCrStride,
|
|
||||||
aData.mCrChannel + ((cbcr_y + i) * aData.mCbCrStride) + cbcr_x,
|
|
||||||
mData.mCbCrStride);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fix picture rect to be correct
|
|
||||||
mData.mPicX = mData.mPicY = 0;
|
|
||||||
mSize = aData.mPicSize;
|
|
||||||
|
|
||||||
AllocateTextures();
|
AllocateTextures();
|
||||||
|
|
||||||
|
@ -477,19 +423,25 @@ PlanarYCbCrImageD3D10::GetAsSurface()
|
||||||
nsRefPtr<gfxImageSurface> imageSurface =
|
nsRefPtr<gfxImageSurface> imageSurface =
|
||||||
new gfxImageSurface(mSize, gfxASurface::ImageFormatRGB24);
|
new gfxImageSurface(mSize, gfxASurface::ImageFormatRGB24);
|
||||||
|
|
||||||
|
gfx::YUVType type =
|
||||||
|
gfx::TypeFromSize(mData.mYSize.width,
|
||||||
|
mData.mYSize.height,
|
||||||
|
mData.mCbCrSize.width,
|
||||||
|
mData.mCbCrSize.height);
|
||||||
|
|
||||||
// Convert from YCbCr to RGB now
|
// Convert from YCbCr to RGB now
|
||||||
gfx::ConvertYCbCrToRGB32(mData.mYChannel,
|
gfx::ConvertYCbCrToRGB32(mData.mYChannel,
|
||||||
mData.mCbChannel,
|
mData.mCbChannel,
|
||||||
mData.mCrChannel,
|
mData.mCrChannel,
|
||||||
imageSurface->Data(),
|
imageSurface->Data(),
|
||||||
0,
|
mData.mPicX,
|
||||||
0,
|
mData.mPicY,
|
||||||
mSize.width,
|
mData.mPicSize.width,
|
||||||
mSize.height,
|
mData.mPicSize.height,
|
||||||
mData.mYStride,
|
mData.mYStride,
|
||||||
mData.mCbCrStride,
|
mData.mCbCrStride,
|
||||||
imageSurface->Stride(),
|
imageSurface->Stride(),
|
||||||
mType);
|
type);
|
||||||
|
|
||||||
return imageSurface.forget().get();
|
return imageSurface.forget().get();
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,6 @@ public:
|
||||||
nsRefPtr<ID3D10ShaderResourceView> mCbView;
|
nsRefPtr<ID3D10ShaderResourceView> mCbView;
|
||||||
nsRefPtr<ID3D10ShaderResourceView> mCrView;
|
nsRefPtr<ID3D10ShaderResourceView> mCrView;
|
||||||
PRPackedBool mHasData;
|
PRPackedBool mHasData;
|
||||||
gfx::YUVType mType;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче