Implement SkAshmemDiscardableMemory

-   Implement ashmem-backed SkDiscardableMemory subclass:
    This class in only accesible via the SkDiscardableMemory::Create()
    function, which replaces the mock implementation in
    SkDiscardableMemory_none.cpp

-   Added SkDiscardableMemory_ashmem.cpp to the Android port of Skia
    Removed SkDiscardableMemory_none.cpp from the Android port.

-   Added DiscardableMemoryTest.
    Still needs work.

-   SkDiscardablePixelRef Bugfix:
    onLockPixels() now calls SkDELETE on the SkDiscardableMemory pointer
    when it fails to unlock.

-   Improved documentation inside ashmem.h

BUG=
R=scroggo@google.com

Review URL: https://codereview.chromium.org/83563002

git-svn-id: http://skia.googlecode.com/svn/trunk@12608 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/LazyDecodeBitmap.cpp b/tools/LazyDecodeBitmap.cpp
index 9e850e5..f5ff147 100644
--- a/tools/LazyDecodeBitmap.cpp
+++ b/tools/LazyDecodeBitmap.cpp
@@ -17,7 +17,6 @@
 
 __SK_FORCE_IMAGE_DECODER_LINKING;
 
-// TODO(halcanary) Use this flag when ashmem-backed discardable memory lands.
 DEFINE_bool(useVolatileCache, false, "Use a volatile cache for deferred image decoding pixels. "
             "Only meaningful if --deferImageDecoding is set to true and the platform has an "
             "implementation.");
@@ -39,9 +38,11 @@
         return false;
     }
     SkDiscardableMemory::Factory* pool = NULL;
-    if (info.fWidth * info.fHeight > 32 * 1024) {
+    if ((!FLAGS_useVolatileCache) || (info.fWidth * info.fHeight < 32 * 1024)) {
         // how to do switching with SkDiscardableMemory.
         pool = SkGetGlobalDiscardableMemoryPool();
+        // Only meaningful if platform has a default discardable
+        // memory implementation that differs from the global DM pool.
     }
     return SkDiscardablePixelRef::Install(gen.detach(), dst, pool);
 }