Bug 587371 - Image.h PRUint32 getters shouldn't be COM-y. r=joe,a=blocker

This commit is contained in:
Bobby Holley 2010-08-14 18:23:47 -04:00
parent 7e065871d5
commit 4d20b09df3
7 changed files with 36 additions and 71 deletions

View File

@ -212,8 +212,7 @@ nsGIFDecoder2::FlushImageData(PRUint32 fromRow, PRUint32 rows)
// Offset to the frame position
// Only notify observer(s) for first frame
if (!mGIFStruct.images_decoded && mObserver) {
PRUint32 imgCurFrame;
mImageContainer->GetCurrentFrameIndex(&imgCurFrame);
PRUint32 imgCurFrame = mImageContainer->GetCurrentFrameIndex();
mObserver->OnDataAvailable(nsnull, imgCurFrame == PRUint32(mGIFStruct.images_decoded), &r);
}
return NS_OK;
@ -268,15 +267,11 @@ nsGIFDecoder2::Write(const char *aBuffer, PRUint32 aCount)
// pretend that we're decoded. Otherwise, we set mError.
if (NS_FAILED(rv)) {
// Determine if we want to salvage the situation
PRUint32 numFrames = 0;
if (mImageContainer)
mImageContainer->GetNumFrames(&numFrames);
// If we're salvaging, send off notifications
// Determine if we want to salvage the situation.
// If we're salvaging, send off notifications.
// Note that we need to make sure that we have 2 frames, since that tells us
// that the first frame is complete (the second could be in any state).
if (numFrames > 1) {
if (mImageContainer && mImageContainer->GetNumFrames() > 1) {
EndGIF(/* aSuccess = */ PR_TRUE);
}
@ -340,8 +335,7 @@ nsresult nsGIFDecoder2::BeginImageFrame(gfx_depth aDepth)
if (mGIFStruct.y_offset > 0) {
PRInt32 imgWidth;
mImageContainer->GetWidth(&imgWidth);
PRUint32 imgCurFrame;
mImageContainer->GetCurrentFrameIndex(&imgCurFrame);
PRUint32 imgCurFrame = mImageContainer->GetCurrentFrameIndex();
nsIntRect r(0, 0, imgWidth, mGIFStruct.y_offset);
if (mObserver)
mObserver->OnDataAvailable(nsnull,
@ -400,8 +394,7 @@ void nsGIFDecoder2::EndImageFrame()
// 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;
mImageContainer->GetCurrentFrameIndex(&imgCurFrame);
PRUint32 imgCurFrame = mImageContainer->GetCurrentFrameIndex();
nsIntRect r(0, realFrameHeight,
mGIFStruct.screen_width,
mGIFStruct.screen_height - realFrameHeight);

View File

@ -145,11 +145,8 @@ void nsPNGDecoder::CreateFrame(png_uint_32 x_offset, png_uint_32 y_offset,
SetAnimFrameInfo();
#endif
PRUint32 numFrames = 0;
mImage->GetNumFrames(&numFrames);
if (mObserver)
mObserver->OnStartFrame(nsnull, numFrames - 1);
mObserver->OnStartFrame(nsnull, mImage->GetNumFrames() - 1);
PR_LOG(gPNGDecoderAccountingLog, PR_LOG_DEBUG,
("PNGDecoderAccounting: nsPNGDecoder::CreateFrame -- created "
@ -187,8 +184,7 @@ void nsPNGDecoder::SetAnimFrameInfo()
(static_cast<PRFloat64>(delay_num) * 1000 / delay_den);
}
PRUint32 numFrames = 0;
mImage->GetNumFrames(&numFrames);
PRUint32 numFrames = mImage->GetNumFrames();
mImage->SetFrameTimeout(numFrames - 1, timeout);
@ -214,7 +210,7 @@ void nsPNGDecoder::EndImageFrame()
{
PRUint32 numFrames = 1;
#ifdef PNG_APNG_SUPPORTED
mImage->GetNumFrames(&numFrames);
numFrames = mImage->GetNumFrames();
// We can't use mPNG->num_frames_read as it may be one ahead.
if (numFrames > 1) {
@ -226,8 +222,7 @@ void nsPNGDecoder::EndImageFrame()
mError = PR_TRUE;
// allow the call out to the observers.
}
PRUint32 curFrame;
mImage->GetCurrentFrameIndex(&curFrame);
PRUint32 curFrame = mImage->GetCurrentFrameIndex();
if (mObserver)
mObserver->OnDataAvailable(nsnull, curFrame == numFrames - 1,
&mFrameRect);
@ -861,8 +856,7 @@ row_callback(png_structp png_ptr, png_bytep new_row,
if (!rowHasNoAlpha)
decoder->mFrameHasNoAlpha = PR_FALSE;
PRUint32 numFrames = 0;
decoder->mImage->GetNumFrames(&numFrames);
PRUint32 numFrames = decoder->mImage->GetNumFrames();
if (numFrames <= 1) {
// Only do incremental image display for the first frame
nsIntRect r(0, row_num, width, 1);
@ -870,8 +864,7 @@ row_callback(png_structp png_ptr, png_bytep new_row,
decoder->mError = PR_TRUE; /* bail */
return;
}
PRUint32 curFrame;
decoder->mImage->GetCurrentFrameIndex(&curFrame);
PRUint32 curFrame = decoder->mImage->GetCurrentFrameIndex();
if (decoder->mObserver)
decoder->mObserver->OnDataAvailable(nsnull,
curFrame == numFrames - 1, &r);

View File

@ -94,18 +94,18 @@ public:
* The index of the current frame that would be drawn if the image was to be
* drawn now.
*/
virtual nsresult GetCurrentFrameIndex(PRUint32* aCurrentFrameIdx) = 0;
virtual PRUint32 GetCurrentFrameIndex() = 0;
/**
* The total number of frames in this image.
*/
virtual nsresult GetNumFrames(PRUint32* aNumFrames) = 0;
virtual PRUint32 GetNumFrames() = 0;
/**
* The size, in bytes, occupied by the significant data portions of the image.
* This includes both compressed source data and decoded frames.
*/
virtual nsresult GetDataSize(PRUint32* aDataSize) = 0;
virtual PRUint32 GetDataSize() = 0;
protected:
Image();

View File

@ -491,30 +491,16 @@ RasterImage::GetCurrentFrameRect(nsIntRect &aRect)
return NS_OK;
}
nsresult
RasterImage::GetCurrentFrameIndex(PRUint32 *aCurrentFrameIdx)
PRUint32
RasterImage::GetCurrentFrameIndex()
{
if (mError)
return NS_ERROR_FAILURE;
NS_ENSURE_ARG_POINTER(aCurrentFrameIdx);
*aCurrentFrameIdx = GetCurrentImgFrameIndex();
return NS_OK;
return GetCurrentImgFrameIndex();
}
nsresult
RasterImage::GetNumFrames(PRUint32 *aNumFrames)
PRUint32
RasterImage::GetNumFrames()
{
if (mError)
return NS_ERROR_FAILURE;
NS_ENSURE_ARG_POINTER(aNumFrames);
*aNumFrames = mFrames.Length();
return NS_OK;
return mFrames.Length();
}
//******************************************************************************
@ -663,25 +649,24 @@ RasterImage::GetFrame(PRUint32 aWhichFrame,
return rv;
}
nsresult
RasterImage::GetDataSize(PRUint32 *_retval)
PRUint32
RasterImage::GetDataSize()
{
if (mError)
return NS_ERROR_FAILURE;
NS_ENSURE_ARG_POINTER(_retval);
return 0;
// Start with 0
*_retval = 0;
PRUint32 size = 0;
// Account for any compressed source data
*_retval += GetSourceDataSize();
NS_ABORT_IF_FALSE(StoringSourceData() || (*_retval == 0),
size += GetSourceDataSize();
NS_ABORT_IF_FALSE(StoringSourceData() || (size == 0),
"Non-zero source data size when we aren't storing it?");
// Account for any uncompressed frames
*_retval += GetDecodedDataSize();
return NS_OK;
size += GetDecodedDataSize();
return size;
}
PRUint32

View File

@ -166,9 +166,9 @@ public:
const char* aMimeType,
PRUint32 aFlags);
nsresult GetCurrentFrameRect(nsIntRect& aRect);
nsresult GetCurrentFrameIndex(PRUint32* aCurrentFrameIdx);
nsresult GetNumFrames(PRUint32* aNumFrames);
nsresult GetDataSize(PRUint32* aDataSize);
PRUint32 GetCurrentFrameIndex();
PRUint32 GetNumFrames();
PRUint32 GetDataSize();
// Raster-specific methods
static NS_METHOD WriteToRasterImage(nsIInputStream* aIn, void* aClosure,

View File

@ -482,9 +482,7 @@ void imgRequest::SetIsInCache(PRBool incache)
void imgRequest::UpdateCacheEntrySize()
{
if (mCacheEntry) {
PRUint32 imageSize = 0;
mImage->GetDataSize(&imageSize);
mCacheEntry->SetDataSize(imageSize);
mCacheEntry->SetDataSize(mImage->GetDataSize());
#ifdef DEBUG_joe
nsCAutoString url;

View File

@ -223,12 +223,8 @@ imgStatusTracker::SyncNotify(imgRequestProxy* proxy)
proxy->OnStartDecode();
// Send frame messages (OnStartFrame, OnDataAvailable, OnStopFrame)
PRUint32 nframes = 0;
mImage->GetNumFrames(&nframes);
if (nframes > 0) {
PRUint32 frame;
mImage->GetCurrentFrameIndex(&frame);
if (mImage->GetNumFrames() > 0) {
PRUint32 frame = mImage->GetCurrentFrameIndex();
proxy->OnStartFrame(frame);
// OnDataAvailable