SkiaPooledImageRegionDecoder.smali
.class public Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;
.super Ljava/lang/Object;
.source "SkiaPooledImageRegionDecoder.java"
# interfaces
.implements Lio/rong/subscaleview/decoder/ImageRegionDecoder;
# annotations
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
}
.end annotation
# static fields
.field private static final ASSET_PREFIX:Ljava/lang/String; = "file:///android_asset/"
.field private static final FILE_PREFIX:Ljava/lang/String; = "file://"
.field private static final RESOURCE_PREFIX:Ljava/lang/String; = "android.resource://"
.field private static final TAG:Ljava/lang/String; = "SkiaPooledImageRegionDecoder"
.field private static debug:Z
# instance fields
.field private final bitmapConfig:Landroid/graphics/Bitmap$Config;
.field private context:Landroid/content/Context;
.field private final decoderLock:Ljava/util/concurrent/locks/ReadWriteLock;
.field private decoderPool:Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
.field private fileLength:J
.field private final imageDimensions:Landroid/graphics/Point;
.field private final lazyInited:Ljava/util/concurrent/atomic/AtomicBoolean;
.field private uri:Landroid/net/Uri;
# direct methods
.method static constructor <clinit>()V
.registers 0
return-void
.end method
.method public constructor <init>()V
.registers 2
.annotation build Landroidx/annotation/Keep;
.end annotation
const/4 v0, 0x0
.line 1
invoke-direct {p0, v0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;-><init>(Landroid/graphics/Bitmap$Config;)V
return-void
.end method
.method public constructor <init>(Landroid/graphics/Bitmap$Config;)V
.registers 4
.line 2
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 3
new-instance v0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
const/4 v1, 0x0
invoke-direct {v0, v1}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;-><init>(Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$1;)V
iput-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderPool:Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
.line 4
new-instance v0, Ljava/util/concurrent/locks/ReentrantReadWriteLock;
const/4 v1, 0x1
invoke-direct {v0, v1}, Ljava/util/concurrent/locks/ReentrantReadWriteLock;-><init>(Z)V
iput-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderLock:Ljava/util/concurrent/locks/ReadWriteLock;
const-wide v0, 0x7fffffffffffffffL
.line 5
iput-wide v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->fileLength:J
.line 6
new-instance v0, Landroid/graphics/Point;
const/4 v1, 0x0
invoke-direct {v0, v1, v1}, Landroid/graphics/Point;-><init>(II)V
iput-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->imageDimensions:Landroid/graphics/Point;
.line 7
new-instance v0, Ljava/util/concurrent/atomic/AtomicBoolean;
invoke-direct {v0, v1}, Ljava/util/concurrent/atomic/AtomicBoolean;-><init>(Z)V
iput-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->lazyInited:Ljava/util/concurrent/atomic/AtomicBoolean;
.line 8
invoke-static {}, Lio/rong/subscaleview/SubsamplingScaleImageView;->getPreferredBitmapConfig()Landroid/graphics/Bitmap$Config;
move-result-object v0
if-eqz p1, :cond_32
.line 9
iput-object p1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->bitmapConfig:Landroid/graphics/Bitmap$Config;
goto :goto_3b
:cond_32
if-eqz v0, :cond_37
.line 10
iput-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->bitmapConfig:Landroid/graphics/Bitmap$Config;
goto :goto_3b
.line 11
:cond_37
sget-object p1, Landroid/graphics/Bitmap$Config;->RGB_565:Landroid/graphics/Bitmap$Config;
iput-object p1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->bitmapConfig:Landroid/graphics/Bitmap$Config;
:goto_3b
return-void
.end method
.method static synthetic access$100(Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;)Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
.registers 1
.line 1
iget-object p0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderPool:Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
return-object p0
.end method
.method static synthetic access$300(Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;)J
.registers 3
.line 1
iget-wide v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->fileLength:J
return-wide v0
.end method
.method static synthetic access$400(Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;Ljava/lang/String;)V
.registers 2
.line 1
invoke-direct {p0, p1}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->debug(Ljava/lang/String;)V
return-void
.end method
.method static synthetic access$500(Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;)V
.registers 1
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/lang/Exception;
}
.end annotation
.line 1
invoke-direct {p0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->initialiseDecoder()V
return-void
.end method
.method private debug(Ljava/lang/String;)V
.registers 3
.line 1
sget-boolean v0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->debug:Z
if-eqz v0, :cond_9
.line 2
sget-object v0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->TAG:Ljava/lang/String;
invoke-static {v0, p1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I
:cond_9
return-void
.end method
.method private getNumCoresOldPhones()I
.registers 3
.line 1
:try_start_0
new-instance v0, Ljava/io/File;
const-string v1, "/sys/devices/system/cpu/"
invoke-direct {v0, v1}, Ljava/io/File;-><init>(Ljava/lang/String;)V
.line 2
new-instance v1, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$1CpuFilter;
invoke-direct {v1, p0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$1CpuFilter;-><init>(Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;)V
invoke-virtual {v0, v1}, Ljava/io/File;->listFiles(Ljava/io/FileFilter;)[Ljava/io/File;
move-result-object v0
.line 3
array-length v0, v0
:try_end_11
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_11} :catch_12
return v0
:catch_12
const/4 v0, 0x1
return v0
.end method
.method private getNumberOfCores()I
.registers 3
.line 1
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
const/16 v1, 0x11
if-lt v0, v1, :cond_f
.line 2
invoke-static {}, Ljava/lang/Runtime;->getRuntime()Ljava/lang/Runtime;
move-result-object v0
invoke-virtual {v0}, Ljava/lang/Runtime;->availableProcessors()I
move-result v0
return v0
.line 3
:cond_f
invoke-direct {p0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->getNumCoresOldPhones()I
move-result v0
return v0
.end method
.method private initialiseDecoder()V
.registers 11
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/lang/Exception;
}
.end annotation
.line 1
iget-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->uri:Landroid/net/Uri;
invoke-virtual {v0}, Landroid/net/Uri;->toString()Ljava/lang/String;
move-result-object v0
const-string v1, "android.resource://"
.line 2
invoke-virtual {v0, v1}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
move-result v1
const/4 v2, 0x1
const/4 v3, 0x0
const-wide v4, 0x7fffffffffffffffL
if-eqz v1, :cond_96
.line 3
iget-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->uri:Landroid/net/Uri;
invoke-virtual {v0}, Landroid/net/Uri;->getAuthority()Ljava/lang/String;
move-result-object v0
.line 4
iget-object v1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->context:Landroid/content/Context;
invoke-virtual {v1}, Landroid/content/Context;->getPackageName()Ljava/lang/String;
move-result-object v1
invoke-virtual {v1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v1
if-eqz v1, :cond_2e
.line 5
iget-object v1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->context:Landroid/content/Context;
invoke-virtual {v1}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;
move-result-object v1
goto :goto_38
.line 6
:cond_2e
iget-object v1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->context:Landroid/content/Context;
invoke-virtual {v1}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;
move-result-object v1
.line 7
invoke-virtual {v1, v0}, Landroid/content/pm/PackageManager;->getResourcesForApplication(Ljava/lang/String;)Landroid/content/res/Resources;
move-result-object v1
.line 8
:goto_38
iget-object v6, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->uri:Landroid/net/Uri;
invoke-virtual {v6}, Landroid/net/Uri;->getPathSegments()Ljava/util/List;
move-result-object v6
.line 9
invoke-interface {v6}, Ljava/util/List;->size()I
move-result v7
const/4 v8, 0x2
if-ne v7, v8, :cond_5e
.line 10
invoke-interface {v6, v3}, Ljava/util/List;->get(I)Ljava/lang/Object;
move-result-object v8
check-cast v8, Ljava/lang/String;
const-string v9, "drawable"
invoke-virtual {v8, v9}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v8
if-eqz v8, :cond_5e
.line 11
invoke-interface {v6, v2}, Ljava/util/List;->get(I)Ljava/lang/Object;
move-result-object v2
check-cast v2, Ljava/lang/String;
.line 12
invoke-virtual {v1, v2, v9, v0}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I
move-result v0
goto :goto_78
:cond_5e
if-ne v7, v2, :cond_77
.line 13
invoke-interface {v6, v3}, Ljava/util/List;->get(I)Ljava/lang/Object;
move-result-object v0
check-cast v0, Ljava/lang/CharSequence;
invoke-static {v0}, Landroid/text/TextUtils;->isDigitsOnly(Ljava/lang/CharSequence;)Z
move-result v0
if-eqz v0, :cond_77
.line 14
:try_start_6c
invoke-interface {v6, v3}, Ljava/util/List;->get(I)Ljava/lang/Object;
move-result-object v0
check-cast v0, Ljava/lang/String;
invoke-static {v0}, Ljava/lang/Integer;->parseInt(Ljava/lang/String;)I
move-result v0
:try_end_76
.catch Ljava/lang/NumberFormatException; {:try_start_6c .. :try_end_76} :catch_77
goto :goto_78
:catch_77
:cond_77
const/4 v0, 0x0
.line 15
:goto_78
:try_start_78
iget-object v1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->context:Landroid/content/Context;
invoke-virtual {v1}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;
move-result-object v1
invoke-virtual {v1, v0}, Landroid/content/res/Resources;->openRawResourceFd(I)Landroid/content/res/AssetFileDescriptor;
move-result-object v1
.line 16
invoke-virtual {v1}, Landroid/content/res/AssetFileDescriptor;->getLength()J
move-result-wide v4
:try_end_86
.catch Ljava/lang/Exception; {:try_start_78 .. :try_end_86} :catch_86
.line 17
:catch_86
iget-object v1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->context:Landroid/content/Context;
invoke-virtual {v1}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;
move-result-object v1
invoke-virtual {v1, v0}, Landroid/content/res/Resources;->openRawResource(I)Ljava/io/InputStream;
move-result-object v0
invoke-static {v0, v3}, Landroid/graphics/BitmapRegionDecoder;->newInstance(Ljava/io/InputStream;Z)Landroid/graphics/BitmapRegionDecoder;
move-result-object v0
goto/16 :goto_108
:cond_96
const-string v1, "file:///android_asset/"
.line 18
invoke-virtual {v0, v1}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
move-result v1
if-eqz v1, :cond_c1
const/16 v1, 0x16
.line 19
invoke-virtual {v0, v1}, Ljava/lang/String;->substring(I)Ljava/lang/String;
move-result-object v0
.line 20
:try_start_a4
iget-object v1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->context:Landroid/content/Context;
invoke-virtual {v1}, Landroid/content/Context;->getAssets()Landroid/content/res/AssetManager;
move-result-object v1
invoke-virtual {v1, v0}, Landroid/content/res/AssetManager;->openFd(Ljava/lang/String;)Landroid/content/res/AssetFileDescriptor;
move-result-object v1
.line 21
invoke-virtual {v1}, Landroid/content/res/AssetFileDescriptor;->getLength()J
move-result-wide v4
:try_end_b2
.catch Ljava/lang/Exception; {:try_start_a4 .. :try_end_b2} :catch_b2
.line 22
:catch_b2
iget-object v1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->context:Landroid/content/Context;
invoke-virtual {v1}, Landroid/content/Context;->getAssets()Landroid/content/res/AssetManager;
move-result-object v1
invoke-virtual {v1, v0, v2}, Landroid/content/res/AssetManager;->open(Ljava/lang/String;I)Ljava/io/InputStream;
move-result-object v0
invoke-static {v0, v3}, Landroid/graphics/BitmapRegionDecoder;->newInstance(Ljava/io/InputStream;Z)Landroid/graphics/BitmapRegionDecoder;
move-result-object v0
goto :goto_108
:cond_c1
const-string v1, "file://"
.line 23
invoke-virtual {v0, v1}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
move-result v1
if-eqz v1, :cond_e3
const/4 v1, 0x7
.line 24
invoke-virtual {v0, v1}, Ljava/lang/String;->substring(I)Ljava/lang/String;
move-result-object v1
invoke-static {v1, v3}, Landroid/graphics/BitmapRegionDecoder;->newInstance(Ljava/lang/String;Z)Landroid/graphics/BitmapRegionDecoder;
move-result-object v1
.line 25
:try_start_d2
new-instance v2, Ljava/io/File;
invoke-direct {v2, v0}, Ljava/io/File;-><init>(Ljava/lang/String;)V
.line 26
invoke-virtual {v2}, Ljava/io/File;->exists()Z
move-result v0
if-eqz v0, :cond_e1
.line 27
invoke-virtual {v2}, Ljava/io/File;->length()J
move-result-wide v4
:try_end_e1
.catch Ljava/lang/Exception; {:try_start_d2 .. :try_end_e1} :catch_e1
:catch_e1
:cond_e1
move-object v0, v1
goto :goto_108
:cond_e3
const/4 v0, 0x0
.line 28
:try_start_e4
iget-object v1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->context:Landroid/content/Context;
invoke-virtual {v1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v1
.line 29
iget-object v2, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->uri:Landroid/net/Uri;
invoke-virtual {v1, v2}, Landroid/content/ContentResolver;->openInputStream(Landroid/net/Uri;)Ljava/io/InputStream;
move-result-object v0
.line 30
invoke-static {v0, v3}, Landroid/graphics/BitmapRegionDecoder;->newInstance(Ljava/io/InputStream;Z)Landroid/graphics/BitmapRegionDecoder;
move-result-object v2
:try_end_f4
.catchall {:try_start_e4 .. :try_end_f4} :catchall_13e
.line 31
:try_start_f4
iget-object v3, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->uri:Landroid/net/Uri;
const-string v6, "r"
invoke-virtual {v1, v3, v6}, Landroid/content/ContentResolver;->openAssetFileDescriptor(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/res/AssetFileDescriptor;
move-result-object v1
if-eqz v1, :cond_102
.line 32
invoke-virtual {v1}, Landroid/content/res/AssetFileDescriptor;->getLength()J
move-result-wide v4
:try_end_102
.catch Ljava/lang/Exception; {:try_start_f4 .. :try_end_102} :catch_102
.catchall {:try_start_f4 .. :try_end_102} :catchall_13e
:catch_102
:cond_102
if-eqz v0, :cond_107
.line 33
:try_start_104
invoke-virtual {v0}, Ljava/io/InputStream;->close()V
:try_end_107
.catch Ljava/lang/Exception; {:try_start_104 .. :try_end_107} :catch_107
:catch_107
:cond_107
move-object v0, v2
.line 34
:goto_108
iput-wide v4, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->fileLength:J
.line 35
iget-object v1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->imageDimensions:Landroid/graphics/Point;
invoke-virtual {v0}, Landroid/graphics/BitmapRegionDecoder;->getWidth()I
move-result v2
invoke-virtual {v0}, Landroid/graphics/BitmapRegionDecoder;->getHeight()I
move-result v3
invoke-virtual {v1, v2, v3}, Landroid/graphics/Point;->set(II)V
.line 36
iget-object v1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderLock:Ljava/util/concurrent/locks/ReadWriteLock;
invoke-interface {v1}, Ljava/util/concurrent/locks/ReadWriteLock;->writeLock()Ljava/util/concurrent/locks/Lock;
move-result-object v1
invoke-interface {v1}, Ljava/util/concurrent/locks/Lock;->lock()V
.line 37
:try_start_120
iget-object v1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderPool:Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
if-eqz v1, :cond_129
.line 38
iget-object v1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderPool:Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
# invokes: Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;->add(Landroid/graphics/BitmapRegionDecoder;)V
invoke-static {v1, v0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;->access$600(Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;Landroid/graphics/BitmapRegionDecoder;)V
:try_end_129
.catchall {:try_start_120 .. :try_end_129} :catchall_133
.line 39
:cond_129
iget-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderLock:Ljava/util/concurrent/locks/ReadWriteLock;
invoke-interface {v0}, Ljava/util/concurrent/locks/ReadWriteLock;->writeLock()Ljava/util/concurrent/locks/Lock;
move-result-object v0
invoke-interface {v0}, Ljava/util/concurrent/locks/Lock;->unlock()V
return-void
:catchall_133
move-exception v0
iget-object v1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderLock:Ljava/util/concurrent/locks/ReadWriteLock;
invoke-interface {v1}, Ljava/util/concurrent/locks/ReadWriteLock;->writeLock()Ljava/util/concurrent/locks/Lock;
move-result-object v1
invoke-interface {v1}, Ljava/util/concurrent/locks/Lock;->unlock()V
throw v0
:catchall_13e
move-exception v1
if-eqz v0, :cond_144
.line 40
:try_start_141
invoke-virtual {v0}, Ljava/io/InputStream;->close()V
:try_end_144
.catch Ljava/lang/Exception; {:try_start_141 .. :try_end_144} :catch_144
:catch_144
:cond_144
throw v1
.end method
.method private isLowMemory()Z
.registers 3
.line 1
iget-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->context:Landroid/content/Context;
const-string v1, "activity"
invoke-virtual {v0, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;
move-result-object v0
check-cast v0, Landroid/app/ActivityManager;
if-eqz v0, :cond_17
.line 2
new-instance v1, Landroid/app/ActivityManager$MemoryInfo;
invoke-direct {v1}, Landroid/app/ActivityManager$MemoryInfo;-><init>()V
.line 3
invoke-virtual {v0, v1}, Landroid/app/ActivityManager;->getMemoryInfo(Landroid/app/ActivityManager$MemoryInfo;)V
.line 4
iget-boolean v0, v1, Landroid/app/ActivityManager$MemoryInfo;->lowMemory:Z
return v0
:cond_17
const/4 v0, 0x1
return v0
.end method
.method private lazyInit()V
.registers 6
.line 1
iget-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->lazyInited:Ljava/util/concurrent/atomic/AtomicBoolean;
const/4 v1, 0x0
const/4 v2, 0x1
invoke-virtual {v0, v1, v2}, Ljava/util/concurrent/atomic/AtomicBoolean;->compareAndSet(ZZ)Z
move-result v0
if-eqz v0, :cond_22
iget-wide v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->fileLength:J
const-wide v2, 0x7fffffffffffffffL
cmp-long v4, v0, v2
if-gez v4, :cond_22
const-string v0, "Starting lazy init of additional decoders"
.line 2
invoke-direct {p0, v0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->debug(Ljava/lang/String;)V
.line 3
new-instance v0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$1;
invoke-direct {v0, p0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$1;-><init>(Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;)V
.line 4
invoke-virtual {v0}, Ljava/lang/Thread;->start()V
:cond_22
return-void
.end method
.method public static setDebug(Z)V
.registers 1
.annotation build Landroidx/annotation/Keep;
.end annotation
.line 1
sput-boolean p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->debug:Z
return-void
.end method
# virtual methods
.method protected allowAdditionalDecoder(IJ)Z
.registers 9
const/4 v0, 0x0
const/4 v1, 0x4
if-lt p1, v1, :cond_a
const-string p1, "No additional decoders allowed, reached hard limit (4)"
.line 1
invoke-direct {p0, p1}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->debug(Ljava/lang/String;)V
return v0
:cond_a
int-to-long v1, p1
mul-long v1, v1, p2
const-wide/32 p2, 0x1400000
cmp-long v3, v1, p2
if-lez v3, :cond_1a
const-string p1, "No additional encoders allowed, reached hard memory limit (20Mb)"
.line 2
invoke-direct {p0, p1}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->debug(Ljava/lang/String;)V
return v0
.line 3
:cond_1a
invoke-direct {p0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->getNumberOfCores()I
move-result p2
if-lt p1, p2, :cond_3e
.line 4
new-instance p1, Ljava/lang/StringBuilder;
invoke-direct {p1}, Ljava/lang/StringBuilder;-><init>()V
const-string p2, "No additional encoders allowed, limited by CPU cores ("
invoke-virtual {p1, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-direct {p0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->getNumberOfCores()I
move-result p2
invoke-virtual {p1, p2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
const-string p2, ")"
invoke-virtual {p1, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {p1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p1
invoke-direct {p0, p1}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->debug(Ljava/lang/String;)V
return v0
.line 5
:cond_3e
invoke-direct {p0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->isLowMemory()Z
move-result p2
if-eqz p2, :cond_4a
const-string p1, "No additional encoders allowed, memory is low"
.line 6
invoke-direct {p0, p1}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->debug(Ljava/lang/String;)V
return v0
.line 7
:cond_4a
new-instance p2, Ljava/lang/StringBuilder;
invoke-direct {p2}, Ljava/lang/StringBuilder;-><init>()V
const-string p3, "Additional decoder allowed, current count is "
invoke-virtual {p2, p3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {p2, p1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
const-string p1, ", estimated native memory "
invoke-virtual {p2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-wide/32 v3, 0x100000
div-long/2addr v1, v3
invoke-virtual {p2, v1, v2}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
const-string p1, "Mb"
invoke-virtual {p2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {p2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p1
invoke-direct {p0, p1}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->debug(Ljava/lang/String;)V
const/4 p1, 0x1
return p1
.end method
.method public decodeRegion(Landroid/graphics/Rect;I)Landroid/graphics/Bitmap;
.registers 5
.line 1
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
const-string v1, "Decode region "
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
const-string v1, " on thread "
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/Thread;->getName()Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v0
invoke-direct {p0, v0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->debug(Ljava/lang/String;)V
.line 2
invoke-virtual {p1}, Landroid/graphics/Rect;->width()I
move-result v0
iget-object v1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->imageDimensions:Landroid/graphics/Point;
iget v1, v1, Landroid/graphics/Point;->x:I
if-lt v0, v1, :cond_38
invoke-virtual {p1}, Landroid/graphics/Rect;->height()I
move-result v0
iget-object v1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->imageDimensions:Landroid/graphics/Point;
iget v1, v1, Landroid/graphics/Point;->y:I
if-ge v0, v1, :cond_3b
.line 3
:cond_38
invoke-direct {p0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->lazyInit()V
.line 4
:cond_3b
iget-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderLock:Ljava/util/concurrent/locks/ReadWriteLock;
invoke-interface {v0}, Ljava/util/concurrent/locks/ReadWriteLock;->readLock()Ljava/util/concurrent/locks/Lock;
move-result-object v0
invoke-interface {v0}, Ljava/util/concurrent/locks/Lock;->lock()V
.line 5
:try_start_44
iget-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderPool:Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
if-eqz v0, :cond_90
.line 6
iget-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderPool:Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
# invokes: Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;->acquire()Landroid/graphics/BitmapRegionDecoder;
invoke-static {v0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;->access$700(Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;)Landroid/graphics/BitmapRegionDecoder;
move-result-object v0
:try_end_4e
.catchall {:try_start_44 .. :try_end_4e} :catchall_98
if-eqz v0, :cond_89
.line 7
:try_start_50
invoke-virtual {v0}, Landroid/graphics/BitmapRegionDecoder;->isRecycled()Z
move-result v1
if-nez v1, :cond_89
.line 8
new-instance v1, Landroid/graphics/BitmapFactory$Options;
invoke-direct {v1}, Landroid/graphics/BitmapFactory$Options;-><init>()V
.line 9
iput p2, v1, Landroid/graphics/BitmapFactory$Options;->inSampleSize:I
.line 10
iget-object p2, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->bitmapConfig:Landroid/graphics/Bitmap$Config;
iput-object p2, v1, Landroid/graphics/BitmapFactory$Options;->inPreferredConfig:Landroid/graphics/Bitmap$Config;
.line 11
invoke-virtual {v0, p1, v1}, Landroid/graphics/BitmapRegionDecoder;->decodeRegion(Landroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
move-result-object p1
:try_end_65
.catchall {:try_start_50 .. :try_end_65} :catchall_80
if-eqz p1, :cond_78
if-eqz v0, :cond_6e
.line 12
:try_start_69
iget-object p2, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderPool:Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
# invokes: Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;->release(Landroid/graphics/BitmapRegionDecoder;)V
invoke-static {p2, v0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;->access$800(Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;Landroid/graphics/BitmapRegionDecoder;)V
:try_end_6e
.catchall {:try_start_69 .. :try_end_6e} :catchall_98
.line 13
:cond_6e
iget-object p2, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderLock:Ljava/util/concurrent/locks/ReadWriteLock;
invoke-interface {p2}, Ljava/util/concurrent/locks/ReadWriteLock;->readLock()Ljava/util/concurrent/locks/Lock;
move-result-object p2
invoke-interface {p2}, Ljava/util/concurrent/locks/Lock;->unlock()V
return-object p1
.line 14
:cond_78
:try_start_78
new-instance p1, Ljava/lang/RuntimeException;
const-string p2, "Skia image decoder returned null bitmap - image format may not be supported"
invoke-direct {p1, p2}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V
throw p1
:try_end_80
.catchall {:try_start_78 .. :try_end_80} :catchall_80
:catchall_80
move-exception p1
if-eqz v0, :cond_88
.line 15
:try_start_83
iget-object p2, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderPool:Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
# invokes: Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;->release(Landroid/graphics/BitmapRegionDecoder;)V
invoke-static {p2, v0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;->access$800(Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;Landroid/graphics/BitmapRegionDecoder;)V
:cond_88
throw p1
:cond_89
if-eqz v0, :cond_90
iget-object p1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderPool:Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
# invokes: Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;->release(Landroid/graphics/BitmapRegionDecoder;)V
invoke-static {p1, v0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;->access$800(Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;Landroid/graphics/BitmapRegionDecoder;)V
.line 16
:cond_90
new-instance p1, Ljava/lang/IllegalStateException;
const-string p2, "Cannot decode region after decoder has been recycled"
invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p1
:try_end_98
.catchall {:try_start_83 .. :try_end_98} :catchall_98
:catchall_98
move-exception p1
.line 17
iget-object p2, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderLock:Ljava/util/concurrent/locks/ReadWriteLock;
invoke-interface {p2}, Ljava/util/concurrent/locks/ReadWriteLock;->readLock()Ljava/util/concurrent/locks/Lock;
move-result-object p2
invoke-interface {p2}, Ljava/util/concurrent/locks/Lock;->unlock()V
throw p1
.end method
.method public init(Landroid/content/Context;Landroid/net/Uri;)Landroid/graphics/Point;
.registers 3
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/lang/Exception;
}
.end annotation
.line 1
iput-object p1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->context:Landroid/content/Context;
.line 2
iput-object p2, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->uri:Landroid/net/Uri;
.line 3
invoke-direct {p0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->initialiseDecoder()V
.line 4
iget-object p1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->imageDimensions:Landroid/graphics/Point;
return-object p1
.end method
.method public declared-synchronized isReady()Z
.registers 2
monitor-enter p0
.line 1
:try_start_1
iget-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderPool:Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
if-eqz v0, :cond_f
iget-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderPool:Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
# invokes: Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;->isEmpty()Z
invoke-static {v0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;->access$900(Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;)Z
move-result v0
:try_end_b
.catchall {:try_start_1 .. :try_end_b} :catchall_12
if-nez v0, :cond_f
const/4 v0, 0x1
goto :goto_10
:cond_f
const/4 v0, 0x0
:goto_10
monitor-exit p0
return v0
:catchall_12
move-exception v0
monitor-exit p0
throw v0
.end method
.method public declared-synchronized recycle()V
.registers 3
monitor-enter p0
.line 1
:try_start_1
iget-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderLock:Ljava/util/concurrent/locks/ReadWriteLock;
invoke-interface {v0}, Ljava/util/concurrent/locks/ReadWriteLock;->writeLock()Ljava/util/concurrent/locks/Lock;
move-result-object v0
invoke-interface {v0}, Ljava/util/concurrent/locks/Lock;->lock()V
:try_end_a
.catchall {:try_start_1 .. :try_end_a} :catchall_30
.line 2
:try_start_a
iget-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderPool:Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
if-eqz v0, :cond_1a
.line 3
iget-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderPool:Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
# invokes: Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;->recycle()V
invoke-static {v0}, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;->access$1000(Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;)V
const/4 v0, 0x0
.line 4
iput-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderPool:Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder$DecoderPool;
.line 5
iput-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->context:Landroid/content/Context;
.line 6
iput-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->uri:Landroid/net/Uri;
:try_end_1a
.catchall {:try_start_a .. :try_end_1a} :catchall_25
.line 7
:cond_1a
:try_start_1a
iget-object v0, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderLock:Ljava/util/concurrent/locks/ReadWriteLock;
invoke-interface {v0}, Ljava/util/concurrent/locks/ReadWriteLock;->writeLock()Ljava/util/concurrent/locks/Lock;
move-result-object v0
invoke-interface {v0}, Ljava/util/concurrent/locks/Lock;->unlock()V
:try_end_23
.catchall {:try_start_1a .. :try_end_23} :catchall_30
.line 8
monitor-exit p0
return-void
:catchall_25
move-exception v0
.line 9
:try_start_26
iget-object v1, p0, Lio/rong/subscaleview/decoder/SkiaPooledImageRegionDecoder;->decoderLock:Ljava/util/concurrent/locks/ReadWriteLock;
invoke-interface {v1}, Ljava/util/concurrent/locks/ReadWriteLock;->writeLock()Ljava/util/concurrent/locks/Lock;
move-result-object v1
invoke-interface {v1}, Ljava/util/concurrent/locks/Lock;->unlock()V
throw v0
:try_end_30
.catchall {:try_start_26 .. :try_end_30} :catchall_30
:catchall_30
move-exception v0
monitor-exit p0
throw v0
.end method