Backed out changeset 248c73a2c3b1 (bug 1215089)

This commit is contained in:
Sebastian Hengst 2017-10-04 16:25:46 +02:00
Родитель 4c598e730b
Коммит 2da2f1cc48
17 изменённых файлов: 94 добавлений и 202 удалений

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

@ -92,7 +92,6 @@ BytesPerPixel(SurfaceFormat aFormat)
case SurfaceFormat::A8: case SurfaceFormat::A8:
return 1; return 1;
case SurfaceFormat::R5G6B5_UINT16: case SurfaceFormat::R5G6B5_UINT16:
case SurfaceFormat::A16:
return 2; return 2;
case SurfaceFormat::R8G8B8: case SurfaceFormat::R8G8B8:
case SurfaceFormat::B8G8R8: case SurfaceFormat::B8G8R8:
@ -107,19 +106,6 @@ BytesPerPixel(SurfaceFormat aFormat)
} }
} }
static inline SurfaceFormat
SurfaceFormatForAlphaDepth(uint32_t aDepth)
{
if (aDepth == 8) {
return SurfaceFormat::A8;
} else if (aDepth == 10 ||
aDepth == 12) {
return SurfaceFormat::A16;
}
MOZ_ASSERT_UNREACHABLE("Unsupported alpha depth");
return SurfaceFormat::UNKNOWN;
}
static inline bool static inline bool
IsOpaqueFormat(SurfaceFormat aFormat) { IsOpaqueFormat(SurfaceFormat aFormat) {
switch (aFormat) { switch (aFormat) {

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

@ -56,7 +56,6 @@ enum class SurfaceFormat : int8_t {
// This one is a single-byte, so endianness isn't an issue. // This one is a single-byte, so endianness isn't an issue.
A8, A8,
A16,
R8G8, R8G8,

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

@ -159,7 +159,6 @@ BufferTextureData*
BufferTextureData::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator, BufferTextureData::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
int32_t aBufferSize, int32_t aBufferSize,
YUVColorSpace aYUVColorSpace, YUVColorSpace aYUVColorSpace,
uint32_t aDepth,
TextureFlags aTextureFlags) TextureFlags aTextureFlags)
{ {
if (aBufferSize == 0 || !gfx::Factory::CheckBufferSize(aBufferSize)) { if (aBufferSize == 0 || !gfx::Factory::CheckBufferSize(aBufferSize)) {
@ -172,10 +171,9 @@ BufferTextureData::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
// Initialize the metadata with something, even if it will have to be rewritten // Initialize the metadata with something, even if it will have to be rewritten
// afterwards since we don't know the dimensions of the texture at this point. // afterwards since we don't know the dimensions of the texture at this point.
BufferDescriptor desc = YCbCrDescriptor(gfx::IntSize(), 0, gfx::IntSize(), 0, BufferDescriptor desc = YCbCrDescriptor(gfx::IntSize(), gfx::IntSize(),
0, 0, 0, StereoMode::MONO, 0, 0, 0, StereoMode::MONO,
aYUVColorSpace, aYUVColorSpace,
aDepth,
hasIntermediateBuffer); hasIntermediateBuffer);
return CreateInternal(aAllocator ? aAllocator->GetTextureForwarder() : nullptr, return CreateInternal(aAllocator ? aAllocator->GetTextureForwarder() : nullptr,
@ -185,16 +183,12 @@ BufferTextureData::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
BufferTextureData* BufferTextureData*
BufferTextureData::CreateForYCbCr(KnowsCompositor* aAllocator, BufferTextureData::CreateForYCbCr(KnowsCompositor* aAllocator,
gfx::IntSize aYSize, gfx::IntSize aYSize,
uint32_t aYStride,
gfx::IntSize aCbCrSize, gfx::IntSize aCbCrSize,
uint32_t aCbCrStride,
StereoMode aStereoMode, StereoMode aStereoMode,
YUVColorSpace aYUVColorSpace, YUVColorSpace aYUVColorSpace,
uint32_t aDepth,
TextureFlags aTextureFlags) TextureFlags aTextureFlags)
{ {
uint32_t bufSize = ImageDataSerializer::ComputeYCbCrBufferSize( uint32_t bufSize = ImageDataSerializer::ComputeYCbCrBufferSize(aYSize, aCbCrSize);
aYSize, aYStride, aCbCrSize, aCbCrStride);
if (bufSize == 0) { if (bufSize == 0) {
return nullptr; return nullptr;
} }
@ -202,30 +196,20 @@ BufferTextureData::CreateForYCbCr(KnowsCompositor* aAllocator,
uint32_t yOffset; uint32_t yOffset;
uint32_t cbOffset; uint32_t cbOffset;
uint32_t crOffset; uint32_t crOffset;
ImageDataSerializer::ComputeYCbCrOffsets(aYStride, aYSize.height, ImageDataSerializer::ComputeYCbCrOffsets(aYSize.width, aYSize.height,
aCbCrStride, aCbCrSize.height, aCbCrSize.width, aCbCrSize.height,
yOffset, cbOffset, crOffset); yOffset, cbOffset, crOffset);
bool hasIntermediateBuffer = bool hasIntermediateBuffer = aAllocator ? ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV,
aAllocator aAllocator->GetCompositorBackendType())
? ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV, : true;
aAllocator->GetCompositorBackendType())
: true;
YCbCrDescriptor descriptor = YCbCrDescriptor(aYSize, aYStride, YCbCrDescriptor descriptor = YCbCrDescriptor(aYSize, aCbCrSize, yOffset, cbOffset,
aCbCrSize, aCbCrStride, crOffset, aStereoMode, aYUVColorSpace,
yOffset, cbOffset, crOffset,
aStereoMode,
aYUVColorSpace,
aDepth,
hasIntermediateBuffer); hasIntermediateBuffer);
return CreateInternal(aAllocator ? aAllocator->GetTextureForwarder() return CreateInternal(aAllocator ? aAllocator->GetTextureForwarder() : nullptr, descriptor,
: nullptr, gfx::BackendType::NONE, bufSize, aTextureFlags);
descriptor,
gfx::BackendType::NONE,
bufSize,
aTextureFlags);
} }
void void
@ -270,12 +254,6 @@ BufferTextureData::GetYUVColorSpace() const
return ImageDataSerializer::YUVColorSpaceFromBufferDescriptor(mDescriptor); return ImageDataSerializer::YUVColorSpaceFromBufferDescriptor(mDescriptor);
} }
Maybe<uint32_t>
BufferTextureData::GetDepth() const
{
return ImageDataSerializer::DepthFromBufferDescriptor(mDescriptor);
}
Maybe<StereoMode> Maybe<StereoMode>
BufferTextureData::GetStereoMode() const BufferTextureData::GetStereoMode() const
{ {
@ -373,17 +351,17 @@ BufferTextureData::BorrowMappedYCbCrData(MappedYCbCrTextureData& aMap)
aMap.y.data = data + desc.yOffset(); aMap.y.data = data + desc.yOffset();
aMap.y.size = ySize; aMap.y.size = ySize;
aMap.y.stride = desc.yStride(); aMap.y.stride = ySize.width;
aMap.y.skip = 0; aMap.y.skip = 0;
aMap.cb.data = data + desc.cbOffset(); aMap.cb.data = data + desc.cbOffset();
aMap.cb.size = cbCrSize; aMap.cb.size = cbCrSize;
aMap.cb.stride = desc.cbCrStride(); aMap.cb.stride = cbCrSize.width;
aMap.cb.skip = 0; aMap.cb.skip = 0;
aMap.cr.data = data + desc.crOffset(); aMap.cr.data = data + desc.crOffset();
aMap.cr.size = cbCrSize; aMap.cr.size = cbCrSize;
aMap.cr.stride = desc.cbCrStride(); aMap.cr.stride = cbCrSize.width;
aMap.cr.skip = 0; aMap.cr.skip = 0;
return true; return true;

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

@ -30,12 +30,9 @@ public:
static BufferTextureData* CreateForYCbCr(KnowsCompositor* aAllocator, static BufferTextureData* CreateForYCbCr(KnowsCompositor* aAllocator,
gfx::IntSize aYSize, gfx::IntSize aYSize,
uint32_t aYStride,
gfx::IntSize aCbCrSize, gfx::IntSize aCbCrSize,
uint32_t aCbCrStride,
StereoMode aStereoMode, StereoMode aStereoMode,
YUVColorSpace aYUVColorSpace, YUVColorSpace aYUVColorSpace,
uint32_t aDepth,
TextureFlags aTextureFlags); TextureFlags aTextureFlags);
// It is generally better to use CreateForYCbCr instead. // It is generally better to use CreateForYCbCr instead.
@ -44,7 +41,6 @@ public:
static BufferTextureData* CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator, static BufferTextureData* CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
int32_t aSize, int32_t aSize,
YUVColorSpace aYUVColorSpace, YUVColorSpace aYUVColorSpace,
uint32_t aDepth,
TextureFlags aTextureFlags); TextureFlags aTextureFlags);
virtual bool Lock(OpenMode aMode) override { return true; } virtual bool Lock(OpenMode aMode) override { return true; }
@ -71,8 +67,6 @@ public:
Maybe<YUVColorSpace> GetYUVColorSpace() const; Maybe<YUVColorSpace> GetYUVColorSpace() const;
Maybe<uint32_t> GetDepth() const;
Maybe<StereoMode> GetStereoMode() const; Maybe<StereoMode> GetStereoMode() const;
protected: protected:

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

@ -161,16 +161,14 @@ struct EffectRGB : public TexturedEffect
struct EffectYCbCr : public TexturedEffect struct EffectYCbCr : public TexturedEffect
{ {
EffectYCbCr(TextureSource *aSource, YUVColorSpace aYUVColorSpace, uint32_t aDepth, gfx::SamplingFilter aSamplingFilter) EffectYCbCr(TextureSource *aSource, YUVColorSpace aYUVColorSpace, gfx::SamplingFilter aSamplingFilter)
: TexturedEffect(EffectTypes::YCBCR, aSource, false, aSamplingFilter) : TexturedEffect(EffectTypes::YCBCR, aSource, false, aSamplingFilter)
, mYUVColorSpace(aYUVColorSpace) , mYUVColorSpace(aYUVColorSpace)
, mDepth(aDepth)
{} {}
virtual const char* Name() { return "EffectYCbCr"; } virtual const char* Name() { return "EffectYCbCr"; }
YUVColorSpace mYUVColorSpace; YUVColorSpace mYUVColorSpace;
uint32_t mDepth;
}; };
struct EffectNV12 : public TexturedEffect struct EffectNV12 : public TexturedEffect
@ -272,8 +270,7 @@ CreateTexturedEffect(TextureHost* aHost,
RefPtr<TexturedEffect> result; RefPtr<TexturedEffect> result;
if (aHost->GetReadFormat() == gfx::SurfaceFormat::YUV) { if (aHost->GetReadFormat() == gfx::SurfaceFormat::YUV) {
MOZ_ASSERT(aHost->GetYUVColorSpace() != YUVColorSpace::UNKNOWN); MOZ_ASSERT(aHost->GetYUVColorSpace() != YUVColorSpace::UNKNOWN);
result = new EffectYCbCr( result = new EffectYCbCr(aSource, aHost->GetYUVColorSpace(), aSamplingFilter);
aSource, aHost->GetYUVColorSpace(), aHost->GetDepth(), aSamplingFilter);
} else { } else {
result = CreateTexturedEffect(aHost->GetReadFormat(), result = CreateTexturedEffect(aHost->GetReadFormat(),
aSource, aSource,

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

@ -71,12 +71,18 @@ ComputeYCbCrBufferSize(const gfx::IntSize& aYSize, int32_t aYStride,
!gfx::Factory::AllowedSurfaceSize(IntSize(aCbCrStride, aCbCrSize.height))) { !gfx::Factory::AllowedSurfaceSize(IntSize(aCbCrStride, aCbCrSize.height))) {
return 0; return 0;
} }
// Overflow checks are performed in AllowedSurfaceSize // Overflow checks are performed in AllowedSurfaceSize
return GetAlignedStride<4>(aYSize.height, aYStride) + return GetAlignedStride<4>(aYSize.height, aYStride) +
2 * GetAlignedStride<4>(aCbCrSize.height, aCbCrStride); 2 * GetAlignedStride<4>(aCbCrSize.height, aCbCrStride);
} }
// Minimum required shmem size in bytes
uint32_t
ComputeYCbCrBufferSize(const gfx::IntSize& aYSize, const gfx::IntSize& aCbCrSize)
{
return ComputeYCbCrBufferSize(aYSize, aYSize.width, aCbCrSize, aCbCrSize.width);
}
uint32_t uint32_t
ComputeYCbCrBufferSize(uint32_t aBufferSize) ComputeYCbCrBufferSize(uint32_t aBufferSize)
{ {
@ -130,6 +136,7 @@ Maybe<gfx::IntSize> CbCrSizeFromBufferDescriptor(const BufferDescriptor& aDescri
} }
Maybe<YUVColorSpace> YUVColorSpaceFromBufferDescriptor(const BufferDescriptor& aDescriptor) Maybe<YUVColorSpace> YUVColorSpaceFromBufferDescriptor(const BufferDescriptor& aDescriptor)
{
{ {
switch (aDescriptor.type()) { switch (aDescriptor.type()) {
case BufferDescriptor::TRGBDescriptor: case BufferDescriptor::TRGBDescriptor:
@ -137,20 +144,9 @@ Maybe<YUVColorSpace> YUVColorSpaceFromBufferDescriptor(const BufferDescriptor& a
case BufferDescriptor::TYCbCrDescriptor: case BufferDescriptor::TYCbCrDescriptor:
return Some(aDescriptor.get_YCbCrDescriptor().yUVColorSpace()); return Some(aDescriptor.get_YCbCrDescriptor().yUVColorSpace());
default: default:
MOZ_CRASH("GFX: YUVColorSpaceFromBufferDescriptor"); MOZ_CRASH("GFX: CbCrSizeFromBufferDescriptor");
} }
} }
Maybe<uint32_t> DepthFromBufferDescriptor(const BufferDescriptor& aDescriptor)
{
switch (aDescriptor.type()) {
case BufferDescriptor::TRGBDescriptor:
return Nothing();
case BufferDescriptor::TYCbCrDescriptor:
return Some(aDescriptor.get_YCbCrDescriptor().depth());
default:
MOZ_CRASH("GFX: DepthFromBufferDescriptor");
}
} }
Maybe<StereoMode> StereoModeFromBufferDescriptor(const BufferDescriptor& aDescriptor) Maybe<StereoMode> StereoModeFromBufferDescriptor(const BufferDescriptor& aDescriptor)
@ -161,7 +157,7 @@ Maybe<StereoMode> StereoModeFromBufferDescriptor(const BufferDescriptor& aDescri
case BufferDescriptor::TYCbCrDescriptor: case BufferDescriptor::TYCbCrDescriptor:
return Some(aDescriptor.get_YCbCrDescriptor().stereoMode()); return Some(aDescriptor.get_YCbCrDescriptor().stereoMode());
default: default:
MOZ_CRASH("GFX: StereoModeFromBufferDescriptor"); MOZ_CRASH("GFX: CbCrSizeFromBufferDescriptor");
} }
} }
@ -184,6 +180,9 @@ already_AddRefed<DataSourceSurface>
DataSourceSurfaceFromYCbCrDescriptor(uint8_t* aBuffer, const YCbCrDescriptor& aDescriptor, gfx::DataSourceSurface* aSurface) DataSourceSurfaceFromYCbCrDescriptor(uint8_t* aBuffer, const YCbCrDescriptor& aDescriptor, gfx::DataSourceSurface* aSurface)
{ {
gfx::IntSize ySize = aDescriptor.ySize(); gfx::IntSize ySize = aDescriptor.ySize();
gfx::IntSize cbCrSize = aDescriptor.cbCrSize();
int32_t yStride = ySize.width;
int32_t cbCrStride = cbCrSize.width;
RefPtr<DataSourceSurface> result; RefPtr<DataSourceSurface> result;
if (aSurface) { if (aSurface) {
@ -210,15 +209,14 @@ DataSourceSurfaceFromYCbCrDescriptor(uint8_t* aBuffer, const YCbCrDescriptor& aD
layers::PlanarYCbCrData ycbcrData; layers::PlanarYCbCrData ycbcrData;
ycbcrData.mYChannel = GetYChannel(aBuffer, aDescriptor); ycbcrData.mYChannel = GetYChannel(aBuffer, aDescriptor);
ycbcrData.mYStride = aDescriptor.yStride(); ycbcrData.mYStride = yStride;
ycbcrData.mYSize = ySize; ycbcrData.mYSize = ySize;
ycbcrData.mCbChannel = GetCbChannel(aBuffer, aDescriptor); ycbcrData.mCbChannel = GetCbChannel(aBuffer, aDescriptor);
ycbcrData.mCrChannel = GetCrChannel(aBuffer, aDescriptor); ycbcrData.mCrChannel = GetCrChannel(aBuffer, aDescriptor);
ycbcrData.mCbCrStride = aDescriptor.cbCrStride(); ycbcrData.mCbCrStride = cbCrStride;
ycbcrData.mCbCrSize = aDescriptor.cbCrSize(); ycbcrData.mCbCrSize = cbCrSize;
ycbcrData.mPicSize = ySize; ycbcrData.mPicSize = ySize;
ycbcrData.mYUVColorSpace = aDescriptor.yUVColorSpace(); ycbcrData.mYUVColorSpace = aDescriptor.yUVColorSpace();
ycbcrData.mDepth = aDescriptor.depth();
gfx::ConvertYCbCrToRGB(ycbcrData, gfx::ConvertYCbCrToRGB(ycbcrData,
gfx::SurfaceFormat::B8G8R8X8, gfx::SurfaceFormat::B8G8R8X8,
@ -239,18 +237,21 @@ ConvertAndScaleFromYCbCrDescriptor(uint8_t* aBuffer,
int32_t aStride) int32_t aStride)
{ {
MOZ_ASSERT(aBuffer); MOZ_ASSERT(aBuffer);
gfx::IntSize ySize = aDescriptor.ySize();
gfx::IntSize cbCrSize = aDescriptor.cbCrSize();
int32_t yStride = ySize.width;
int32_t cbCrStride = cbCrSize.width;
layers::PlanarYCbCrData ycbcrData; layers::PlanarYCbCrData ycbcrData;
ycbcrData.mYChannel = GetYChannel(aBuffer, aDescriptor); ycbcrData.mYChannel = GetYChannel(aBuffer, aDescriptor);
ycbcrData.mYStride = aDescriptor.yStride();; ycbcrData.mYStride = yStride;
ycbcrData.mYSize = aDescriptor.ySize(); ycbcrData.mYSize = ySize;
ycbcrData.mCbChannel = GetCbChannel(aBuffer, aDescriptor); ycbcrData.mCbChannel = GetCbChannel(aBuffer, aDescriptor);
ycbcrData.mCrChannel = GetCrChannel(aBuffer, aDescriptor); ycbcrData.mCrChannel = GetCrChannel(aBuffer, aDescriptor);
ycbcrData.mCbCrStride = aDescriptor.cbCrStride(); ycbcrData.mCbCrStride = cbCrStride;
ycbcrData.mCbCrSize = aDescriptor.cbCrSize(); ycbcrData.mCbCrSize = cbCrSize;
ycbcrData.mPicSize = aDescriptor.ySize(); ycbcrData.mPicSize = ySize;
ycbcrData.mYUVColorSpace = aDescriptor.yUVColorSpace(); ycbcrData.mYUVColorSpace = aDescriptor.yUVColorSpace();
ycbcrData.mDepth = aDescriptor.depth();
gfx::ConvertYCbCrToRGB(ycbcrData, aDestFormat, aDestSize, aDestBuffer, aStride); gfx::ConvertYCbCrToRGB(ycbcrData, aDestFormat, aDestSize, aDestBuffer, aStride);
} }

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

@ -45,6 +45,9 @@ uint32_t ComputeYCbCrBufferSize(const gfx::IntSize& aYSize,
int32_t aYStride, int32_t aYStride,
const gfx::IntSize& aCbCrSize, const gfx::IntSize& aCbCrSize,
int32_t aCbCrStride); int32_t aCbCrStride);
uint32_t ComputeYCbCrBufferSize(const gfx::IntSize& aYSize,
const gfx::IntSize& aCbCrSize);
uint32_t ComputeYCbCrBufferSize(uint32_t aBufferSize); uint32_t ComputeYCbCrBufferSize(uint32_t aBufferSize);
void ComputeYCbCrOffsets(int32_t yStride, int32_t yHeight, void ComputeYCbCrOffsets(int32_t yStride, int32_t yHeight,
@ -59,8 +62,6 @@ Maybe<gfx::IntSize> CbCrSizeFromBufferDescriptor(const BufferDescriptor& aDescri
Maybe<YUVColorSpace> YUVColorSpaceFromBufferDescriptor(const BufferDescriptor& aDescriptor); Maybe<YUVColorSpace> YUVColorSpaceFromBufferDescriptor(const BufferDescriptor& aDescriptor);
Maybe<uint32_t> DepthFromBufferDescriptor(const BufferDescriptor& aDescriptor);
Maybe<StereoMode> StereoModeFromBufferDescriptor(const BufferDescriptor& aDescriptor); Maybe<StereoMode> StereoModeFromBufferDescriptor(const BufferDescriptor& aDescriptor);
uint8_t* GetYChannel(uint8_t* aBuffer, const YCbCrDescriptor& aDescriptor); uint8_t* GetYChannel(uint8_t* aBuffer, const YCbCrDescriptor& aDescriptor);

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

@ -101,11 +101,8 @@ ImageClient::CreateTextureClientForImage(Image* aImage, KnowsCompositor* aForwar
return nullptr; return nullptr;
} }
texture = TextureClient::CreateForYCbCr(aForwarder, texture = TextureClient::CreateForYCbCr(aForwarder,
data->mYSize, data->mYStride, data->mYSize, data->mCbCrSize, data->mStereoMode,
data->mCbCrSize, data->mCbCrStride,
data->mStereoMode,
data->mYUVColorSpace, data->mYUVColorSpace,
data->mDepth,
TextureFlags::DEFAULT); TextureFlags::DEFAULT);
if (!texture) { if (!texture) {
return nullptr; return nullptr;

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

@ -1256,12 +1256,9 @@ TextureClient::CreateForRawBufferAccess(LayersIPCChannel* aAllocator,
already_AddRefed<TextureClient> already_AddRefed<TextureClient>
TextureClient::CreateForYCbCr(KnowsCompositor* aAllocator, TextureClient::CreateForYCbCr(KnowsCompositor* aAllocator,
gfx::IntSize aYSize, gfx::IntSize aYSize,
uint32_t aYStride,
gfx::IntSize aCbCrSize, gfx::IntSize aCbCrSize,
uint32_t aCbCrStride,
StereoMode aStereoMode, StereoMode aStereoMode,
YUVColorSpace aYUVColorSpace, YUVColorSpace aYUVColorSpace,
uint32_t aDepth,
TextureFlags aTextureFlags) TextureFlags aTextureFlags)
{ {
if (!aAllocator || !aAllocator->GetLayersIPCActor()->IPCOpen()) { if (!aAllocator || !aAllocator->GetLayersIPCActor()->IPCOpen()) {
@ -1272,12 +1269,9 @@ TextureClient::CreateForYCbCr(KnowsCompositor* aAllocator,
return nullptr; return nullptr;
} }
TextureData* data = TextureData* data = BufferTextureData::CreateForYCbCr(aAllocator, aYSize, aCbCrSize,
BufferTextureData::CreateForYCbCr(aAllocator, aStereoMode, aYUVColorSpace,
aYSize, aYStride, aTextureFlags);
aCbCrSize, aCbCrStride,
aStereoMode, aYUVColorSpace,
aDepth, aTextureFlags);
if (!data) { if (!data) {
return nullptr; return nullptr;
} }
@ -1291,15 +1285,15 @@ already_AddRefed<TextureClient>
TextureClient::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator, TextureClient::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
size_t aSize, size_t aSize,
YUVColorSpace aYUVColorSpace, YUVColorSpace aYUVColorSpace,
uint32_t aDepth,
TextureFlags aTextureFlags) TextureFlags aTextureFlags)
{ {
if (!aAllocator || !aAllocator->GetLayersIPCActor()->IPCOpen()) { if (!aAllocator || !aAllocator->GetLayersIPCActor()->IPCOpen()) {
return nullptr; return nullptr;
} }
TextureData* data = BufferTextureData::CreateForYCbCrWithBufferSize( TextureData* data =
aAllocator, aSize, aYUVColorSpace, aDepth, aTextureFlags); BufferTextureData::CreateForYCbCrWithBufferSize(aAllocator, aSize, aYUVColorSpace,
aTextureFlags);
if (!data) { if (!data) {
return nullptr; return nullptr;
} }
@ -1308,28 +1302,26 @@ TextureClient::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
aAllocator->GetTextureForwarder()); aAllocator->GetTextureForwarder());
} }
TextureClient::TextureClient(TextureData* aData, TextureClient::TextureClient(TextureData* aData, TextureFlags aFlags, LayersIPCChannel* aAllocator)
TextureFlags aFlags, : AtomicRefCountedWithFinalize("TextureClient")
LayersIPCChannel* aAllocator) , mAllocator(aAllocator)
: AtomicRefCountedWithFinalize("TextureClient") , mActor(nullptr)
, mAllocator(aAllocator) , mData(aData)
, mActor(nullptr) , mFlags(aFlags)
, mData(aData) , mOpenMode(OpenMode::OPEN_NONE)
, mFlags(aFlags)
, mOpenMode(OpenMode::OPEN_NONE)
#ifdef DEBUG #ifdef DEBUG
, mExpectedDtRefs(0) , mExpectedDtRefs(0)
#endif #endif
, mIsLocked(false) , mIsLocked(false)
, mIsReadLocked(false) , mIsReadLocked(false)
, mUpdated(false) , mUpdated(false)
, mAddedToCompositableClient(false) , mAddedToCompositableClient(false)
, mWorkaroundAnnoyingSharedSurfaceLifetimeIssues(false) , mWorkaroundAnnoyingSharedSurfaceLifetimeIssues(false)
, mWorkaroundAnnoyingSharedSurfaceOwnershipIssues(false) , mWorkaroundAnnoyingSharedSurfaceOwnershipIssues(false)
, mFwdTransactionId(0) , mFwdTransactionId(0)
, mSerial(++sSerialCounter) , mSerial(++sSerialCounter)
#ifdef GFX_DEBUG_TRACK_CLIENTS_IN_POOL #ifdef GFX_DEBUG_TRACK_CLIENTS_IN_POOL
, mPoolTracker(nullptr) , mPoolTracker(nullptr)
#endif #endif
{ {
mData->FillInfo(mInfo); mData->FillInfo(mInfo);
@ -1765,18 +1757,14 @@ UpdateYCbCrTextureClient(TextureClient* aTexture, const PlanarYCbCrData& aData)
srcData.y.size = aData.mYSize; srcData.y.size = aData.mYSize;
srcData.y.stride = aData.mYStride; srcData.y.stride = aData.mYStride;
srcData.y.skip = aData.mYSkip; srcData.y.skip = aData.mYSkip;
MOZ_ASSERT(aData.mDepth == 8 || (aData.mDepth > 8 && aData.mDepth <= 16));
srcData.y.bytesPerPixel = (aData.mDepth > 8) ? 2 : 1;
srcData.cb.data = aData.mCbChannel; srcData.cb.data = aData.mCbChannel;
srcData.cb.size = aData.mCbCrSize; srcData.cb.size = aData.mCbCrSize;
srcData.cb.stride = aData.mCbCrStride; srcData.cb.stride = aData.mCbCrStride;
srcData.cb.skip = aData.mCbSkip; srcData.cb.skip = aData.mCbSkip;
srcData.cb.bytesPerPixel = (aData.mDepth > 8) ? 2 : 1;
srcData.cr.data = aData.mCrChannel; srcData.cr.data = aData.mCrChannel;
srcData.cr.size = aData.mCbCrSize; srcData.cr.size = aData.mCbCrSize;
srcData.cr.stride = aData.mCbCrStride; srcData.cr.stride = aData.mCbCrStride;
srcData.cr.skip = aData.mCrSkip; srcData.cr.skip = aData.mCrSkip;
srcData.cr.bytesPerPixel = (aData.mDepth > 8) ? 2 : 1;
srcData.metadata = nullptr; srcData.metadata = nullptr;
if (!srcData.CopyInto(mapped)) { if (!srcData.CopyInto(mapped)) {
@ -1821,19 +1809,15 @@ MappedYCbCrChannelData::CopyInto(MappedYCbCrChannelData& aDst)
// fast-ish path // fast-ish path
memcpy(aDst.data + i * aDst.stride, memcpy(aDst.data + i * aDst.stride,
data + i * stride, data + i * stride,
size.width * bytesPerPixel); size.width);
} else { } else {
// slow path // slow path
uint8_t* src = data + i * stride; uint8_t* src = data + i * stride;
uint8_t* dst = aDst.data + i * aDst.stride; uint8_t* dst = aDst.data + i * aDst.stride;
for (int32_t j = 0; j < size.width; ++j) { for (int32_t j = 0; j < size.width; ++j) {
for (uint32_t k = 0; k < bytesPerPixel; ++k) { *dst = *src;
*dst = *src; src += 1 + skip;
src += 1; dst += 1 + aDst.skip;
dst += 1;
}
src += skip;
dst += aDst.skip;
} }
} }
} }

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

@ -139,7 +139,6 @@ struct MappedYCbCrChannelData
gfx::IntSize size; gfx::IntSize size;
int32_t stride; int32_t stride;
int32_t skip; int32_t skip;
uint32_t bytesPerPixel;
bool CopyInto(MappedYCbCrChannelData& aDst); bool CopyInto(MappedYCbCrChannelData& aDst);
}; };
@ -348,12 +347,9 @@ public:
static already_AddRefed<TextureClient> static already_AddRefed<TextureClient>
CreateForYCbCr(KnowsCompositor* aAllocator, CreateForYCbCr(KnowsCompositor* aAllocator,
gfx::IntSize aYSize, gfx::IntSize aYSize,
uint32_t aYStride,
gfx::IntSize aCbCrSize, gfx::IntSize aCbCrSize,
uint32_t aCbCrStride,
StereoMode aStereoMode, StereoMode aStereoMode,
YUVColorSpace aYUVColorSpace, YUVColorSpace aYUVColorSpace,
uint32_t aDepth,
TextureFlags aTextureFlags); TextureFlags aTextureFlags);
// Creates and allocates a TextureClient (can be accessed through raw // Creates and allocates a TextureClient (can be accessed through raw
@ -373,7 +369,6 @@ public:
CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator, CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
size_t aSize, size_t aSize,
YUVColorSpace aYUVColorSpace, YUVColorSpace aYUVColorSpace,
uint32_t aDepth,
TextureFlags aTextureFlags); TextureFlags aTextureFlags);
// Creates and allocates a TextureClient of the same type. // Creates and allocates a TextureClient of the same type.

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

@ -108,8 +108,6 @@ YCbCrTextureClientAllocationHelper::IsCompatible(TextureClient* aTextureClient)
bufferData->GetCbCrSize().ref() != mData.mCbCrSize || bufferData->GetCbCrSize().ref() != mData.mCbCrSize ||
bufferData->GetYUVColorSpace().isNothing() || bufferData->GetYUVColorSpace().isNothing() ||
bufferData->GetYUVColorSpace().ref() != mData.mYUVColorSpace || bufferData->GetYUVColorSpace().ref() != mData.mYUVColorSpace ||
bufferData->GetDepth().isNothing() ||
bufferData->GetDepth().ref() != mData.mDepth ||
bufferData->GetStereoMode().isNothing() || bufferData->GetStereoMode().isNothing() ||
bufferData->GetStereoMode().ref() != mData.mStereoMode) { bufferData->GetStereoMode().ref() != mData.mStereoMode) {
return false; return false;
@ -121,11 +119,9 @@ already_AddRefed<TextureClient>
YCbCrTextureClientAllocationHelper::Allocate(KnowsCompositor* aAllocator) YCbCrTextureClientAllocationHelper::Allocate(KnowsCompositor* aAllocator)
{ {
return TextureClient::CreateForYCbCr(aAllocator, return TextureClient::CreateForYCbCr(aAllocator,
mData.mYSize, mData.mYStride, mData.mYSize, mData.mCbCrSize,
mData.mCbCrSize, mData.mCbCrStride,
mData.mStereoMode, mData.mStereoMode,
mData.mYUVColorSpace, mData.mYUVColorSpace,
mData.mDepth,
mTextureFlags); mTextureFlags);
} }

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

@ -880,16 +880,6 @@ BufferTextureHost::GetYUVColorSpace() const
return YUVColorSpace::UNKNOWN; return YUVColorSpace::UNKNOWN;
} }
uint32_t
BufferTextureHost::GetDepth() const
{
if (mFormat == gfx::SurfaceFormat::YUV) {
const YCbCrDescriptor& desc = mDescriptor.get_YCbCrDescriptor();
return desc.depth();
}
return 8;
}
bool bool
BufferTextureHost::UploadIfNeeded() BufferTextureHost::UploadIfNeeded()
{ {
@ -996,19 +986,19 @@ BufferTextureHost::Upload(nsIntRegion *aRegion)
RefPtr<gfx::DataSourceSurface> tempY = RefPtr<gfx::DataSourceSurface> tempY =
gfx::Factory::CreateWrappingDataSourceSurface(ImageDataSerializer::GetYChannel(buf, desc), gfx::Factory::CreateWrappingDataSourceSurface(ImageDataSerializer::GetYChannel(buf, desc),
desc.yStride(), desc.ySize().width,
desc.ySize(), desc.ySize(),
SurfaceFormatForAlphaDepth(desc.depth())); gfx::SurfaceFormat::A8);
RefPtr<gfx::DataSourceSurface> tempCb = RefPtr<gfx::DataSourceSurface> tempCb =
gfx::Factory::CreateWrappingDataSourceSurface(ImageDataSerializer::GetCbChannel(buf, desc), gfx::Factory::CreateWrappingDataSourceSurface(ImageDataSerializer::GetCbChannel(buf, desc),
desc.cbCrStride(), desc.cbCrSize().width,
desc.cbCrSize(), desc.cbCrSize(),
SurfaceFormatForAlphaDepth(desc.depth())); gfx::SurfaceFormat::A8);
RefPtr<gfx::DataSourceSurface> tempCr = RefPtr<gfx::DataSourceSurface> tempCr =
gfx::Factory::CreateWrappingDataSourceSurface(ImageDataSerializer::GetCrChannel(buf, desc), gfx::Factory::CreateWrappingDataSourceSurface(ImageDataSerializer::GetCrChannel(buf, desc),
desc.cbCrStride(), desc.cbCrSize().width,
desc.cbCrSize(), desc.cbCrSize(),
SurfaceFormatForAlphaDepth(desc.depth())); gfx::SurfaceFormat::A8);
// We don't support partial updates for Y U V textures // We don't support partial updates for Y U V textures
NS_ASSERTION(!aRegion, "Unsupported partial updates for YCbCr textures"); NS_ASSERTION(!aRegion, "Unsupported partial updates for YCbCr textures");
if (!tempY || if (!tempY ||

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

@ -438,11 +438,6 @@ public:
virtual YUVColorSpace GetYUVColorSpace() const { return YUVColorSpace::UNKNOWN; } virtual YUVColorSpace GetYUVColorSpace() const { return YUVColorSpace::UNKNOWN; }
/**
* Return the bit depth of the image. Used with YUV textures.
*/
virtual uint32_t GetDepth() const { return 8; }
/** /**
* Called during the transaction. The TextureSource may or may not be composited. * Called during the transaction. The TextureSource may or may not be composited.
* *
@ -737,8 +732,6 @@ public:
virtual YUVColorSpace GetYUVColorSpace() const override; virtual YUVColorSpace GetYUVColorSpace() const override;
virtual uint32_t GetDepth() const override;
virtual gfx::IntSize GetSize() const override { return mSize; } virtual gfx::IntSize GetSize() const override { return mSize; }
virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override; virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override;

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

@ -100,15 +100,12 @@ struct RGBDescriptor {
struct YCbCrDescriptor { struct YCbCrDescriptor {
IntSize ySize; IntSize ySize;
uint32_t yStride;
IntSize cbCrSize; IntSize cbCrSize;
uint32_t cbCrStride;
uint32_t yOffset; uint32_t yOffset;
uint32_t cbOffset; uint32_t cbOffset;
uint32_t crOffset; uint32_t crOffset;
StereoMode stereoMode; StereoMode stereoMode;
YUVColorSpace yUVColorSpace; YUVColorSpace yUVColorSpace;
uint32_t depth;
bool hasIntermediateBuffer; bool hasIntermediateBuffer;
}; };

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

@ -113,21 +113,13 @@ SharedPlanarYCbCrImage::AdoptData(const Data& aData)
uint32_t crOffset = aData.mCrChannel - base; uint32_t crOffset = aData.mCrChannel - base;
auto fwd = mCompositable->GetForwarder(); auto fwd = mCompositable->GetForwarder();
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer( bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV,
gfx::SurfaceFormat::YUV, fwd->GetCompositorBackendType()); fwd->GetCompositorBackendType());
static_cast<BufferTextureData*>(mTextureClient->GetInternalData()) static_cast<BufferTextureData*>(mTextureClient->GetInternalData())->SetDesciptor(
->SetDesciptor(YCbCrDescriptor(aData.mYSize, YCbCrDescriptor(aData.mYSize, aData.mCbCrSize, yOffset, cbOffset, crOffset,
aData.mYStride, aData.mStereoMode, aData.mYUVColorSpace, hasIntermediateBuffer)
aData.mCbCrSize, );
aData.mCbCrStride,
yOffset,
cbOffset,
crOffset,
aData.mStereoMode,
aData.mYUVColorSpace,
aData.mDepth,
hasIntermediateBuffer));
return true; return true;
} }
@ -183,20 +175,18 @@ SharedPlanarYCbCrImage::Allocate(PlanarYCbCrData& aData)
mData.mPicSize = aData.mPicSize; mData.mPicSize = aData.mPicSize;
mData.mStereoMode = aData.mStereoMode; mData.mStereoMode = aData.mStereoMode;
mData.mYUVColorSpace = aData.mYUVColorSpace; mData.mYUVColorSpace = aData.mYUVColorSpace;
mData.mDepth = aData.mDepth;
// those members are not always equal to aData's, due to potentially different // those members are not always equal to aData's, due to potentially different
// packing. // packing.
mData.mYSkip = 0; mData.mYSkip = 0;
mData.mCbSkip = 0; mData.mCbSkip = 0;
mData.mCrSkip = 0; mData.mCrSkip = 0;
mData.mYStride = aData.mYStride; mData.mYStride = mData.mYSize.width;
mData.mCbCrStride = aData.mCbCrStride; mData.mCbCrStride = mData.mCbCrSize.width;
// do not set mBuffer like in PlanarYCbCrImage because the later // do not set mBuffer like in PlanarYCbCrImage because the later
// will try to manage this memory without knowing it belongs to a // will try to manage this memory without knowing it belongs to a
// shmem. // shmem.
mBufferSize = ImageDataSerializer::ComputeYCbCrBufferSize( mBufferSize = ImageDataSerializer::ComputeYCbCrBufferSize(mData.mYSize, mData.mCbCrSize);
mData.mYSize, mData.mYStride, mData.mCbCrSize, mData.mCbCrStride);
mSize = mData.mPicSize; mSize = mData.mPicSize;
mOrigin = gfx::IntPoint(aData.mPicX, aData.mPicY); mOrigin = gfx::IntPoint(aData.mPicX, aData.mPicY);

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

@ -262,7 +262,6 @@ TEST(Layers, TextureYCbCrSerialization) {
clientData.mCbCrStride = cbSurface->Stride(); clientData.mCbCrStride = cbSurface->Stride();
clientData.mStereoMode = StereoMode::MONO; clientData.mStereoMode = StereoMode::MONO;
clientData.mYUVColorSpace = YUVColorSpace::BT601; clientData.mYUVColorSpace = YUVColorSpace::BT601;
clientData.mDepth = 8;
clientData.mYSkip = 0; clientData.mYSkip = 0;
clientData.mCbSkip = 0; clientData.mCbSkip = 0;
clientData.mCrSkip = 0; clientData.mCrSkip = 0;
@ -291,9 +290,9 @@ TEST(Layers, TextureYCbCrSerialization) {
return; return;
} }
RefPtr<TextureClient> client = TextureClient::CreateForYCbCr(imageBridge, clientData.mYSize, clientData.mYStride, clientData.mCbCrSize, clientData.mCbCrStride, RefPtr<TextureClient> client = TextureClient::CreateForYCbCr(imageBridge, clientData.mYSize, clientData.mCbCrSize,
StereoMode::MONO, YUVColorSpace::BT601, StereoMode::MONO, YUVColorSpace::BT601,
8, TextureFlags::DEALLOCATE_CLIENT); TextureFlags::DEALLOCATE_CLIENT);
TestTextureClientYCbCr(client, clientData); TestTextureClientYCbCr(client, clientData);

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

@ -62,14 +62,9 @@ CreateYCbCrTextureClientWithBackend(LayersBackend aLayersBackend)
// Create YCbCrTexture for basice backend. // Create YCbCrTexture for basice backend.
if (aLayersBackend == LayersBackend::LAYERS_BASIC) { if (aLayersBackend == LayersBackend::LAYERS_BASIC) {
return TextureClient::CreateForYCbCr(nullptr, return TextureClient::CreateForYCbCr(nullptr, clientData.mYSize,
clientData.mYSize, clientData.mCbCrSize, StereoMode::MONO,
clientData.mYStride,
clientData.mCbCrSize,
clientData.mCbCrStride,
StereoMode::MONO,
YUVColorSpace::BT601, YUVColorSpace::BT601,
8,
TextureFlags::DEALLOCATE_CLIENT); TextureFlags::DEALLOCATE_CLIENT);
} }