diff --git a/image/Downscaler.cpp b/image/Downscaler.cpp index d83141b93e84..d44e6b8a9c2c 100644 --- a/image/Downscaler.cpp +++ b/image/Downscaler.cpp @@ -74,8 +74,8 @@ Downscaler::BeginFrame(const nsIntSize& aOriginalSize, mFrameRect = aFrameRect.valueOr(nsIntRect(nsIntPoint(), aOriginalSize)); MOZ_ASSERT(mFrameRect.x >= 0 && mFrameRect.y >= 0 && - mFrameRect.width > 0 && mFrameRect.height > 0, - "Frame rect must have positive components"); + mFrameRect.width >= 0 && mFrameRect.height >= 0, + "Frame rect must have non-negative components"); MOZ_ASSERT(nsIntRect(0, 0, aOriginalSize.width, aOriginalSize.height) .Contains(mFrameRect), "Frame rect must fit inside image"); @@ -159,8 +159,13 @@ Downscaler::ResetForNextProgressivePass() mCurrentInLine = 0; mLinesInBuffer = 0; - // If we have a vertical offset, commit rows to shift us past it. - SkipToRow(mFrameRect.y); + if (mFrameRect.IsEmpty()) { + // Our frame rect is zero size; commit rows until the end of the image. + SkipToRow(mOriginalSize.height - 1); + } else { + // If we have a vertical offset, commit rows to shift us past it. + SkipToRow(mFrameRect.y); + } } static void diff --git a/image/Downscaler.h b/image/Downscaler.h index e2942cc43e31..64ab1fe91137 100644 --- a/image/Downscaler.h +++ b/image/Downscaler.h @@ -83,6 +83,8 @@ public: bool aHasAlpha, bool aFlipVertically = false); + bool IsFrameComplete() const { return mCurrentInLine >= mOriginalSize.height; } + /// Retrieves the buffer into which the Decoder should write each row. uint8_t* RowBuffer() { @@ -161,6 +163,7 @@ public: return NS_ERROR_FAILURE; } + bool IsFrameComplete() const { return false; } uint8_t* RowBuffer() { return nullptr; } void ClearRow(uint32_t = 0) { } void CommitRow() { }