mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 13:25:37 +00:00
Bug 666446, Part 7/18 - Change nsImageLoader to utilize new refresh driver animations to overcome performance issues with animated background images. [r=roc]
This commit is contained in:
parent
5e210060ef
commit
c4d5846ffe
@ -57,6 +57,7 @@
|
||||
|
||||
#include "nsStyleContext.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
|
||||
// Paint forcing
|
||||
#include "prenv.h"
|
||||
@ -67,7 +68,8 @@ nsImageLoader::nsImageLoader(nsIFrame *aFrame, PRUint32 aActions,
|
||||
nsImageLoader *aNextLoader)
|
||||
: mFrame(aFrame),
|
||||
mActions(aActions),
|
||||
mNextLoader(aNextLoader)
|
||||
mNextLoader(aNextLoader),
|
||||
mRequestRegistered(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -105,12 +107,15 @@ nsImageLoader::Destroy()
|
||||
todestroy->Destroy();
|
||||
}
|
||||
|
||||
mFrame = nsnull;
|
||||
|
||||
if (mRequest) {
|
||||
nsPresContext* presContext = mFrame->PresContext();
|
||||
|
||||
nsLayoutUtils::DeregisterImageRequest(presContext, mRequest,
|
||||
&mRequestRegistered);
|
||||
mRequest->CancelAndForgetObserver(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
mFrame = nsnull;
|
||||
mRequest = nsnull;
|
||||
}
|
||||
|
||||
@ -269,3 +274,31 @@ nsImageLoader::DoRedraw(const nsRect* aDamageRect)
|
||||
mFrame->Invalidate(bounds);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageLoader::OnStartDecode(imgIRequest *aRequest)
|
||||
{
|
||||
// Register our image request with the refresh driver.
|
||||
nsPresContext* presContext = mFrame->PresContext();
|
||||
if (!presContext) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsLayoutUtils::RegisterImageRequest(presContext, aRequest,
|
||||
&mRequestRegistered);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageLoader::OnStopDecode(imgIRequest *aRequest, nsresult status,
|
||||
const PRUnichar *statusArg)
|
||||
{
|
||||
// Deregister the imgIRequest with the refresh driver if the
|
||||
// image is not animated.
|
||||
nsLayoutUtils::DeregisterImageRequestIfNotAnimated(mFrame->PresContext(),
|
||||
mRequest,
|
||||
&mRequestRegistered);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -82,6 +82,10 @@ public:
|
||||
|
||||
// imgIDecoderObserver (override nsStubImageDecoderObserver)
|
||||
NS_IMETHOD OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage);
|
||||
NS_IMETHOD OnStartDecode(imgIRequest *aRequest);
|
||||
NS_IMETHOD OnStopDecode(imgIRequest *aRequest,
|
||||
nsresult status,
|
||||
const PRUnichar *statusArg);
|
||||
NS_IMETHOD OnStopFrame(imgIRequest *aRequest, PRUint32 aFrame);
|
||||
NS_IMETHOD OnStopRequest(imgIRequest *aRequest, bool aLastPart);
|
||||
// Do not override OnDataAvailable since background images are not
|
||||
@ -109,4 +113,8 @@ private:
|
||||
nsCOMPtr<imgIRequest> mRequest;
|
||||
PRUint32 mActions;
|
||||
nsRefPtr<nsImageLoader> mNextLoader;
|
||||
|
||||
// This is a boolean flag indicating whether or not the current image request
|
||||
// has been registered with the refresh driver.
|
||||
bool mRequestRegistered;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user