mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1238558 (part 1) - Add Decoder::BeforeFinishInternal(). r=tnikkel.
This commit is contained in:
parent
ef4157031e
commit
506abe122b
@ -190,6 +190,7 @@ void
|
||||
Decoder::CompleteDecode()
|
||||
{
|
||||
// Implementation-specific finalization
|
||||
BeforeFinishInternal();
|
||||
if (!HasError()) {
|
||||
FinishInternal();
|
||||
} else {
|
||||
@ -393,6 +394,7 @@ Decoder::AllocateFrameInternal(uint32_t aFrameNum,
|
||||
*/
|
||||
|
||||
void Decoder::InitInternal() { }
|
||||
void Decoder::BeforeFinishInternal() { }
|
||||
void Decoder::FinishInternal() { }
|
||||
void Decoder::FinishWithErrorInternal() { }
|
||||
|
||||
|
@ -283,9 +283,14 @@ protected:
|
||||
/*
|
||||
* Internal hooks. Decoder implementations may override these and
|
||||
* only these methods.
|
||||
*
|
||||
* BeforeFinishInternal() can be used to detect if decoding is in an
|
||||
* incomplete state, e.g. due to file truncation, in which case it should
|
||||
* call PostDataError().
|
||||
*/
|
||||
virtual void InitInternal();
|
||||
virtual void WriteInternal(const char* aBuffer, uint32_t aCount) = 0;
|
||||
virtual void BeforeFinishInternal();
|
||||
virtual void FinishInternal();
|
||||
virtual void FinishWithErrorInternal();
|
||||
|
||||
|
@ -220,6 +220,14 @@ nsBMPDecoder::GetCompressedImageSize() const
|
||||
: mH.mImageSize;
|
||||
}
|
||||
|
||||
void
|
||||
nsBMPDecoder::BeforeFinishInternal()
|
||||
{
|
||||
if (!IsMetadataDecode() && !mImageData) {
|
||||
PostDataError();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsBMPDecoder::FinishInternal()
|
||||
{
|
||||
@ -232,17 +240,18 @@ nsBMPDecoder::FinishInternal()
|
||||
// Send notifications if appropriate.
|
||||
if (!IsMetadataDecode() && HasSize()) {
|
||||
|
||||
// We should have image data.
|
||||
MOZ_ASSERT(mImageData);
|
||||
|
||||
// If it was truncated, fill in the missing pixels as black.
|
||||
if (mImageData) {
|
||||
while (mCurrentRow > 0) {
|
||||
uint32_t* dst = RowBuffer();
|
||||
while (mCurrentPos < mH.mWidth) {
|
||||
SetPixel(dst, 0, 0, 0);
|
||||
mCurrentPos++;
|
||||
}
|
||||
mCurrentPos = 0;
|
||||
FinishRow();
|
||||
while (mCurrentRow > 0) {
|
||||
uint32_t* dst = RowBuffer();
|
||||
while (mCurrentPos < mH.mWidth) {
|
||||
SetPixel(dst, 0, 0, 0);
|
||||
mCurrentPos++;
|
||||
}
|
||||
mCurrentPos = 0;
|
||||
FinishRow();
|
||||
}
|
||||
|
||||
// Invalidate.
|
||||
@ -492,7 +501,7 @@ nsBMPDecoder::ReadInfoHeaderSize(const char* aData, size_t aLength)
|
||||
PostDataError();
|
||||
return Transition::TerminateFailure();
|
||||
}
|
||||
// ICO BMPs must have a WinVMPv3 header. nsICODecoder should have already
|
||||
// ICO BMPs must have a WinBMPv3 header. nsICODecoder should have already
|
||||
// terminated decoding if this isn't the case.
|
||||
MOZ_ASSERT_IF(mIsWithinICO, mH.mBIHSize == InfoHeaderLength::WIN_V3);
|
||||
|
||||
|
@ -151,6 +151,7 @@ public:
|
||||
|
||||
virtual void WriteInternal(const char* aBuffer,
|
||||
uint32_t aCount) override;
|
||||
virtual void BeforeFinishInternal() override;
|
||||
virtual void FinishInternal() override;
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user