зеркало из https://github.com/mozilla/pjs.git
Bug 590252 - part 2 - Make decoder implementations use the Decoder superclass invalidation framework.r=joe,a=blocker
This commit is contained in:
Родитель
a729dbab9c
Коммит
4e88f86536
|
@ -584,15 +584,12 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
|
||||||
|
|
||||||
const PRUint32 rows = mOldLine - mCurLine;
|
const PRUint32 rows = mOldLine - mCurLine;
|
||||||
if (rows) {
|
if (rows) {
|
||||||
|
|
||||||
|
// Invalidate
|
||||||
nsIntRect r(0, mBIH.height < 0 ? -mBIH.height - mOldLine : mCurLine,
|
nsIntRect r(0, mBIH.height < 0 ? -mBIH.height - mOldLine : mCurLine,
|
||||||
mBIH.width, rows);
|
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;
|
mOldLine = mCurLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,19 +163,8 @@ nsresult
|
||||||
nsGIFDecoder2::FlushImageData(PRUint32 fromRow, PRUint32 rows)
|
nsGIFDecoder2::FlushImageData(PRUint32 fromRow, PRUint32 rows)
|
||||||
{
|
{
|
||||||
nsIntRect r(mGIFStruct.x_offset, mGIFStruct.y_offset + fromRow, mGIFStruct.width, 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;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,22 +274,6 @@ void nsGIFDecoder2::EndGIF(PRBool aSuccess)
|
||||||
//******************************************************************************
|
//******************************************************************************
|
||||||
nsresult nsGIFDecoder2::BeginImageFrame(gfx_depth aDepth)
|
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;
|
PRUint32 imageDataLength;
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
gfxASurface::gfxImageFormat format;
|
gfxASurface::gfxImageFormat format;
|
||||||
|
@ -333,6 +306,18 @@ nsresult nsGIFDecoder2::BeginImageFrame(gfx_depth aDepth)
|
||||||
// Tell the superclass we're starting a frame
|
// Tell the superclass we're starting a frame
|
||||||
PostFrameStart();
|
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;
|
mCurrentFrame = mGIFStruct.images_decoded;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -346,19 +331,15 @@ void nsGIFDecoder2::EndImageFrame()
|
||||||
// Only need to flush first frame
|
// Only need to flush first frame
|
||||||
(void) FlushImageData();
|
(void) FlushImageData();
|
||||||
|
|
||||||
// If the first frame is smaller in height than the entire image, send a
|
// If the first frame is smaller in height than the entire image, send an
|
||||||
// OnDataAvailable (Display Refresh) for the area it does not have data for.
|
// invalidation for the area it does not have data for.
|
||||||
// This will clear the remaining bits of the placeholder. (Bug 37589)
|
// This will clear the remaining bits of the placeholder. (Bug 37589)
|
||||||
const PRUint32 realFrameHeight = mGIFStruct.height + mGIFStruct.y_offset;
|
const PRUint32 realFrameHeight = mGIFStruct.height + mGIFStruct.y_offset;
|
||||||
if (realFrameHeight < mGIFStruct.screen_height) {
|
if (realFrameHeight < mGIFStruct.screen_height) {
|
||||||
PRUint32 imgCurFrame = mImage->GetCurrentFrameIndex();
|
|
||||||
nsIntRect r(0, realFrameHeight,
|
nsIntRect r(0, realFrameHeight,
|
||||||
mGIFStruct.screen_width,
|
mGIFStruct.screen_width,
|
||||||
mGIFStruct.screen_height - realFrameHeight);
|
mGIFStruct.screen_height - realFrameHeight);
|
||||||
if (mObserver)
|
PostInvalidation(r);
|
||||||
mObserver->OnDataAvailable(nsnull,
|
|
||||||
imgCurFrame == PRUint32(mGIFStruct.images_decoded),
|
|
||||||
&r);
|
|
||||||
}
|
}
|
||||||
// This transparency check is only valid for first frame
|
// This transparency check is only valid for first frame
|
||||||
if (mGIFStruct.is_transparent && !mSawTransparency) {
|
if (mGIFStruct.is_transparent && !mSawTransparency) {
|
||||||
|
|
|
@ -121,14 +121,11 @@ nsICODecoder::FinishInternal()
|
||||||
|
|
||||||
// Send notifications if appropriate
|
// Send notifications if appropriate
|
||||||
if (!IsSizeDecode() && !mError && (GetFrameCount() == 1)) {
|
if (!IsSizeDecode() && !mError && (GetFrameCount() == 1)) {
|
||||||
// Tell the image that it's data has been updated
|
|
||||||
|
// Invalidate
|
||||||
nsIntRect r(0, 0, mDirEntry.mWidth, mDirEntry.mHeight);
|
nsIntRect r(0, 0, mDirEntry.mWidth, mDirEntry.mHeight);
|
||||||
rv = mImage->FrameUpdated(0, r);
|
PostInvalidation(r);
|
||||||
|
|
||||||
|
|
||||||
if (mObserver) {
|
|
||||||
mObserver->OnDataAvailable(nsnull, PR_TRUE, &r);
|
|
||||||
}
|
|
||||||
PostFrameStop();
|
PostFrameStop();
|
||||||
mImage->DecodingComplete();
|
mImage->DecodingComplete();
|
||||||
if (mObserver) {
|
if (mObserver) {
|
||||||
|
|
|
@ -154,14 +154,8 @@ nsIconDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount)
|
||||||
// Copy the bytes
|
// Copy the bytes
|
||||||
memcpy(mImageData + mPixBytesRead, aBuffer, bytesToRead);
|
memcpy(mImageData + mPixBytesRead, aBuffer, bytesToRead);
|
||||||
|
|
||||||
// Notify
|
// Invalidate
|
||||||
rv = mImage->FrameUpdated(0, r);
|
PostInvalidation(r);
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
mState = iconStateError;
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
if (mObserver)
|
|
||||||
mObserver->OnDataAvailable(nsnull, PR_TRUE, &r);
|
|
||||||
|
|
||||||
// Book Keeping
|
// Book Keeping
|
||||||
aBuffer += bytesToRead;
|
aBuffer += bytesToRead;
|
||||||
|
|
|
@ -674,9 +674,7 @@ nsJPEGDecoder::OutputScanlines(PRBool* suspend)
|
||||||
|
|
||||||
if (top != mInfo.output_scanline) {
|
if (top != mInfo.output_scanline) {
|
||||||
nsIntRect r(0, top, mInfo.output_width, mInfo.output_scanline-top);
|
nsIntRect r(0, top, mInfo.output_width, mInfo.output_scanline-top);
|
||||||
rv = mImage->FrameUpdated(0, r);
|
PostInvalidation(r);
|
||||||
if (mObserver)
|
|
||||||
mObserver->OnDataAvailable(nsnull, PR_TRUE, &r);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
|
|
@ -204,14 +204,7 @@ void nsPNGDecoder::EndImageFrame()
|
||||||
if (mFrameHasNoAlpha)
|
if (mFrameHasNoAlpha)
|
||||||
mImage->SetFrameHasNoAlpha(numFrames - 1);
|
mImage->SetFrameHasNoAlpha(numFrames - 1);
|
||||||
|
|
||||||
if (NS_FAILED(mImage->FrameUpdated(numFrames - 1, mFrameRect))) {
|
PostInvalidation(mFrameRect);
|
||||||
mError = PR_TRUE;
|
|
||||||
// allow the call out to the observers.
|
|
||||||
}
|
|
||||||
PRUint32 curFrame = mImage->GetCurrentFrameIndex();
|
|
||||||
if (mObserver)
|
|
||||||
mObserver->OnDataAvailable(nsnull, curFrame == numFrames - 1,
|
|
||||||
&mFrameRect);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -809,15 +802,9 @@ nsPNGDecoder::row_callback(png_structp png_ptr, png_bytep new_row,
|
||||||
PRUint32 numFrames = decoder->mImage->GetNumFrames();
|
PRUint32 numFrames = decoder->mImage->GetNumFrames();
|
||||||
if (numFrames <= 1) {
|
if (numFrames <= 1) {
|
||||||
// Only do incremental image display for the first frame
|
// 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);
|
nsIntRect r(0, row_num, width, 1);
|
||||||
if (NS_FAILED(decoder->mImage->FrameUpdated(numFrames - 1, r))) {
|
decoder->PostInvalidation(r);
|
||||||
decoder->mError = PR_TRUE; /* bail */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PRUint32 curFrame = decoder->mImage->GetCurrentFrameIndex();
|
|
||||||
if (decoder->mObserver)
|
|
||||||
decoder->mObserver->OnDataAvailable(nsnull,
|
|
||||||
curFrame == numFrames - 1, &r);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -927,7 +927,7 @@ RasterImage::EnsureCleanFrame(PRUint32 aFrameNum, PRInt32 aX, PRInt32 aY,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
RasterImage::FrameUpdated(PRUint32 aFrameNum, nsIntRect &aUpdatedRect)
|
RasterImage::FrameUpdated(PRUint32 aFrameNum, nsIntRect &aUpdatedRect)
|
||||||
{
|
{
|
||||||
NS_ABORT_IF_FALSE(aFrameNum < mFrames.Length(), "Invalid frame index!");
|
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!");
|
NS_ABORT_IF_FALSE(frame, "Calling FrameUpdated on frame that doesn't exist!");
|
||||||
|
|
||||||
frame->ImageUpdated(aUpdatedRect);
|
frame->ImageUpdated(aUpdatedRect);
|
||||||
|
|
||||||
// XXXbholley - this should turn into a void method as soon the decoders
|
|
||||||
// stop using it
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
|
|
@ -226,7 +226,7 @@ public:
|
||||||
PRUint32** paletteData,
|
PRUint32** paletteData,
|
||||||
PRUint32* paletteLength);
|
PRUint32* paletteLength);
|
||||||
|
|
||||||
nsresult FrameUpdated(PRUint32 aFrameNum, nsIntRect& aUpdatedRect);
|
void FrameUpdated(PRUint32 aFrameNum, nsIntRect& aUpdatedRect);
|
||||||
|
|
||||||
/* notification when the current frame is done decoding */
|
/* notification when the current frame is done decoding */
|
||||||
nsresult EndFrameDecode(PRUint32 aFrameNum);
|
nsresult EndFrameDecode(PRUint32 aFrameNum);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче