2013-03-18 21:37:39 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkPurgeableImageCache_DEFINED
|
|
|
|
#define SkPurgeableImageCache_DEFINED
|
|
|
|
|
|
|
|
#include "SkImageCache.h"
|
|
|
|
|
|
|
|
#ifdef SK_DEBUG
|
|
|
|
#include "SkTDArray.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation for SkImageCache that uses system defined purgeable memory.
|
|
|
|
*/
|
|
|
|
class SkPurgeableImageCache : public SkImageCache {
|
|
|
|
|
|
|
|
public:
|
2013-07-11 22:29:29 +00:00
|
|
|
SK_DECLARE_INST_COUNT(SkPurgeableImageCache)
|
|
|
|
|
2013-03-18 21:37:39 +00:00
|
|
|
static SkImageCache* Create();
|
|
|
|
|
2013-07-09 21:31:54 +00:00
|
|
|
virtual void* allocAndPinCache(size_t bytes, ID*) SK_OVERRIDE;
|
|
|
|
virtual void* pinCache(ID, SkImageCache::DataStatus*) SK_OVERRIDE;
|
|
|
|
virtual void releaseCache(ID) SK_OVERRIDE;
|
|
|
|
virtual void throwAwayCache(ID) SK_OVERRIDE;
|
2013-03-18 21:37:39 +00:00
|
|
|
|
|
|
|
#ifdef SK_DEBUG
|
2013-07-09 21:31:54 +00:00
|
|
|
virtual MemoryStatus getMemoryStatus(ID) const SK_OVERRIDE;
|
2013-03-18 21:37:39 +00:00
|
|
|
virtual void purgeAllUnpinnedCaches() SK_OVERRIDE;
|
|
|
|
virtual ~SkPurgeableImageCache();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
private:
|
|
|
|
SkPurgeableImageCache();
|
|
|
|
|
|
|
|
#ifdef SK_DEBUG
|
2013-07-09 21:31:54 +00:00
|
|
|
SkTDArray<ID> fRecs;
|
|
|
|
int findRec(ID) const;
|
2013-03-18 21:37:39 +00:00
|
|
|
#endif
|
2013-07-09 21:31:54 +00:00
|
|
|
void removeRec(ID);
|
2013-03-18 21:37:39 +00:00
|
|
|
};
|
|
|
|
#endif // SkPurgeableImageCache_DEFINED
|