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

Unified Diff: src/ports/SkDiscardableMemory_none.cpp

Issue 103033002: Big Cleanup: SkBitmapFactory, SkLazyPixelRef, SkImageCache (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase one last time Created 7 years 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 | « src/lazy/SkPurgeableImageCache.cpp ('k') | tests/BitmapFactoryTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkDiscardableMemory_none.cpp
diff --git a/src/ports/SkDiscardableMemory_none.cpp b/src/ports/SkDiscardableMemory_none.cpp
index 700713ba4816631dfc7d7e2f3bb69558d5eedbee..51c3164dfa6e90ea3b29f31a29461bc23bf49bcf 100644
--- a/src/ports/SkDiscardableMemory_none.cpp
+++ b/src/ports/SkDiscardableMemory_none.cpp
@@ -5,57 +5,9 @@
* found in the LICENSE file.
*/
-#include "SkDiscardableMemory.h"
+#include "SkDiscardableMemoryPool.h"
#include "SkTypes.h"
-namespace {
-////////////////////////////////////////////////////////////////////////////////
-/**
- * Always successful, never purges. Useful for testing.
- */
-class SkMockDiscardableMemory : public SkDiscardableMemory {
-public:
- SkMockDiscardableMemory(void*);
- virtual ~SkMockDiscardableMemory();
- virtual bool lock() SK_OVERRIDE;
- virtual void* data() SK_OVERRIDE;
- virtual void unlock() SK_OVERRIDE;
-private:
- bool fLocked;
- void* fPointer;
-};
-
-////////////////////////////////////////////////////////////////////////////////
-
-SkMockDiscardableMemory::SkMockDiscardableMemory(void* ptr)
- : fLocked(true)
- , fPointer(ptr) { // Takes ownership of ptr.
- SkASSERT(fPointer != NULL);
-}
-
-SkMockDiscardableMemory::~SkMockDiscardableMemory() {
- SkASSERT(!fLocked);
- sk_free(fPointer);
-}
-
-bool SkMockDiscardableMemory::lock() {
- SkASSERT(!fLocked);
- return fLocked = true;
-}
-
-void* SkMockDiscardableMemory::data() {
- SkASSERT(fLocked);
- return fLocked ? fPointer : NULL;
-}
-
-void SkMockDiscardableMemory::unlock() {
- SkASSERT(fLocked);
- fLocked = false;
-}
-////////////////////////////////////////////////////////////////////////////////
-} // namespace
-
SkDiscardableMemory* SkDiscardableMemory::Create(size_t bytes) {
- void* ptr = sk_malloc_throw(bytes);
- return (ptr != NULL) ? SkNEW_ARGS(SkMockDiscardableMemory, (ptr)) : NULL;
+ return SkGetGlobalDiscardableMemoryPool()->create(bytes);
}
« no previous file with comments | « src/lazy/SkPurgeableImageCache.cpp ('k') | tests/BitmapFactoryTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698