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

Unified Diff: include/ports/SkMacImageCache.h

Issue 12433020: Improvements/additions to SkImageCache/SkLazyPixelRef. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Modified a comment. 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
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

Powered by Google App Engine
This is Rietveld 408576698