/*
 * Copyright (c) 2017-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */
package com.facebook.imagepipeline.memory;

import android.graphics.Bitmap;
import android.graphics.Color;
import android.support.annotation.Nullable;
import com.facebook.imageutils.BitmapUtil;

public class BitmapPoolBackend extends LruBucketsPoolBackend<Bitmap> {
  @Nullable
  @Override
  public Bitmap get(int size) {
    Bitmap bitmap = super.get(size);
    if (bitmap != null) {
      bitmap.eraseColor(Color.TRANSPARENT);
    }
    return bitmap;
  }

  @Override
  public int getSize(Bitmap bitmap) {
    return BitmapUtil.getSizeInBytes(bitmap);
  }
}

@@ -452,16 +452,57 @@
 llable;%0A
+import com.facebook.common.logging.FLog;%0A
 import c
@@ -608,16 +608,188 @@
 tmap%3E %7B%0A
+%0A  private static final String TAG = %22BitmapPoolBackend%22;%0A%0A  @Override%0A  public void put(Bitmap bitmap) %7B%0A    if (isReusable(bitmap)) %7B%0A      super.put(bitmap);%0A    %7D%0A  %7D%0A%0A
   @Nulla
@@ -895,16 +895,38 @@
  != null
+ && isReusable(bitmap)
 ) %7B%0A    
@@ -967,20 +967,16 @@
 ENT);%0A  
-  %7D%0A
     retu
@@ -986,16 +986,39 @@
 bitmap;%0A
+    %7D%0A    return null;%0A
   %7D%0A%0A  @
@@ -1113,11 +1113,393 @@
 ap);%0A  %7D
+%0A%0A  protected boolean isReusable(@Nullable Bitmap bitmap) %7B%0A    if (bitmap == null) %7B%0A      return false;%0A    %7D%0A    if (bitmap.isRecycled()) %7B%0A      FLog.wtf(TAG, %22Cannot reuse a recycled bitmap: %25s%22, bitmap);%0A      return false;%0A    %7D%0A    if (!bitmap.isMutable()) %7B%0A      FLog.wtf(TAG, %22Cannot reuse an immutable bitmap: %25s%22, bitmap);%0A      return false;%0A    %7D%0A    return true;%0A  %7D
 %0A%7D%0A

Check bitmap reusability