mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 15:58:39 +09:00
Issue #2546 - Part 3: Remove mapDataInto
This commit is contained in:
parent
2b8d75e136
commit
1bc0eda791
6 changed files with 2 additions and 377 deletions
|
|
@ -118,38 +118,6 @@ public:
|
|||
return (uint32_t)(size.height * stride);
|
||||
}
|
||||
|
||||
virtual UniquePtr<ImagePixelLayout>
|
||||
MapDataInto(uint8_t* aBuffer,
|
||||
uint32_t aOffset,
|
||||
uint32_t aBufferLength,
|
||||
ImageBitmapFormat aFormat,
|
||||
ErrorResult& aRv) const
|
||||
{
|
||||
DataSourceSurface::ScopedMap map(Surface(), DataSourceSurface::READ);
|
||||
if (!map.IsMapped()) {
|
||||
aRv.Throw(NS_ERROR_ILLEGAL_VALUE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Copy or convert data.
|
||||
UniquePtr<ImagePixelLayout> srcLayout =
|
||||
CreateDefaultPixelLayout(GetFormat(), Surface()->GetSize().width,
|
||||
Surface()->GetSize().height, map.GetStride());
|
||||
|
||||
// Prepare destination buffer.
|
||||
uint8_t* dstBuffer = aBuffer + aOffset;
|
||||
UniquePtr<ImagePixelLayout> dstLayout =
|
||||
CopyAndConvertImageData(GetFormat(), map.GetData(), srcLayout.get(),
|
||||
aFormat, dstBuffer);
|
||||
|
||||
if (!dstLayout) {
|
||||
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return dstLayout;
|
||||
}
|
||||
|
||||
protected:
|
||||
Impl() {}
|
||||
|
||||
|
|
@ -197,32 +165,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
UniquePtr<ImagePixelLayout>
|
||||
MapDataInto(uint8_t* aBuffer,
|
||||
uint32_t aOffset,
|
||||
uint32_t aBufferLength,
|
||||
ImageBitmapFormat aFormat,
|
||||
ErrorResult& aRv) const override
|
||||
{
|
||||
// Prepare source buffer and pixel layout.
|
||||
const PlanarYCbCrData* data = GetPlanarYCbCrData();
|
||||
|
||||
UniquePtr<ImagePixelLayout> srcLayout =
|
||||
CreatePixelLayoutFromPlanarYCbCrData(data);
|
||||
|
||||
// Do conversion.
|
||||
UniquePtr<ImagePixelLayout> dstLayout =
|
||||
CopyAndConvertImageData(GetFormat(), data->mYChannel, srcLayout.get(),
|
||||
aFormat, aBuffer+aOffset);
|
||||
|
||||
if (!dstLayout) {
|
||||
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return dstLayout;
|
||||
}
|
||||
|
||||
private:
|
||||
const PlanarYCbCrData* GetPlanarYCbCrData() const
|
||||
{
|
||||
|
|
@ -274,17 +216,5 @@ ImageUtils::GetBufferLength() const
|
|||
return mImpl->GetBufferLength();
|
||||
}
|
||||
|
||||
UniquePtr<ImagePixelLayout>
|
||||
ImageUtils::MapDataInto(uint8_t* aBuffer,
|
||||
uint32_t aOffset,
|
||||
uint32_t aBufferLength,
|
||||
ImageBitmapFormat aFormat,
|
||||
ErrorResult& aRv) const
|
||||
{
|
||||
MOZ_ASSERT(mImpl);
|
||||
MOZ_ASSERT(aBuffer, "Map data into a null buffer.");
|
||||
return mImpl->MapDataInto(aBuffer, aOffset, aBufferLength, aFormat, aRv);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue