mirror of
https://github.com/wasabeef/glide-transformations.git
synced 2025-06-08 15:34:04 +08:00
Put the mask bitmap to the BitmapPool
put the mask bitmap to the BitmapPool when the mask is get from the BitmapPool.
This commit is contained in:
parent
46d5d4d72f
commit
831f038d29
@ -48,8 +48,10 @@ public class MaskTransformation implements Transformation<Bitmap> {
|
|||||||
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
|
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
|
||||||
Bitmap source = resource.get();
|
Bitmap source = resource.get();
|
||||||
|
|
||||||
|
boolean maskFromBitmapPool = true;
|
||||||
Bitmap mask = mBitmapPool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
|
Bitmap mask = mBitmapPool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
|
||||||
if (mask == null) {
|
if (mask == null) {
|
||||||
|
maskFromBitmapPool = false;
|
||||||
mask = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
|
mask = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +78,10 @@ public class MaskTransformation implements Transformation<Bitmap> {
|
|||||||
source.getWidth(), source.getHeight()), null);
|
source.getWidth(), source.getHeight()), null);
|
||||||
canvas.drawBitmap(source, 0, 0, paint);
|
canvas.drawBitmap(source, 0, 0, paint);
|
||||||
|
|
||||||
|
if (maskFromBitmapPool) {
|
||||||
|
mBitmapPool.put(mask);
|
||||||
|
}
|
||||||
|
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,8 +56,10 @@ public class NinePatchMaskTransformation implements Transformation<Bitmap> {
|
|||||||
int width = outWidth == Target.SIZE_ORIGINAL ? source.getWidth() : outWidth;
|
int width = outWidth == Target.SIZE_ORIGINAL ? source.getWidth() : outWidth;
|
||||||
int height = outHeight == Target.SIZE_ORIGINAL ? source.getHeight() : outHeight;
|
int height = outHeight == Target.SIZE_ORIGINAL ? source.getHeight() : outHeight;
|
||||||
|
|
||||||
|
boolean maskFromBitmapPool = true;
|
||||||
Bitmap mask = mBitmapPool.get(width, height, Bitmap.Config.ARGB_8888);
|
Bitmap mask = mBitmapPool.get(width, height, Bitmap.Config.ARGB_8888);
|
||||||
if (mask == null) {
|
if (mask == null) {
|
||||||
|
maskFromBitmapPool = false;
|
||||||
mask = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
mask = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +86,10 @@ public class NinePatchMaskTransformation implements Transformation<Bitmap> {
|
|||||||
source.getWidth(), source.getHeight()), null);
|
source.getWidth(), source.getHeight()), null);
|
||||||
canvas.drawBitmap(source, 0, 0, paint);
|
canvas.drawBitmap(source, 0, 0, paint);
|
||||||
|
|
||||||
|
if (maskFromBitmapPool) {
|
||||||
|
mBitmapPool.put(mask);
|
||||||
|
}
|
||||||
|
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user