Index: include/ports/SkMacImageCache.h |
diff --git a/include/ports/SkMacImageCache.h b/include/ports/SkMacImageCache.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5c315e476a5fbb72f9c6cf27578f727e5f241f9d |
--- /dev/null |
+++ b/include/ports/SkMacImageCache.h |
@@ -0,0 +1,63 @@ |
+/* |
+ * 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 SkMacImageCache_DEFINED |
+#define SkMacImageCache_DEFINED |
+ |
+#include "SkImageCache.h" |
+ |
+#ifdef SK_DEBUG |
+ #include "SkTDArray.h" |
+#endif |
+ |
+#include <mach/mach.h> |
+ |
+ |
+/** |
+ * Interface for a cache that manages pixel memory. |
+ */ |
+class SkMacImageCache : public SkImageCache { |
+ |
+public: |
+ /** |
+ * Get a pointer to the single global instance of SkMacImageCache. |
+ */ |
+ static SkMacImageCache* GetMacImageCache(); |
+ |
+ virtual void* allocAndPinCache(size_t bytes, intptr_t* ID) SK_OVERRIDE; |
+ virtual void* pinCache(intptr_t ID, SkImageCache::PurgeStatus*) SK_OVERRIDE; |
+ virtual void releaseCache(intptr_t ID) SK_OVERRIDE; |
+ virtual void throwAwayCache(intptr_t ID) SK_OVERRIDE; |
+ |
+#ifdef SK_DEBUG |
+ virtual PinStatus getPinStatus(intptr_t ID) const SK_OVERRIDE; |
+ virtual void purgeAllCaches() SK_OVERRIDE; |
+ virtual ~SkMacImageCache(); |
+#endif |
+ |
+private: |
+ /** |
+ * Constructor is private. The correct way to get this cache is through |
+ * GetMacImageCache, so that all callers can get the single global. |
+ */ |
+ SkMacImageCache(); |
+ |
+ struct Rec { |
+ vm_address_t fAddr; |
+ vm_size_t fSize; |
+#ifdef SK_DEBUG |
+ bool fPinned; |
+#endif |
+ }; |
+ |
+#ifdef SK_DEBUG |
+ SkTDArray<intptr_t> fRecs; |
+ int findRec(intptr_t) const; |
+#endif |
+ void removeRec(intptr_t); |
+}; |
+#endif // SkMacImageCache_DEFINED |