Bug 731419 - Part 1: Discard image data immediately on tab close, imagelib changes. r=joe

--HG--
extra : rebase_source : 5e08cc235f1a9cb7b63d83df13760f2f2a4de0a4
This commit is contained in:
Justin Lebar 2012-03-10 01:29:28 -05:00
parent dbf9b1b40f
commit ac34f00ddc
7 changed files with 47 additions and 2 deletions

View File

@ -93,7 +93,7 @@ native gfxGraphicsFilter(gfxPattern::GraphicsFilter);
*
* Internally, imgIContainer also manages animation of images.
*/
[scriptable, uuid(2506249c-e0a1-4d8f-846c-2d478247f8d8)]
[scriptable, uuid(8bf87433-be67-413b-9497-00071c5002bd)]
interface imgIContainer : nsISupports
{
/**
@ -283,6 +283,12 @@ interface imgIContainer : nsISupports
*/
void unlockImage();
/**
* If this image is unlocked, discard its decoded data. If the image is
* locked or has already been discarded, do nothing.
*/
void requestDiscard();
/**
* Indicates that this imgIContainer has been triggered to update
* its internal animation state. Likely this should only be called

View File

@ -52,7 +52,7 @@ interface nsIPrincipal;
* @version 0.1
* @see imagelib2
*/
[scriptable, uuid(c3bf4e2a-f64b-4ac1-a84e-18631b1802ab)]
[scriptable, uuid(d35a9adb-8328-4b64-b06f-72a165acd080)]
interface imgIRequest : nsIRequest
{
/**
@ -194,6 +194,12 @@ interface imgIRequest : nsIRequest
*/
void unlockImage();
/**
* If this image is unlocked, discard the image's decoded data. If the image
* is locked or is already discarded, do nothing.
*/
void requestDiscard();
/**
* If this request is for an animated image, the method creates a new
* request which contains the current frame of the image.

View File

@ -2696,6 +2696,18 @@ RasterImage::UnlockImage()
return NS_OK;
}
//******************************************************************************
/* void requestDiscard() */
NS_IMETHODIMP
RasterImage::RequestDiscard()
{
if (CanDiscard()) {
ForceDiscard();
}
return NS_OK;
}
// Flushes up to aMaxBytes to the decoder.
nsresult
RasterImage::DecodeSomeData(PRUint32 aMaxBytes)

View File

@ -198,6 +198,7 @@ public:
NS_SCRIPTABLE NS_IMETHOD RequestDecode(void);
NS_SCRIPTABLE NS_IMETHOD LockImage(void);
NS_SCRIPTABLE NS_IMETHOD UnlockImage(void);
NS_SCRIPTABLE NS_IMETHOD RequestDiscard(void);
NS_SCRIPTABLE NS_IMETHOD ResetAnimation(void);
NS_IMETHOD_(void) RequestRefresh(const mozilla::TimeStamp& aTime);
// END NS_DECL_IMGICONTAINER

View File

@ -626,6 +626,15 @@ VectorImage::UnlockImage()
return NS_OK;
}
//******************************************************************************
/* void requestDiscard() */
NS_IMETHODIMP
VectorImage::RequestDiscard()
{
// This method is for image-discarding, which only applies to RasterImages.
return NS_OK;
}
//******************************************************************************
/* void resetAnimation (); */
NS_IMETHODIMP

View File

@ -81,6 +81,7 @@ public:
NS_SCRIPTABLE NS_IMETHOD RequestDecode(void);
NS_SCRIPTABLE NS_IMETHOD LockImage(void);
NS_SCRIPTABLE NS_IMETHOD UnlockImage(void);
NS_SCRIPTABLE NS_IMETHOD RequestDiscard(void);
NS_SCRIPTABLE NS_IMETHOD ResetAnimation(void);
NS_IMETHOD_(void) RequestRefresh(const mozilla::TimeStamp& aTime);
// END NS_DECL_IMGICONTAINER

View File

@ -370,6 +370,16 @@ imgRequestProxy::UnlockImage()
return NS_OK;
}
/* void requestDiscard (); */
NS_IMETHODIMP
imgRequestProxy::RequestDiscard()
{
if (mImage) {
return mImage->RequestDiscard();
}
return NS_OK;
}
NS_IMETHODIMP
imgRequestProxy::IncrementAnimationConsumers()
{