Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(704)

Unified Diff: include/lazy/SkPurgeableImageCache.h

Issue 12433020: Improvements/additions to SkImageCache/SkLazyPixelRef. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/lazy/SkLruImageCache.h ('k') | include/ports/SkAshmemImageCache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/lazy/SkPurgeableImageCache.h
diff --git a/include/lazy/SkPurgeableImageCache.h b/include/lazy/SkPurgeableImageCache.h
new file mode 100644
index 0000000000000000000000000000000000000000..98ace4a689ddbd58e0a39644fc0fa6e7b9602d68
--- /dev/null
+++ b/include/lazy/SkPurgeableImageCache.h
@@ -0,0 +1,54 @@
+/*
+ * 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:
+ /**
+ * Get a pointer to the single global instance of the purgeable image cache.
+ * If there is no Skia implementation for purgeable memory, this returns NULL.
+ * If non-NULL, the caller must unref it after use.
+ */
+ static SkImageCache* GetPurgeableImageCache();
reed1 2013/03/18 21:25:17 Why isn't this just called Create()?
scroggo 2013/03/18 21:37:16 Done.
+
+ virtual void* allocAndPinCache(size_t bytes, intptr_t* ID) SK_OVERRIDE;
+ virtual void* pinCache(intptr_t ID, SkImageCache::DataStatus*) SK_OVERRIDE;
+ virtual void releaseCache(intptr_t ID) SK_OVERRIDE;
+ virtual void throwAwayCache(intptr_t ID) SK_OVERRIDE;
+
+#ifdef SK_DEBUG
+ virtual MemoryStatus getMemoryStatus(intptr_t ID) const SK_OVERRIDE;
+ virtual void purgeAllUnpinnedCaches() SK_OVERRIDE;
+ virtual ~SkPurgeableImageCache();
+#endif
+
+private:
+ /**
+ * Constructor is private. The correct way to get this cache is through
+ * GetPurgeableImageCache, which will return the single global.
+ */
+ SkPurgeableImageCache();
+
+#ifdef SK_DEBUG
+ SkTDArray<intptr_t> fRecs;
+ int findRec(intptr_t) const;
+#endif
+ void removeRec(intptr_t);
+};
+#endif // SkPurgeableImageCache_DEFINED
« no previous file with comments | « include/lazy/SkLruImageCache.h ('k') | include/ports/SkAshmemImageCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698