diff --git a/modules/libpr0n/decoders/nsBMPDecoder.cpp b/modules/libpr0n/decoders/nsBMPDecoder.cpp index 9ec2339af6a..47ca66e608f 100644 --- a/modules/libpr0n/decoders/nsBMPDecoder.cpp +++ b/modules/libpr0n/decoders/nsBMPDecoder.cpp @@ -584,15 +584,12 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) const PRUint32 rows = mOldLine - mCurLine; if (rows) { + + // Invalidate nsIntRect r(0, mBIH.height < 0 ? -mBIH.height - mOldLine : mCurLine, mBIH.width, rows); + PostInvalidation(r); - // Tell the image that its data has been updated - rv = mImage->FrameUpdated(0, r); - NS_ENSURE_SUCCESS(rv, rv); - - if (mObserver) - mObserver->OnDataAvailable(nsnull, PR_TRUE, &r); mOldLine = mCurLine; } diff --git a/modules/libpr0n/decoders/nsGIFDecoder2.cpp b/modules/libpr0n/decoders/nsGIFDecoder2.cpp index 015a8efa88f..3acc2ba6790 100644 --- a/modules/libpr0n/decoders/nsGIFDecoder2.cpp +++ b/modules/libpr0n/decoders/nsGIFDecoder2.cpp @@ -163,19 +163,8 @@ nsresult nsGIFDecoder2::FlushImageData(PRUint32 fromRow, PRUint32 rows) { nsIntRect r(mGIFStruct.x_offset, mGIFStruct.y_offset + fromRow, mGIFStruct.width, rows); + PostInvalidation(r); - // Update image - nsresult rv = mImage->FrameUpdated(mGIFStruct.images_decoded, r); - if (NS_FAILED(rv)) { - return rv; - } - - // Offset to the frame position - // Only notify observer(s) for first frame - if (!mGIFStruct.images_decoded && mObserver) { - PRUint32 imgCurFrame = mImage->GetCurrentFrameIndex(); - mObserver->OnDataAvailable(nsnull, imgCurFrame == PRUint32(mGIFStruct.images_decoded), &r); - } return NS_OK; } @@ -285,22 +274,6 @@ void nsGIFDecoder2::EndGIF(PRBool aSuccess) //****************************************************************************** nsresult nsGIFDecoder2::BeginImageFrame(gfx_depth aDepth) { - if (!mGIFStruct.images_decoded) { - // Send a onetime OnDataAvailable (Display Refresh) for the first frame - // if it has a y-axis offset. Otherwise, the area may never be refreshed - // and the placeholder will remain on the screen. (Bug 37589) - if (mGIFStruct.y_offset > 0) { - PRInt32 imgWidth; - mImage->GetWidth(&imgWidth); - PRUint32 imgCurFrame = mImage->GetCurrentFrameIndex(); - nsIntRect r(0, 0, imgWidth, mGIFStruct.y_offset); - if (mObserver) - mObserver->OnDataAvailable(nsnull, - imgCurFrame == PRUint32(mGIFStruct.images_decoded), - &r); - } - } - PRUint32 imageDataLength; nsresult rv; gfxASurface::gfxImageFormat format; @@ -333,6 +306,18 @@ nsresult nsGIFDecoder2::BeginImageFrame(gfx_depth aDepth) // Tell the superclass we're starting a frame PostFrameStart(); + if (!mGIFStruct.images_decoded) { + // Send a onetime invalidation for the first frame if it has a y-axis offset. + // Otherwise, the area may never be refreshed and the placeholder will remain + // on the screen. (Bug 37589) + if (mGIFStruct.y_offset > 0) { + PRInt32 imgWidth; + mImage->GetWidth(&imgWidth); + nsIntRect r(0, 0, imgWidth, mGIFStruct.y_offset); + PostInvalidation(r); + } + } + mCurrentFrame = mGIFStruct.images_decoded; return NS_OK; } @@ -346,19 +331,15 @@ void nsGIFDecoder2::EndImageFrame() // Only need to flush first frame (void) FlushImageData(); - // If the first frame is smaller in height than the entire image, send a - // OnDataAvailable (Display Refresh) for the area it does not have data for. + // If the first frame is smaller in height than the entire image, send an + // invalidation for the area it does not have data for. // This will clear the remaining bits of the placeholder. (Bug 37589) const PRUint32 realFrameHeight = mGIFStruct.height + mGIFStruct.y_offset; if (realFrameHeight < mGIFStruct.screen_height) { - PRUint32 imgCurFrame = mImage->GetCurrentFrameIndex(); nsIntRect r(0, realFrameHeight, mGIFStruct.screen_width, mGIFStruct.screen_height - realFrameHeight); - if (mObserver) - mObserver->OnDataAvailable(nsnull, - imgCurFrame == PRUint32(mGIFStruct.images_decoded), - &r); + PostInvalidation(r); } // This transparency check is only valid for first frame if (mGIFStruct.is_transparent && !mSawTransparency) { diff --git a/modules/libpr0n/decoders/nsICODecoder.cpp b/modules/libpr0n/decoders/nsICODecoder.cpp index 338a58e483b..ff1bfc17055 100644 --- a/modules/libpr0n/decoders/nsICODecoder.cpp +++ b/modules/libpr0n/decoders/nsICODecoder.cpp @@ -121,14 +121,11 @@ nsICODecoder::FinishInternal() // Send notifications if appropriate if (!IsSizeDecode() && !mError && (GetFrameCount() == 1)) { - // Tell the image that it's data has been updated + + // Invalidate nsIntRect r(0, 0, mDirEntry.mWidth, mDirEntry.mHeight); - rv = mImage->FrameUpdated(0, r); + PostInvalidation(r); - - if (mObserver) { - mObserver->OnDataAvailable(nsnull, PR_TRUE, &r); - } PostFrameStop(); mImage->DecodingComplete(); if (mObserver) { diff --git a/modules/libpr0n/decoders/nsIconDecoder.cpp b/modules/libpr0n/decoders/nsIconDecoder.cpp index f76e973a440..32ca8e52493 100644 --- a/modules/libpr0n/decoders/nsIconDecoder.cpp +++ b/modules/libpr0n/decoders/nsIconDecoder.cpp @@ -154,14 +154,8 @@ nsIconDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) // Copy the bytes memcpy(mImageData + mPixBytesRead, aBuffer, bytesToRead); - // Notify - rv = mImage->FrameUpdated(0, r); - if (NS_FAILED(rv)) { - mState = iconStateError; - return rv; - } - if (mObserver) - mObserver->OnDataAvailable(nsnull, PR_TRUE, &r); + // Invalidate + PostInvalidation(r); // Book Keeping aBuffer += bytesToRead; diff --git a/modules/libpr0n/decoders/nsJPEGDecoder.cpp b/modules/libpr0n/decoders/nsJPEGDecoder.cpp index 6649dd99443..d78c6b3781d 100644 --- a/modules/libpr0n/decoders/nsJPEGDecoder.cpp +++ b/modules/libpr0n/decoders/nsJPEGDecoder.cpp @@ -674,9 +674,7 @@ nsJPEGDecoder::OutputScanlines(PRBool* suspend) if (top != mInfo.output_scanline) { nsIntRect r(0, top, mInfo.output_width, mInfo.output_scanline-top); - rv = mImage->FrameUpdated(0, r); - if (mObserver) - mObserver->OnDataAvailable(nsnull, PR_TRUE, &r); + PostInvalidation(r); } return rv; diff --git a/modules/libpr0n/decoders/nsPNGDecoder.cpp b/modules/libpr0n/decoders/nsPNGDecoder.cpp index 5550d92843d..1678299dcee 100644 --- a/modules/libpr0n/decoders/nsPNGDecoder.cpp +++ b/modules/libpr0n/decoders/nsPNGDecoder.cpp @@ -204,14 +204,7 @@ void nsPNGDecoder::EndImageFrame() if (mFrameHasNoAlpha) mImage->SetFrameHasNoAlpha(numFrames - 1); - if (NS_FAILED(mImage->FrameUpdated(numFrames - 1, mFrameRect))) { - mError = PR_TRUE; - // allow the call out to the observers. - } - PRUint32 curFrame = mImage->GetCurrentFrameIndex(); - if (mObserver) - mObserver->OnDataAvailable(nsnull, curFrame == numFrames - 1, - &mFrameRect); + PostInvalidation(mFrameRect); } #endif @@ -809,15 +802,9 @@ nsPNGDecoder::row_callback(png_structp png_ptr, png_bytep new_row, PRUint32 numFrames = decoder->mImage->GetNumFrames(); if (numFrames <= 1) { // Only do incremental image display for the first frame + // XXXbholley - this check should be handled in the superclass nsIntRect r(0, row_num, width, 1); - if (NS_FAILED(decoder->mImage->FrameUpdated(numFrames - 1, r))) { - decoder->mError = PR_TRUE; /* bail */ - return; - } - PRUint32 curFrame = decoder->mImage->GetCurrentFrameIndex(); - if (decoder->mObserver) - decoder->mObserver->OnDataAvailable(nsnull, - curFrame == numFrames - 1, &r); + decoder->PostInvalidation(r); } } } diff --git a/modules/libpr0n/src/RasterImage.cpp b/modules/libpr0n/src/RasterImage.cpp index bff7a18e0b8..b61a549c1e8 100644 --- a/modules/libpr0n/src/RasterImage.cpp +++ b/modules/libpr0n/src/RasterImage.cpp @@ -927,7 +927,7 @@ RasterImage::EnsureCleanFrame(PRUint32 aFrameNum, PRInt32 aX, PRInt32 aY, } -nsresult +void RasterImage::FrameUpdated(PRUint32 aFrameNum, nsIntRect &aUpdatedRect) { NS_ABORT_IF_FALSE(aFrameNum < mFrames.Length(), "Invalid frame index!"); @@ -936,10 +936,6 @@ RasterImage::FrameUpdated(PRUint32 aFrameNum, nsIntRect &aUpdatedRect) NS_ABORT_IF_FALSE(frame, "Calling FrameUpdated on frame that doesn't exist!"); frame->ImageUpdated(aUpdatedRect); - - // XXXbholley - this should turn into a void method as soon the decoders - // stop using it - return NS_OK; } nsresult diff --git a/modules/libpr0n/src/RasterImage.h b/modules/libpr0n/src/RasterImage.h index c808174d112..56db7a2f799 100644 --- a/modules/libpr0n/src/RasterImage.h +++ b/modules/libpr0n/src/RasterImage.h @@ -226,7 +226,7 @@ public: PRUint32** paletteData, PRUint32* paletteLength); - nsresult FrameUpdated(PRUint32 aFrameNum, nsIntRect& aUpdatedRect); + void FrameUpdated(PRUint32 aFrameNum, nsIntRect& aUpdatedRect); /* notification when the current frame is done decoding */ nsresult EndFrameDecode(PRUint32 aFrameNum);