BufferMemoryChunk.smali
.class public Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;
.super Ljava/lang/Object;
.source "SourceFile"
# 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
.line 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 2
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 3
iput p1, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mSize:I
.line 4
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
.line 1
instance-of v0, p2, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;
if-eqz v0, :cond_3b
.line 2
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 3
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 4
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 5
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 6
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 7
new-array p1, p4, [B
.line 8
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 9
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 10
: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 1
: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 2
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 10
.line 1
invoke-static {p2}, Lcom/facebook/common/internal/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object;
.line 2
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 v4, v0, v2
if-nez v4, :cond_21
.line 3
invoke-virtual {p0}, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->getUniqueId()J
move-result-wide v0
invoke-static {v0, v1}, Ljava/lang/Long;->toHexString(J)Ljava/lang/String;
.line 4
invoke-interface {p2}, Lcom/facebook/imagepipeline/memory/MemoryChunk;->getUniqueId()J
move-result-wide v0
invoke-static {v0, v1}, Ljava/lang/Long;->toHexString(J)Ljava/lang/String;
const/4 v0, 0x0
.line 5
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkArgument(Z)V
.line 6
:cond_21
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 v4, v0, v2
if-gez v4, :cond_3b
.line 7
monitor-enter p2
.line 8
:try_start_2e
monitor-enter p0
:try_end_2f
.catchall {:try_start_2e .. :try_end_2f} :catchall_38
.line 9
:try_start_2f
invoke-direct {p0, p1, p2, p3, p4}, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->doCopy(ILcom/facebook/imagepipeline/memory/MemoryChunk;II)V
.line 10
monitor-exit p0
:try_end_33
.catchall {:try_start_2f .. :try_end_33} :catchall_35
.line 11
:try_start_33
monitor-exit p2
:try_end_34
.catchall {:try_start_33 .. :try_end_34} :catchall_38
return-void
:catchall_35
move-exception p1
.line 12
:try_start_36
monitor-exit p0
:try_end_37
.catchall {:try_start_36 .. :try_end_37} :catchall_35
:try_start_37
throw p1
:catchall_38
move-exception p1
.line 13
monitor-exit p2
:try_end_3a
.catchall {:try_start_37 .. :try_end_3a} :catchall_38
throw p1
.line 14
:cond_3b
monitor-enter p0
.line 15
:try_start_3c
monitor-enter p2
:try_end_3d
.catchall {:try_start_3c .. :try_end_3d} :catchall_46
.line 16
:try_start_3d
invoke-direct {p0, p1, p2, p3, p4}, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->doCopy(ILcom/facebook/imagepipeline/memory/MemoryChunk;II)V
.line 17
monitor-exit p2
:try_end_41
.catchall {:try_start_3d .. :try_end_41} :catchall_43
.line 18
:try_start_41
monitor-exit p0
:try_end_42
.catchall {:try_start_41 .. :try_end_42} :catchall_46
return-void
:catchall_43
move-exception p1
.line 19
:try_start_44
monitor-exit p2
:try_end_45
.catchall {:try_start_44 .. :try_end_45} :catchall_43
:try_start_45
throw p1
:catchall_46
move-exception p1
.line 20
monitor-exit p0
:try_end_48
.catchall {:try_start_45 .. :try_end_48} :catchall_46
throw p1
.end method
.method public declared-synchronized getByteBuffer()Ljava/nio/ByteBuffer;
.registers 2
monitor-enter p0
: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
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
iget v0, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mSize:I
return v0
.end method
.method public getUniqueId()J
.registers 3
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
: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
monitor-enter p0
.line 8
: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
const/4 v0, 0x1
goto :goto_c
:cond_b
const/4 v0, 0x0
:goto_c
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkState(Z)V
if-ltz p1, :cond_13
const/4 v0, 0x1
goto :goto_14
:cond_13
const/4 v0, 0x0
.line 9
:goto_14
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkArgument(Z)V
.line 10
iget v0, p0, Lcom/facebook/imagepipeline/memory/BufferMemoryChunk;->mSize:I
if-ge p1, v0, :cond_1c
goto :goto_1d
:cond_1c
const/4 v1, 0x0
:goto_1d
invoke-static {v1}, Lcom/facebook/common/internal/Preconditions;->checkArgument(Z)V
.line 11
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_26
.catchall {:try_start_1 .. :try_end_26} :catchall_28
monitor-exit p0
return p1
:catchall_28
move-exception p1
monitor-exit p0
throw p1
.end method
.method public declared-synchronized read(I[BII)I
.registers 7
monitor-enter p0
.line 1
:try_start_1
invoke-static {p2}, Lcom/facebook/common/internal/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object;
.line 2
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 3
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 4
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 5
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 6
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 7
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
monitor-enter p0
.line 1
:try_start_1
invoke-static {p2}, Lcom/facebook/common/internal/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object;
.line 2
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 3
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 4
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 5
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 6
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 7
monitor-exit p0
return p4
:catchall_28
move-exception p1
monitor-exit p0
throw p1
.end method