aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkDiscardableMemory_none.cpp
diff options
context:
space:
mode:
authorGravatar halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-05 18:31:42 +0000
committerGravatar halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-05 18:31:42 +0000
commit2c7c7ee47d75e7815ea8db05e924ab55958cb402 (patch)
treee6b7221c8f6a6d3b9d548c923499f3cf23f79634 /src/ports/SkDiscardableMemory_none.cpp
parent3e0446ccbfbeadd0d02d417cb68e950d6c92f8e1 (diff)
Big Cleanup: SkBitmapFactory, SkLazyPixelRef, SkImageCache
Removed SkBitmapFactory since no clients were using it. New cache selection mechanism can simply pass a SkDiscardableMemory::Factory into the SkDiscardablePixelRef if non-default SkDiscardableMemory should be used. Removed BitmapFactoryTest. SkDiscardableMemory::Factory interface. Android will need this functionality in the future inside their BitmapFactory. Removed SkLazyPixelRef, since it's functionality is now subsumed into SkDiscardablePixelRef. Removed LazyPixelRef test. Modified SkDiscardablePixelRef to optionally allow it to use a SkDiscardableMemory::Factory. This tiny change makes it a replacement for SkLazyPixelRef. This functioanlity is also necessary for moving Android over to SkDiscardablePixelRef from SkImageRef in a later CL. Added a test for this. SkDecodingImageGenerator::Install can optionally pass a factory in to SkDiscardablePixelRef. Removed SkImageCache, SkLruImageCache, and SkPurgeableImageCache. This functionality can be handled much more cleanly by SkDiscardableMemory. New SkDiscardableMemoryPool class to replace SkLruImageCache. In a later CL, we will replace SkImageRef_GlobalPool (used by android) as well. This is a concrete implementation of SkDiscardableMemory::Factory. Added a test for this. modified gm/factory.cpp to remove dependnce on SkBitmapFactory + SkLruImageCache. Now uses SkDecodingImageGenerator + SkDiscardablePixelRef + SkDiscardableMemoryPool. SkImageDecoder::Target replaces SkBitmapFactory::Target. The DecodeMemoryToTarget function may disappear in the future. Moved SkLazyCachingPixelRef::DecodeProc replaces SkBitmapFactory::DecodeProc. This is a short term change, since another CL changes SkLazyCachingPixelRef to use SkImageGenerator instead of DecodeProc. Modified DrawBitmapRectTest to use SkDiscardablePixelRef instead of SkLazyPixelRef. tools/LazyDecodeBitmap.cpp now uses SkDecodingImageGenerator + SkDiscardablePixelRef instead of a SkBitmapFactory. bench_pictures uses the Global SkDiscardableMemoryPool instead of a global gLruImageCache. R=reed@google.com, scroggo@google.com Review URL: https://codereview.chromium.org/103033002 git-svn-id: http://skia.googlecode.com/svn/trunk@12515 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/ports/SkDiscardableMemory_none.cpp')
-rw-r--r--src/ports/SkDiscardableMemory_none.cpp52
1 files changed, 2 insertions, 50 deletions
diff --git a/src/ports/SkDiscardableMemory_none.cpp b/src/ports/SkDiscardableMemory_none.cpp
index 700713ba48..51c3164dfa 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);
}