зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1238558 (part 1) - Add Decoder::BeforeFinishInternal(). r=tnikkel.
--HG-- extra : rebase_source : 613a2ce0931b8b6c67d93e4d55e965193bbb55d0
This commit is contained in:
Родитель
77c63240e3
Коммит
8c0fc6309a
|
@ -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:
|
||||
|
|
Загрузка…
Ссылка в новой задаче