mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 936964 (part 2) - Make SurfaceCache ref-counted. r=seth.
--HG-- extra : rebase_source : 0f6be3429ce653ca01bb5db7c8520c7e996acf67
This commit is contained in:
parent
7b367571d4
commit
234337011d
@ -14,6 +14,7 @@
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/Util.h" // for Maybe
|
||||
#include "gfxASurface.h"
|
||||
#include "gfxPattern.h" // Workaround for flaw in bug 921753 part 2.
|
||||
@ -69,7 +70,7 @@ class SurfaceCacheImpl;
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// The single surface cache instance.
|
||||
static SurfaceCacheImpl* sInstance = nullptr;
|
||||
static StaticRefPtr<SurfaceCacheImpl> sInstance;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -223,9 +224,11 @@ private:
|
||||
* maintains high-level invariants and encapsulates the details of the surface
|
||||
* cache's implementation.
|
||||
*/
|
||||
class SurfaceCacheImpl
|
||||
class SurfaceCacheImpl : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
SurfaceCacheImpl(uint32_t aSurfaceCacheExpirationTimeMS,
|
||||
uint32_t aSurfaceCacheSize)
|
||||
: mExpirationTracker(MOZ_THIS_IN_INITIALIZER_LIST(),
|
||||
@ -242,7 +245,7 @@ public:
|
||||
os->AddObserver(mMemoryPressureObserver, "memory-pressure", false);
|
||||
}
|
||||
|
||||
~SurfaceCacheImpl()
|
||||
virtual ~SurfaceCacheImpl()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
@ -458,6 +461,7 @@ private:
|
||||
Cost mAvailableCost;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(SurfaceCacheImpl, nsISupports)
|
||||
NS_IMPL_ISUPPORTS1(SurfaceCacheImpl::MemoryPressureObserver, nsIObserver)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -508,7 +512,6 @@ SurfaceCache::Initialize()
|
||||
SurfaceCache::Shutdown()
|
||||
{
|
||||
MOZ_ASSERT(sInstance, "No singleton - was Shutdown() called twice?");
|
||||
delete sInstance;
|
||||
sInstance = nullptr;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user