DalvikPurgeableDecoder.smali
.class public abstract Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;
.super Ljava/lang/Object;
.source "SourceFile"
# interfaces
.implements Lcom/facebook/imagepipeline/platform/PlatformDecoder;
# annotations
.annotation build Lcom/facebook/common/internal/DoNotStrip;
.end annotation
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder$OreoUtils;
}
.end annotation
# static fields
.field public static final EOI:[B
# instance fields
.field private final mUnpooledBitmapsCounter:Lcom/facebook/imagepipeline/memory/BitmapCounter;
# direct methods
.method public static constructor <clinit>()V
.registers 1
.line 1
invoke-static {}, Lcom/facebook/imagepipeline/nativecode/ImagePipelineNativeLoader;->load()V
const/4 v0, 0x2
new-array v0, v0, [B
.line 2
fill-array-data v0, :array_c
sput-object v0, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;->EOI:[B
return-void
:array_c
.array-data 1
-0x1t
-0x27t
.end array-data
.end method
.method public constructor <init>()V
.registers 2
.line 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 2
invoke-static {}, Lcom/facebook/imagepipeline/memory/BitmapCounterProvider;->get()Lcom/facebook/imagepipeline/memory/BitmapCounter;
move-result-object v0
iput-object v0, p0, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;->mUnpooledBitmapsCounter:Lcom/facebook/imagepipeline/memory/BitmapCounter;
return-void
.end method
.method public static endsWithEOI(Lcom/facebook/common/references/CloseableReference;I)Z
.registers 5
.annotation build Lcom/facebook/common/internal/VisibleForTesting;
.end annotation
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/facebook/common/references/CloseableReference<",
"Lcom/facebook/common/memory/PooledByteBuffer;",
">;I)Z"
}
.end annotation
.line 1
invoke-virtual {p0}, Lcom/facebook/common/references/CloseableReference;->get()Ljava/lang/Object;
move-result-object p0
check-cast p0, Lcom/facebook/common/memory/PooledByteBuffer;
const/4 v0, 0x1
const/4 v1, 0x2
if-lt p1, v1, :cond_1d
add-int/lit8 v1, p1, -0x2
.line 2
invoke-interface {p0, v1}, Lcom/facebook/common/memory/PooledByteBuffer;->read(I)B
move-result v1
const/4 v2, -0x1
if-ne v1, v2, :cond_1d
sub-int/2addr p1, v0
.line 3
invoke-interface {p0, p1}, Lcom/facebook/common/memory/PooledByteBuffer;->read(I)B
move-result p0
const/16 p1, -0x27
if-ne p0, p1, :cond_1d
goto :goto_1e
:cond_1d
const/4 v0, 0x0
:goto_1e
return v0
.end method
.method public static getBitmapFactoryOptions(ILandroid/graphics/Bitmap$Config;)Landroid/graphics/BitmapFactory$Options;
.registers 4
.annotation build Lcom/facebook/common/internal/VisibleForTesting;
.end annotation
.line 1
new-instance v0, Landroid/graphics/BitmapFactory$Options;
invoke-direct {v0}, Landroid/graphics/BitmapFactory$Options;-><init>()V
const/4 v1, 0x1
.line 2
iput-boolean v1, v0, Landroid/graphics/BitmapFactory$Options;->inDither:Z
.line 3
iput-object p1, v0, Landroid/graphics/BitmapFactory$Options;->inPreferredConfig:Landroid/graphics/Bitmap$Config;
.line 4
iput-boolean v1, v0, Landroid/graphics/BitmapFactory$Options;->inPurgeable:Z
.line 5
iput-boolean v1, v0, Landroid/graphics/BitmapFactory$Options;->inInputShareable:Z
.line 6
iput p0, v0, Landroid/graphics/BitmapFactory$Options;->inSampleSize:I
.line 7
iput-boolean v1, v0, Landroid/graphics/BitmapFactory$Options;->inMutable:Z
return-object v0
.end method
.method private static native nativePinBitmap(Landroid/graphics/Bitmap;)V
.annotation build Lcom/facebook/common/internal/DoNotStrip;
.end annotation
.end method
# virtual methods
.method public abstract decodeByteArrayAsPurgeable(Lcom/facebook/common/references/CloseableReference;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/facebook/common/references/CloseableReference<",
"Lcom/facebook/common/memory/PooledByteBuffer;",
">;",
"Landroid/graphics/BitmapFactory$Options;",
")",
"Landroid/graphics/Bitmap;"
}
.end annotation
.end method
.method public decodeFromEncodedImage(Lcom/facebook/imagepipeline/image/EncodedImage;Landroid/graphics/Bitmap$Config;Landroid/graphics/Rect;)Lcom/facebook/common/references/CloseableReference;
.registers 5
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/facebook/imagepipeline/image/EncodedImage;",
"Landroid/graphics/Bitmap$Config;",
"Landroid/graphics/Rect;",
")",
"Lcom/facebook/common/references/CloseableReference<",
"Landroid/graphics/Bitmap;",
">;"
}
.end annotation
const/4 v0, 0x0
invoke-virtual {p0, p1, p2, p3, v0}, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;->decodeFromEncodedImageWithColorSpace(Lcom/facebook/imagepipeline/image/EncodedImage;Landroid/graphics/Bitmap$Config;Landroid/graphics/Rect;Landroid/graphics/ColorSpace;)Lcom/facebook/common/references/CloseableReference;
move-result-object p1
return-object p1
.end method
.method public decodeFromEncodedImageWithColorSpace(Lcom/facebook/imagepipeline/image/EncodedImage;Landroid/graphics/Bitmap$Config;Landroid/graphics/Rect;Landroid/graphics/ColorSpace;)Lcom/facebook/common/references/CloseableReference;
.registers 6
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/facebook/imagepipeline/image/EncodedImage;",
"Landroid/graphics/Bitmap$Config;",
"Landroid/graphics/Rect;",
"Landroid/graphics/ColorSpace;",
")",
"Lcom/facebook/common/references/CloseableReference<",
"Landroid/graphics/Bitmap;",
">;"
}
.end annotation
.line 1
invoke-virtual {p1}, Lcom/facebook/imagepipeline/image/EncodedImage;->getSampleSize()I
move-result p3
.line 2
invoke-static {p3, p2}, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;->getBitmapFactoryOptions(ILandroid/graphics/Bitmap$Config;)Landroid/graphics/BitmapFactory$Options;
move-result-object p2
.line 3
sget p3, Landroid/os/Build$VERSION;->SDK_INT:I
const/16 v0, 0x1a
if-lt p3, v0, :cond_11
.line 4
invoke-static {p2, p4}, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder$OreoUtils;->setColorSpace(Landroid/graphics/BitmapFactory$Options;Landroid/graphics/ColorSpace;)V
.line 5
:cond_11
invoke-virtual {p1}, Lcom/facebook/imagepipeline/image/EncodedImage;->getByteBufferRef()Lcom/facebook/common/references/CloseableReference;
move-result-object p1
.line 6
invoke-static {p1}, Lcom/facebook/common/internal/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object;
.line 7
:try_start_18
invoke-virtual {p0, p1, p2}, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;->decodeByteArrayAsPurgeable(Lcom/facebook/common/references/CloseableReference;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
move-result-object p2
.line 8
invoke-virtual {p0, p2}, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;->pinBitmap(Landroid/graphics/Bitmap;)Lcom/facebook/common/references/CloseableReference;
move-result-object p2
:try_end_20
.catchall {:try_start_18 .. :try_end_20} :catchall_24
.line 9
invoke-static {p1}, Lcom/facebook/common/references/CloseableReference;->closeSafely(Lcom/facebook/common/references/CloseableReference;)V
return-object p2
:catchall_24
move-exception p2
invoke-static {p1}, Lcom/facebook/common/references/CloseableReference;->closeSafely(Lcom/facebook/common/references/CloseableReference;)V
.line 10
throw p2
.end method
.method public abstract decodeJPEGByteArrayAsPurgeable(Lcom/facebook/common/references/CloseableReference;ILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/facebook/common/references/CloseableReference<",
"Lcom/facebook/common/memory/PooledByteBuffer;",
">;I",
"Landroid/graphics/BitmapFactory$Options;",
")",
"Landroid/graphics/Bitmap;"
}
.end annotation
.end method
.method public decodeJPEGFromEncodedImage(Lcom/facebook/imagepipeline/image/EncodedImage;Landroid/graphics/Bitmap$Config;Landroid/graphics/Rect;I)Lcom/facebook/common/references/CloseableReference;
.registers 11
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/facebook/imagepipeline/image/EncodedImage;",
"Landroid/graphics/Bitmap$Config;",
"Landroid/graphics/Rect;",
"I)",
"Lcom/facebook/common/references/CloseableReference<",
"Landroid/graphics/Bitmap;",
">;"
}
.end annotation
const/4 v5, 0x0
move-object v0, p0
move-object v1, p1
move-object v2, p2
move-object v3, p3
move v4, p4
invoke-virtual/range {v0 .. v5}, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;->decodeJPEGFromEncodedImageWithColorSpace(Lcom/facebook/imagepipeline/image/EncodedImage;Landroid/graphics/Bitmap$Config;Landroid/graphics/Rect;ILandroid/graphics/ColorSpace;)Lcom/facebook/common/references/CloseableReference;
move-result-object p1
return-object p1
.end method
.method public decodeJPEGFromEncodedImageWithColorSpace(Lcom/facebook/imagepipeline/image/EncodedImage;Landroid/graphics/Bitmap$Config;Landroid/graphics/Rect;ILandroid/graphics/ColorSpace;)Lcom/facebook/common/references/CloseableReference;
.registers 7
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/facebook/imagepipeline/image/EncodedImage;",
"Landroid/graphics/Bitmap$Config;",
"Landroid/graphics/Rect;",
"I",
"Landroid/graphics/ColorSpace;",
")",
"Lcom/facebook/common/references/CloseableReference<",
"Landroid/graphics/Bitmap;",
">;"
}
.end annotation
.line 1
invoke-virtual {p1}, Lcom/facebook/imagepipeline/image/EncodedImage;->getSampleSize()I
move-result p3
.line 2
invoke-static {p3, p2}, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;->getBitmapFactoryOptions(ILandroid/graphics/Bitmap$Config;)Landroid/graphics/BitmapFactory$Options;
move-result-object p2
.line 3
sget p3, Landroid/os/Build$VERSION;->SDK_INT:I
const/16 v0, 0x1a
if-lt p3, v0, :cond_11
.line 4
invoke-static {p2, p5}, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder$OreoUtils;->setColorSpace(Landroid/graphics/BitmapFactory$Options;Landroid/graphics/ColorSpace;)V
.line 5
:cond_11
invoke-virtual {p1}, Lcom/facebook/imagepipeline/image/EncodedImage;->getByteBufferRef()Lcom/facebook/common/references/CloseableReference;
move-result-object p1
.line 6
invoke-static {p1}, Lcom/facebook/common/internal/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object;
.line 7
:try_start_18
invoke-virtual {p0, p1, p4, p2}, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;->decodeJPEGByteArrayAsPurgeable(Lcom/facebook/common/references/CloseableReference;ILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
move-result-object p2
.line 8
invoke-virtual {p0, p2}, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;->pinBitmap(Landroid/graphics/Bitmap;)Lcom/facebook/common/references/CloseableReference;
move-result-object p2
:try_end_20
.catchall {:try_start_18 .. :try_end_20} :catchall_24
.line 9
invoke-static {p1}, Lcom/facebook/common/references/CloseableReference;->closeSafely(Lcom/facebook/common/references/CloseableReference;)V
return-object p2
:catchall_24
move-exception p2
invoke-static {p1}, Lcom/facebook/common/references/CloseableReference;->closeSafely(Lcom/facebook/common/references/CloseableReference;)V
.line 10
throw p2
.end method
.method public pinBitmap(Landroid/graphics/Bitmap;)Lcom/facebook/common/references/CloseableReference;
.registers 6
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Landroid/graphics/Bitmap;",
")",
"Lcom/facebook/common/references/CloseableReference<",
"Landroid/graphics/Bitmap;",
">;"
}
.end annotation
.line 1
invoke-static {p1}, Lcom/facebook/common/internal/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object;
.line 2
:try_start_3
invoke-static {p1}, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;->nativePinBitmap(Landroid/graphics/Bitmap;)V
:try_end_6
.catch Ljava/lang/Exception; {:try_start_3 .. :try_end_6} :catch_6c
.line 3
iget-object v0, p0, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;->mUnpooledBitmapsCounter:Lcom/facebook/imagepipeline/memory/BitmapCounter;
invoke-virtual {v0, p1}, Lcom/facebook/imagepipeline/memory/BitmapCounter;->increase(Landroid/graphics/Bitmap;)Z
move-result v0
if-eqz v0, :cond_19
.line 4
iget-object v0, p0, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;->mUnpooledBitmapsCounter:Lcom/facebook/imagepipeline/memory/BitmapCounter;
invoke-virtual {v0}, Lcom/facebook/imagepipeline/memory/BitmapCounter;->getReleaser()Lcom/facebook/common/references/ResourceReleaser;
move-result-object v0
invoke-static {p1, v0}, Lcom/facebook/common/references/CloseableReference;->of(Ljava/lang/Object;Lcom/facebook/common/references/ResourceReleaser;)Lcom/facebook/common/references/CloseableReference;
move-result-object p1
return-object p1
.line 5
:cond_19
invoke-static {p1}, Lcom/facebook/imageutils/BitmapUtil;->getSizeInBytes(Landroid/graphics/Bitmap;)I
move-result v0
.line 6
invoke-virtual {p1}, Landroid/graphics/Bitmap;->recycle()V
.line 7
sget-object p1, Ljava/util/Locale;->US:Ljava/util/Locale;
const/4 v1, 0x5
new-array v1, v1, [Ljava/lang/Object;
const/4 v2, 0x0
.line 8
invoke-static {v0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v0
aput-object v0, v1, v2
const/4 v0, 0x1
iget-object v2, p0, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;->mUnpooledBitmapsCounter:Lcom/facebook/imagepipeline/memory/BitmapCounter;
.line 9
invoke-virtual {v2}, Lcom/facebook/imagepipeline/memory/BitmapCounter;->getCount()I
move-result v2
invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v2
aput-object v2, v1, v0
const/4 v0, 0x2
iget-object v2, p0, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;->mUnpooledBitmapsCounter:Lcom/facebook/imagepipeline/memory/BitmapCounter;
.line 10
invoke-virtual {v2}, Lcom/facebook/imagepipeline/memory/BitmapCounter;->getSize()J
move-result-wide v2
invoke-static {v2, v3}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v2
aput-object v2, v1, v0
const/4 v0, 0x3
iget-object v2, p0, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;->mUnpooledBitmapsCounter:Lcom/facebook/imagepipeline/memory/BitmapCounter;
.line 11
invoke-virtual {v2}, Lcom/facebook/imagepipeline/memory/BitmapCounter;->getMaxCount()I
move-result v2
invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v2
aput-object v2, v1, v0
const/4 v0, 0x4
iget-object v2, p0, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;->mUnpooledBitmapsCounter:Lcom/facebook/imagepipeline/memory/BitmapCounter;
.line 12
invoke-virtual {v2}, Lcom/facebook/imagepipeline/memory/BitmapCounter;->getMaxSize()I
move-result v2
invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v2
aput-object v2, v1, v0
const-string v0, "Attempted to pin a bitmap of size %d bytes. The current pool count is %d, the current pool size is %d bytes. The current pool max count is %d, the current pool max size is %d bytes."
.line 13
invoke-static {p1, v0, v1}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object p1
.line 14
new-instance v0, Lcom/facebook/imagepipeline/common/TooManyBitmapsException;
invoke-direct {v0, p1}, Lcom/facebook/imagepipeline/common/TooManyBitmapsException;-><init>(Ljava/lang/String;)V
throw v0
:catch_6c
move-exception v0
.line 15
invoke-virtual {p1}, Landroid/graphics/Bitmap;->recycle()V
.line 16
invoke-static {v0}, Lcom/facebook/common/internal/Throwables;->propagate(Ljava/lang/Throwable;)Ljava/lang/RuntimeException;
move-result-object p1
throw p1
.end method