LruBitmapPool.smali
.class public Lcom/facebook/imagepipeline/memory/LruBitmapPool;
.super Ljava/lang/Object;
.source "SourceFile"
# interfaces
.implements Lcom/facebook/imagepipeline/memory/BitmapPool;
# instance fields
.field private mCurrentSize:I
.field private mMaxBitmapSize:I
.field private final mMaxPoolSize:I
.field private final mPoolStatsTracker:Lcom/facebook/imagepipeline/memory/PoolStatsTracker;
.field protected final mStrategy:Lcom/facebook/imagepipeline/memory/PoolBackend;
.annotation system Ldalvik/annotation/Signature;
value = {
"Lcom/facebook/imagepipeline/memory/PoolBackend<",
"Landroid/graphics/Bitmap;",
">;"
}
.end annotation
.end field
# direct methods
.method public constructor <init>(IILcom/facebook/imagepipeline/memory/PoolStatsTracker;Lcom/facebook/common/memory/MemoryTrimmableRegistry;)V
.registers 6
.line 27
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 17
new-instance v0, Lcom/facebook/imagepipeline/memory/BitmapPoolBackend;
invoke-direct {v0}, Lcom/facebook/imagepipeline/memory/BitmapPoolBackend;-><init>()V
iput-object v0, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mStrategy:Lcom/facebook/imagepipeline/memory/PoolBackend;
.line 28
iput p1, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mMaxPoolSize:I
.line 29
iput p2, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mMaxBitmapSize:I
.line 30
iput-object p3, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mPoolStatsTracker:Lcom/facebook/imagepipeline/memory/PoolStatsTracker;
if-eqz p4, :cond_15
.line 32
invoke-interface {p4, p0}, Lcom/facebook/common/memory/MemoryTrimmableRegistry;->registerMemoryTrimmable(Lcom/facebook/common/memory/MemoryTrimmable;)V
:cond_15
return-void
.end method
.method private alloc(I)Landroid/graphics/Bitmap;
.registers 4
.line 71
iget-object v0, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mPoolStatsTracker:Lcom/facebook/imagepipeline/memory/PoolStatsTracker;
invoke-interface {v0, p1}, Lcom/facebook/imagepipeline/memory/PoolStatsTracker;->onAlloc(I)V
.line 72
sget-object v0, Landroid/graphics/Bitmap$Config;->ALPHA_8:Landroid/graphics/Bitmap$Config;
const/4 v1, 0x1
invoke-static {v1, p1, v0}, Landroid/graphics/Bitmap;->createBitmap(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;
move-result-object p1
return-object p1
.end method
.method private declared-synchronized trimTo(I)V
.registers 4
monitor-enter p0
.line 42
:goto_1
:try_start_1
iget v0, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mCurrentSize:I
if-le v0, p1, :cond_20
.line 43
iget-object v0, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mStrategy:Lcom/facebook/imagepipeline/memory/PoolBackend;
invoke-interface {v0}, Lcom/facebook/imagepipeline/memory/PoolBackend;->pop()Ljava/lang/Object;
move-result-object v0
check-cast v0, Landroid/graphics/Bitmap;
if-eqz v0, :cond_20
.line 47
iget-object v1, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mStrategy:Lcom/facebook/imagepipeline/memory/PoolBackend;
invoke-interface {v1, v0}, Lcom/facebook/imagepipeline/memory/PoolBackend;->getSize(Ljava/lang/Object;)I
move-result v0
.line 48
iget v1, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mCurrentSize:I
sub-int/2addr v1, v0
iput v1, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mCurrentSize:I
.line 49
iget-object v1, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mPoolStatsTracker:Lcom/facebook/imagepipeline/memory/PoolStatsTracker;
invoke-interface {v1, v0}, Lcom/facebook/imagepipeline/memory/PoolStatsTracker;->onFree(I)V
:try_end_1f
.catchall {:try_start_1 .. :try_end_1f} :catchall_22
goto :goto_1
.line 52
:cond_20
monitor-exit p0
return-void
:catchall_22
move-exception p1
monitor-exit p0
goto :goto_26
:goto_25
throw p1
:goto_26
goto :goto_25
.end method
# virtual methods
.method public declared-synchronized get(I)Landroid/graphics/Bitmap;
.registers 4
monitor-enter p0
.line 56
:try_start_1
iget v0, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mCurrentSize:I
iget v1, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mMaxPoolSize:I
if-le v0, v1, :cond_c
.line 57
iget v0, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mMaxPoolSize:I
invoke-direct {p0, v0}, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->trimTo(I)V
.line 59
:cond_c
iget-object v0, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mStrategy:Lcom/facebook/imagepipeline/memory/PoolBackend;
invoke-interface {v0, p1}, Lcom/facebook/imagepipeline/memory/PoolBackend;->get(I)Ljava/lang/Object;
move-result-object v0
check-cast v0, Landroid/graphics/Bitmap;
if-eqz v0, :cond_28
.line 61
iget-object p1, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mStrategy:Lcom/facebook/imagepipeline/memory/PoolBackend;
invoke-interface {p1, v0}, Lcom/facebook/imagepipeline/memory/PoolBackend;->getSize(Ljava/lang/Object;)I
move-result p1
.line 62
iget v1, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mCurrentSize:I
sub-int/2addr v1, p1
iput v1, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mCurrentSize:I
.line 63
iget-object v1, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mPoolStatsTracker:Lcom/facebook/imagepipeline/memory/PoolStatsTracker;
invoke-interface {v1, p1}, Lcom/facebook/imagepipeline/memory/PoolStatsTracker;->onValueReuse(I)V
:try_end_26
.catchall {:try_start_1 .. :try_end_26} :catchall_2e
.line 64
monitor-exit p0
return-object v0
.line 66
:cond_28
:try_start_28
invoke-direct {p0, p1}, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->alloc(I)Landroid/graphics/Bitmap;
move-result-object p1
:try_end_2c
.catchall {:try_start_28 .. :try_end_2c} :catchall_2e
monitor-exit p0
return-object p1
:catchall_2e
move-exception p1
monitor-exit p0
throw p1
.end method
.method public bridge synthetic get(I)Ljava/lang/Object;
.registers 2
.line 15
invoke-virtual {p0, p1}, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->get(I)Landroid/graphics/Bitmap;
move-result-object p1
return-object p1
.end method
.method public release(Landroid/graphics/Bitmap;)V
.registers 4
.line 77
iget-object v0, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mStrategy:Lcom/facebook/imagepipeline/memory/PoolBackend;
invoke-interface {v0, p1}, Lcom/facebook/imagepipeline/memory/PoolBackend;->getSize(Ljava/lang/Object;)I
move-result v0
.line 78
iget v1, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mMaxBitmapSize:I
if-gt v0, v1, :cond_1f
.line 79
iget-object v1, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mPoolStatsTracker:Lcom/facebook/imagepipeline/memory/PoolStatsTracker;
invoke-interface {v1, v0}, Lcom/facebook/imagepipeline/memory/PoolStatsTracker;->onValueRelease(I)V
.line 80
iget-object v1, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mStrategy:Lcom/facebook/imagepipeline/memory/PoolBackend;
invoke-interface {v1, p1}, Lcom/facebook/imagepipeline/memory/PoolBackend;->put(Ljava/lang/Object;)V
.line 81
monitor-enter p0
.line 82
:try_start_15
iget p1, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mCurrentSize:I
add-int/2addr p1, v0
iput p1, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mCurrentSize:I
.line 83
monitor-exit p0
return-void
:catchall_1c
move-exception p1
monitor-exit p0
:try_end_1e
.catchall {:try_start_15 .. :try_end_1e} :catchall_1c
throw p1
:cond_1f
return-void
.end method
.method public bridge synthetic release(Ljava/lang/Object;)V
.registers 2
.line 15
check-cast p1, Landroid/graphics/Bitmap;
invoke-virtual {p0, p1}, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->release(Landroid/graphics/Bitmap;)V
return-void
.end method
.method public trim(Lcom/facebook/common/memory/MemoryTrimType;)V
.registers 8
.line 38
iget v0, p0, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->mMaxPoolSize:I
int-to-double v0, v0
invoke-virtual {p1}, Lcom/facebook/common/memory/MemoryTrimType;->getSuggestedTrimRatio()D
move-result-wide v2
const-wide/high16 v4, 0x3ff0000000000000L # 1.0
sub-double/2addr v4, v2
invoke-static {v0, v1}, Ljava/lang/Double;->isNaN(D)Z
mul-double v0, v0, v4
double-to-int p1, v0
invoke-direct {p0, p1}, Lcom/facebook/imagepipeline/memory/LruBitmapPool;->trimTo(I)V
return-void
.end method