BufferMemoryChunk.smali
.class public Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;
.super Ljava/lang/Object;
.source "BufferMemoryChunk.java"
# interfaces
.implements Lcom/facebook/imagepipeline/memory/MemoryChunk;
.implements Ljava/io/Closeable;
# static fields
.field private static final TAG:Ljava/lang/String; = "BufferMemoryChunk"
# instance fields
.field private mBuffer:Ljava/nio/ByteBuffer;
.field private final mId:J
.field private final mSize:I
# direct methods
.method public constructor <init>(I)V
.registers 4
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x10
}
names = {
"size"
}
.end annotation
.line 35
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 36
invoke-static {p1}, Ljava/nio/ByteBuffer;->allocateDirect(I)Ljava/nio/ByteBuffer;
move-result-object v0
iput-object v0, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mBuffer:Ljava/nio/ByteBuffer;
.line 37
iput p1, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mSize:I
.line 38
invoke-static {p0}, Ljava/lang/System;->identityHashCode(Ljava/lang/Object;)I
move-result p1
int-to-long v0, p1
iput-wide v0, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mId:J
return-void
.end method
.method private doCopy(ILcom/facebook/imagepipeline/memory/MemoryChunk;II)V
.registers 7
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x10,
0x10,
0x10,
0x10
}
names = {
"offset",
"other",
"otherOffset",
"count"
}
.end annotation
.line 154
instance-of v0, p2, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;
if-eqz v0, :cond_3b
.line 157
invoke-virtual {p0}, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->isClosed()Z
move-result v0
xor-int/lit8 v0, v0, 0x1
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkState(Z)V
.line 158
invoke-interface {p2}, Lcom/facebook/imagepipeline/memory/MemoryChunk;->isClosed()Z
move-result v0
xor-int/lit8 v0, v0, 0x1
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkState(Z)V
.line 159
invoke-interface {p2}, Lcom/facebook/imagepipeline/memory/MemoryChunk;->getSize()I
move-result v0
iget v1, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mSize:I
invoke-static {p1, v0, p3, p4, v1}, Lcom/facebook/imagepipeline/memory/MemoryChunkUtil;->checkBounds(IIIII)V
.line 160
iget-object v0, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mBuffer:Ljava/nio/ByteBuffer;
invoke-virtual {v0, p1}, Ljava/nio/ByteBuffer;->position(I)Ljava/nio/Buffer;
.line 162
invoke-interface {p2}, Lcom/facebook/imagepipeline/memory/MemoryChunk;->getByteBuffer()Ljava/nio/ByteBuffer;
move-result-object p1
invoke-virtual {p1, p3}, Ljava/nio/ByteBuffer;->position(I)Ljava/nio/Buffer;
.line 165
new-array p1, p4, [B
.line 166
iget-object p3, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mBuffer:Ljava/nio/ByteBuffer;
const/4 v0, 0x0
invoke-virtual {p3, p1, v0, p4}, Ljava/nio/ByteBuffer;->get([BII)Ljava/nio/ByteBuffer;
.line 167
invoke-interface {p2}, Lcom/facebook/imagepipeline/memory/MemoryChunk;->getByteBuffer()Ljava/nio/ByteBuffer;
move-result-object p2
invoke-virtual {p2, p1, v0, p4}, Ljava/nio/ByteBuffer;->put([BII)Ljava/nio/ByteBuffer;
return-void
.line 155
:cond_3b
new-instance p1, Ljava/lang/IllegalArgumentException;
const-string p2, "Cannot copy two incompatible MemoryChunks"
invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
throw p1
.end method
# virtual methods
.method public declared-synchronized close()V
.registers 2
monitor-enter p0
const/4 v0, 0x0
.line 43
:try_start_2
iput-object v0, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mBuffer:Ljava/nio/ByteBuffer;
:try_end_4
.catchall {:try_start_2 .. :try_end_4} :catchall_6
.line 44
monitor-exit p0
return-void
:catchall_6
move-exception v0
monitor-exit p0
throw v0
.end method
.method public copy(ILcom/facebook/imagepipeline/memory/MemoryChunk;II)V
.registers 9
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x10,
0x10,
0x10,
0x10
}
names = {
"offset",
"other",
"otherOffset",
"count"
}
.end annotation
.line 93
invoke-static {p2}, Lcom/facebook/common/internal/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object;
.line 101
invoke-interface {p2}, Lcom/facebook/imagepipeline/memory/MemoryChunk;->getUniqueId()J
move-result-wide v0
invoke-virtual {p0}, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->getUniqueId()J
move-result-wide v2
cmp-long v0, v0, v2
if-nez v0, :cond_4a
const-string v0, "BufferMemoryChunk"
.line 104
new-instance v1, Ljava/lang/StringBuilder;
invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
const-string v2, "Copying from BufferMemoryChunk "
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
.line 107
invoke-virtual {p0}, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->getUniqueId()J
move-result-wide v2
invoke-static {v2, v3}, Ljava/lang/Long;->toHexString(J)Ljava/lang/String;
move-result-object v2
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string v2, " to BufferMemoryChunk "
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
.line 109
invoke-interface {p2}, Lcom/facebook/imagepipeline/memory/MemoryChunk;->getUniqueId()J
move-result-wide v2
invoke-static {v2, v3}, Ljava/lang/Long;->toHexString(J)Ljava/lang/String;
move-result-object v2
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string v2, " which are the same "
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
.line 104
invoke-static {v0, v1}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
const/4 v0, 0x0
.line 111
invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
move-result-object v0
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkArgument(Ljava/lang/Boolean;)V
.line 115
:cond_4a
invoke-interface {p2}, Lcom/facebook/imagepipeline/memory/MemoryChunk;->getUniqueId()J
move-result-wide v0
invoke-virtual {p0}, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->getUniqueId()J
move-result-wide v2
cmp-long v0, v0, v2
if-gez v0, :cond_64
.line 116
monitor-enter p2
.line 117
:try_start_57
monitor-enter p0
:try_end_58
.catchall {:try_start_57 .. :try_end_58} :catchall_61
.line 118
:try_start_58
invoke-direct {p0, p1, p2, p3, p4}, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->doCopy(ILcom/facebook/imagepipeline/memory/MemoryChunk;II)V
.line 119
monitor-exit p0
:try_end_5c
.catchall {:try_start_58 .. :try_end_5c} :catchall_5e
.line 120
:try_start_5c
monitor-exit p2
:try_end_5d
.catchall {:try_start_5c .. :try_end_5d} :catchall_61
return-void
:catchall_5e
move-exception p1
.line 119
:try_start_5f
monitor-exit p0
:try_end_60
.catchall {:try_start_5f .. :try_end_60} :catchall_5e
:try_start_60
throw p1
:catchall_61
move-exception p1
.line 120
monitor-exit p2
:try_end_63
.catchall {:try_start_60 .. :try_end_63} :catchall_61
throw p1
.line 125
:cond_64
monitor-enter p0
.line 126
:try_start_65
monitor-enter p2
:try_end_66
.catchall {:try_start_65 .. :try_end_66} :catchall_6f
.line 127
:try_start_66
invoke-direct {p0, p1, p2, p3, p4}, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->doCopy(ILcom/facebook/imagepipeline/memory/MemoryChunk;II)V
.line 128
monitor-exit p2
:try_end_6a
.catchall {:try_start_66 .. :try_end_6a} :catchall_6c
.line 129
:try_start_6a
monitor-exit p0
:try_end_6b
.catchall {:try_start_6a .. :try_end_6b} :catchall_6f
return-void
:catchall_6c
move-exception p1
.line 128
:try_start_6d
monitor-exit p2
:try_end_6e
.catchall {:try_start_6d .. :try_end_6e} :catchall_6c
:try_start_6e
throw p1
:catchall_6f
move-exception p1
.line 129
monitor-exit p0
:try_end_71
.catchall {:try_start_6e .. :try_end_71} :catchall_6f
throw p1
.end method
.method public declared-synchronized getByteBuffer()Ljava/nio/ByteBuffer;
.registers 2
.annotation runtime Ljavax/annotation/Nullable;
.end annotation
monitor-enter p0
.line 140
:try_start_1
iget-object v0, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mBuffer:Ljava/nio/ByteBuffer;
:try_end_3
.catchall {:try_start_1 .. :try_end_3} :catchall_5
monitor-exit p0
return-object v0
:catchall_5
move-exception v0
monitor-exit p0
throw v0
.end method
.method public getNativePtr()J
.registers 3
.line 134
new-instance v0, Ljava/lang/UnsupportedOperationException;
const-string v1, "Cannot get the pointer of a BufferMemoryChunk"
invoke-direct {v0, v1}, Ljava/lang/UnsupportedOperationException;-><init>(Ljava/lang/String;)V
throw v0
.end method
.method public getSize()I
.registers 2
.line 53
iget v0, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mSize:I
return v0
.end method
.method public getUniqueId()J
.registers 3
.line 145
iget-wide v0, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mId:J
return-wide v0
.end method
.method public declared-synchronized isClosed()Z
.registers 2
monitor-enter p0
.line 48
:try_start_1
iget-object v0, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mBuffer:Ljava/nio/ByteBuffer;
:try_end_3
.catchall {:try_start_1 .. :try_end_3} :catchall_a
if-nez v0, :cond_7
const/4 v0, 0x1
goto :goto_8
:cond_7
const/4 v0, 0x0
:goto_8
monitor-exit p0
return v0
:catchall_a
move-exception v0
monitor-exit p0
throw v0
.end method
.method public declared-synchronized read(I)B
.registers 5
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x10
}
names = {
"offset"
}
.end annotation
monitor-enter p0
.line 84
:try_start_1
invoke-virtual {p0}, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->isClosed()Z
move-result v0
const/4 v1, 0x1
const/4 v2, 0x0
if-nez v0, :cond_b
move v0, v1
goto :goto_c
:cond_b
move v0, v2
:goto_c
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkState(Z)V
if-ltz p1, :cond_13
move v0, v1
goto :goto_14
:cond_13
move v0, v2
.line 85
:goto_14
invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
move-result-object v0
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkArgument(Ljava/lang/Boolean;)V
.line 86
iget v0, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mSize:I
if-ge p1, v0, :cond_20
goto :goto_21
:cond_20
move v1, v2
:goto_21
invoke-static {v1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
move-result-object v0
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkArgument(Ljava/lang/Boolean;)V
.line 87
iget-object v0, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mBuffer:Ljava/nio/ByteBuffer;
invoke-virtual {v0, p1}, Ljava/nio/ByteBuffer;->get(I)B
move-result p1
:try_end_2e
.catchall {:try_start_1 .. :try_end_2e} :catchall_30
monitor-exit p0
return p1
:catchall_30
move-exception p1
monitor-exit p0
throw p1
.end method
.method public declared-synchronized read(I[BII)I
.registers 7
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x10,
0x10,
0x10,
0x10
}
names = {
"memoryOffset",
"byteArray",
"byteArrayOffset",
"count"
}
.end annotation
monitor-enter p0
.line 72
:try_start_1
invoke-static {p2}, Lcom/facebook/common/internal/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object;
.line 73
invoke-virtual {p0}, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->isClosed()Z
move-result v0
if-nez v0, :cond_c
const/4 v0, 0x1
goto :goto_d
:cond_c
const/4 v0, 0x0
:goto_d
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkState(Z)V
.line 74
iget v0, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mSize:I
invoke-static {p1, p4, v0}, Lcom/facebook/imagepipeline/memory/MemoryChunkUtil;->adjustByteCount(III)I
move-result p4
.line 75
array-length v0, p2
iget v1, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mSize:I
invoke-static {p1, v0, p3, p4, v1}, Lcom/facebook/imagepipeline/memory/MemoryChunkUtil;->checkBounds(IIIII)V
.line 77
iget-object v0, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mBuffer:Ljava/nio/ByteBuffer;
invoke-virtual {v0, p1}, Ljava/nio/ByteBuffer;->position(I)Ljava/nio/Buffer;
.line 78
iget-object p1, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mBuffer:Ljava/nio/ByteBuffer;
invoke-virtual {p1, p2, p3, p4}, Ljava/nio/ByteBuffer;->get([BII)Ljava/nio/ByteBuffer;
:try_end_26
.catchall {:try_start_1 .. :try_end_26} :catchall_28
.line 79
monitor-exit p0
return p4
:catchall_28
move-exception p1
monitor-exit p0
throw p1
.end method
.method public declared-synchronized write(I[BII)I
.registers 7
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x10,
0x10,
0x10,
0x10
}
names = {
"memoryOffset",
"byteArray",
"byteArrayOffset",
"count"
}
.end annotation
monitor-enter p0
.line 59
:try_start_1
invoke-static {p2}, Lcom/facebook/common/internal/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object;
.line 60
invoke-virtual {p0}, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->isClosed()Z
move-result v0
if-nez v0, :cond_c
const/4 v0, 0x1
goto :goto_d
:cond_c
const/4 v0, 0x0
:goto_d
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkState(Z)V
.line 61
iget v0, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mSize:I
invoke-static {p1, p4, v0}, Lcom/facebook/imagepipeline/memory/MemoryChunkUtil;->adjustByteCount(III)I
move-result p4
.line 62
array-length v0, p2
iget v1, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mSize:I
invoke-static {p1, v0, p3, p4, v1}, Lcom/facebook/imagepipeline/memory/MemoryChunkUtil;->checkBounds(IIIII)V
.line 64
iget-object v0, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mBuffer:Ljava/nio/ByteBuffer;
invoke-virtual {v0, p1}, Ljava/nio/ByteBuffer;->position(I)Ljava/nio/Buffer;
.line 65
iget-object p1, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mBuffer:Ljava/nio/ByteBuffer;
invoke-virtual {p1, p2, p3, p4}, Ljava/nio/ByteBuffer;->put([BII)Ljava/nio/ByteBuffer;
:try_end_26
.catchall {:try_start_1 .. :try_end_26} :catchall_28
.line 66
monitor-exit p0
return p4
:catchall_28
move-exception p1
monitor-exit p0
throw p1
.end method