mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-06 12:43:53 +00:00
Fix for bug 659580 (Flush CanvasImageCache on shutdown). r=roc.
--HG-- extra : rebase_source : 9752189ce8c9bd13795979cfa8d50311b5bf5b56
This commit is contained in:
parent
cf4d0a80bd
commit
a86da555f8
@ -133,6 +133,13 @@ public:
|
||||
|
||||
static ImageCache* gImageCache = nsnull;
|
||||
|
||||
class CanvasImageCacheShutdownObserver : public nsIObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
};
|
||||
|
||||
void
|
||||
CanvasImageCache::NotifyDrawImage(nsIDOMElement* aImage,
|
||||
nsHTMLCanvasElement* aCanvas,
|
||||
@ -142,6 +149,7 @@ CanvasImageCache::NotifyDrawImage(nsIDOMElement* aImage,
|
||||
{
|
||||
if (!gImageCache) {
|
||||
gImageCache = new ImageCache();
|
||||
nsContentUtils::RegisterShutdownObserver(new CanvasImageCacheShutdownObserver());
|
||||
}
|
||||
|
||||
ImageCacheEntry* entry = gImageCache->mCache.PutEntry(ImageCacheKey(aImage, aCanvas));
|
||||
@ -186,11 +194,21 @@ CanvasImageCache::Lookup(nsIDOMElement* aImage,
|
||||
return entry->mData->mSurface;
|
||||
}
|
||||
|
||||
void
|
||||
CanvasImageCache::Shutdown()
|
||||
NS_IMPL_ISUPPORTS1(CanvasImageCacheShutdownObserver, nsIObserver)
|
||||
|
||||
NS_IMETHODIMP
|
||||
CanvasImageCacheShutdownObserver::Observe(nsISupports *aSubject,
|
||||
const char *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
delete gImageCache;
|
||||
gImageCache = nsnull;
|
||||
if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
|
||||
delete gImageCache;
|
||||
gImageCache = nsnull;
|
||||
|
||||
nsContentUtils::UnregisterShutdownObserver(this);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -69,8 +69,6 @@ public:
|
||||
static gfxASurface* Lookup(nsIDOMElement* aImage,
|
||||
nsHTMLCanvasElement* aCanvas,
|
||||
gfxIntSize* aSize);
|
||||
|
||||
static void Shutdown();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -121,7 +121,6 @@
|
||||
#include "nsContentSink.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsRefreshDriver.h"
|
||||
#include "CanvasImageCache.h"
|
||||
|
||||
#include "nsHyphenationManager.h"
|
||||
|
||||
@ -281,7 +280,6 @@ nsLayoutStatics::Initialize()
|
||||
void
|
||||
nsLayoutStatics::Shutdown()
|
||||
{
|
||||
CanvasImageCache::Shutdown();
|
||||
nsFrameScriptExecutor::Shutdown();
|
||||
nsFocusManager::Shutdown();
|
||||
#ifdef MOZ_XUL
|
||||
|
Loading…
Reference in New Issue
Block a user