Experiment on non-native bitmap copy
@@ -9,6 +9,7 @@ package com.facebook.imagepipeline.request;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Paint;
import com.facebook.cache.common.CacheKey;
import com.facebook.common.references.CloseableReference;
import com.facebook.imagepipeline.bitmaps.PlatformBitmapFactory;
@@ -29,6 +30,12 @@ public abstract class BasePostprocessor implements Postprocessor {
*/
public static final Bitmap.Config FALLBACK_BITMAP_CONFIGURATION = Bitmap.Config.ARGB_8888;
+ /**
+ * This is the default value that define if native bitmap copy is enable or not. If it isn't, the
+ * fallback is drawing the bitmap using {@link Canvas#drawBitmap(Bitmap, float, float, Paint)}.
+ */
+ public static boolean sEnableNativeBitmapCopy = true;
+
@Override
public String getName() {
return "Unknown postprocessor";
@@ -107,13 +114,13 @@ public abstract class BasePostprocessor implements Postprocessor {
}
/**
- * Copies the content of <code>sourceBitmap</code> to <code>destBitmap</code>. Both bitmaps must
- * have the same width and height. If their {@link Bitmap.Config} are identical, the memory is
- * directly copied. Otherwise, the <code>sourceBitmap</code> is drawn into
- * <code>destBitmap</code>.
+ * Copies the content of {@code sourceBitmap} to {@code destBitmap}. Both bitmaps must have the
+ * same width and height. If their {@link Bitmap.Config} are identical, the memory is directly
+ * copied if {@link #sEnableNativeBitmapCopy} is true. Otherwise, the {@code sourceBitmap} is
+ * drawn into {@code destBitmap}.
*/
private static void internalCopyBitmap(Bitmap destBitmap, Bitmap sourceBitmap) {
- if (destBitmap.getConfig() == sourceBitmap.getConfig()) {
+ if (destBitmap.getConfig() == sourceBitmap.getConfig() && sEnableNativeBitmapCopy) {
Bitmaps.copyBitmap(destBitmap, sourceBitmap);
} else {
// The bitmap configurations might be different when the source bitmap's configuration is
