546 lines
11 KiB
Smali
546 lines
11 KiB
Smali
.class public final Lcom/badlogic/gdx/utils/BufferUtils;
|
|
.super Ljava/lang/Object;
|
|
.source "BufferUtils.java"
|
|
|
|
|
|
# static fields
|
|
.field static a:Lcom/badlogic/gdx/utils/Array;
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"Lcom/badlogic/gdx/utils/Array<",
|
|
"Ljava/nio/ByteBuffer;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
.end field
|
|
|
|
.field static b:I
|
|
|
|
|
|
# direct methods
|
|
.method static constructor <clinit>()V
|
|
.locals 1
|
|
|
|
.line 36
|
|
new-instance v0, Lcom/badlogic/gdx/utils/Array;
|
|
|
|
invoke-direct {v0}, Lcom/badlogic/gdx/utils/Array;-><init>()V
|
|
|
|
sput-object v0, Lcom/badlogic/gdx/utils/BufferUtils;->a:Lcom/badlogic/gdx/utils/Array;
|
|
|
|
const/4 v0, 0x0
|
|
|
|
.line 37
|
|
sput v0, Lcom/badlogic/gdx/utils/BufferUtils;->b:I
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public constructor <init>()V
|
|
.locals 0
|
|
|
|
.line 35
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method private static a(Ljava/nio/Buffer;)I
|
|
.locals 3
|
|
|
|
.line 398
|
|
instance-of v0, p0, Ljava/nio/ByteBuffer;
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
.line 399
|
|
invoke-virtual {p0}, Ljava/nio/Buffer;->position()I
|
|
|
|
move-result p0
|
|
|
|
return p0
|
|
|
|
.line 400
|
|
:cond_0
|
|
instance-of v0, p0, Ljava/nio/ShortBuffer;
|
|
|
|
if-eqz v0, :cond_1
|
|
|
|
.line 401
|
|
invoke-virtual {p0}, Ljava/nio/Buffer;->position()I
|
|
|
|
move-result p0
|
|
|
|
shl-int/lit8 p0, p0, 0x1
|
|
|
|
return p0
|
|
|
|
.line 402
|
|
:cond_1
|
|
instance-of v0, p0, Ljava/nio/CharBuffer;
|
|
|
|
if-eqz v0, :cond_2
|
|
|
|
.line 403
|
|
invoke-virtual {p0}, Ljava/nio/Buffer;->position()I
|
|
|
|
move-result p0
|
|
|
|
shl-int/lit8 p0, p0, 0x1
|
|
|
|
return p0
|
|
|
|
.line 404
|
|
:cond_2
|
|
instance-of v0, p0, Ljava/nio/IntBuffer;
|
|
|
|
if-eqz v0, :cond_3
|
|
|
|
.line 405
|
|
invoke-virtual {p0}, Ljava/nio/Buffer;->position()I
|
|
|
|
move-result p0
|
|
|
|
shl-int/lit8 p0, p0, 0x2
|
|
|
|
return p0
|
|
|
|
.line 406
|
|
:cond_3
|
|
instance-of v0, p0, Ljava/nio/LongBuffer;
|
|
|
|
if-eqz v0, :cond_4
|
|
|
|
.line 407
|
|
invoke-virtual {p0}, Ljava/nio/Buffer;->position()I
|
|
|
|
move-result p0
|
|
|
|
shl-int/lit8 p0, p0, 0x3
|
|
|
|
return p0
|
|
|
|
.line 408
|
|
:cond_4
|
|
instance-of v0, p0, Ljava/nio/FloatBuffer;
|
|
|
|
if-eqz v0, :cond_5
|
|
|
|
.line 409
|
|
invoke-virtual {p0}, Ljava/nio/Buffer;->position()I
|
|
|
|
move-result p0
|
|
|
|
shl-int/lit8 p0, p0, 0x2
|
|
|
|
return p0
|
|
|
|
.line 410
|
|
:cond_5
|
|
instance-of v0, p0, Ljava/nio/DoubleBuffer;
|
|
|
|
if-eqz v0, :cond_6
|
|
|
|
.line 411
|
|
invoke-virtual {p0}, Ljava/nio/Buffer;->position()I
|
|
|
|
move-result p0
|
|
|
|
shl-int/lit8 p0, p0, 0x3
|
|
|
|
return p0
|
|
|
|
.line 413
|
|
:cond_6
|
|
new-instance v0, Lcom/badlogic/gdx/utils/GdxRuntimeException;
|
|
|
|
new-instance v1, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
const-string v2, "Can\'t copy to a "
|
|
|
|
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-virtual {p0}, Ljava/lang/Class;->getName()Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
const-string p0, " instance"
|
|
|
|
invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-direct {v0, p0}, Lcom/badlogic/gdx/utils/GdxRuntimeException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
.end method
|
|
|
|
.method private static a(Ljava/nio/Buffer;I)I
|
|
.locals 2
|
|
|
|
.line 417
|
|
instance-of v0, p0, Ljava/nio/ByteBuffer;
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
return p1
|
|
|
|
.line 419
|
|
:cond_0
|
|
instance-of v0, p0, Ljava/nio/ShortBuffer;
|
|
|
|
if-eqz v0, :cond_1
|
|
|
|
ushr-int/lit8 p0, p1, 0x1
|
|
|
|
return p0
|
|
|
|
.line 421
|
|
:cond_1
|
|
instance-of v0, p0, Ljava/nio/CharBuffer;
|
|
|
|
if-eqz v0, :cond_2
|
|
|
|
ushr-int/lit8 p0, p1, 0x1
|
|
|
|
return p0
|
|
|
|
.line 423
|
|
:cond_2
|
|
instance-of v0, p0, Ljava/nio/IntBuffer;
|
|
|
|
if-eqz v0, :cond_3
|
|
|
|
ushr-int/lit8 p0, p1, 0x2
|
|
|
|
return p0
|
|
|
|
.line 425
|
|
:cond_3
|
|
instance-of v0, p0, Ljava/nio/LongBuffer;
|
|
|
|
if-eqz v0, :cond_4
|
|
|
|
ushr-int/lit8 p0, p1, 0x3
|
|
|
|
return p0
|
|
|
|
.line 427
|
|
:cond_4
|
|
instance-of v0, p0, Ljava/nio/FloatBuffer;
|
|
|
|
if-eqz v0, :cond_5
|
|
|
|
ushr-int/lit8 p0, p1, 0x2
|
|
|
|
return p0
|
|
|
|
.line 429
|
|
:cond_5
|
|
instance-of v0, p0, Ljava/nio/DoubleBuffer;
|
|
|
|
if-eqz v0, :cond_6
|
|
|
|
ushr-int/lit8 p0, p1, 0x3
|
|
|
|
return p0
|
|
|
|
.line 432
|
|
:cond_6
|
|
new-instance p1, Lcom/badlogic/gdx/utils/GdxRuntimeException;
|
|
|
|
new-instance v0, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
const-string v1, "Can\'t copy to a "
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-virtual {p0}, Ljava/lang/Class;->getName()Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
const-string p0, " instance"
|
|
|
|
invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-direct {p1, p0}, Lcom/badlogic/gdx/utils/GdxRuntimeException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p1
|
|
.end method
|
|
|
|
.method public static a(I)Ljava/nio/FloatBuffer;
|
|
.locals 1
|
|
|
|
mul-int/lit8 p0, p0, 0x4
|
|
|
|
.line 455
|
|
invoke-static {p0}, Ljava/nio/ByteBuffer;->allocateDirect(I)Ljava/nio/ByteBuffer;
|
|
|
|
move-result-object p0
|
|
|
|
.line 456
|
|
invoke-static {}, Ljava/nio/ByteOrder;->nativeOrder()Ljava/nio/ByteOrder;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {p0, v0}, Ljava/nio/ByteBuffer;->order(Ljava/nio/ByteOrder;)Ljava/nio/ByteBuffer;
|
|
|
|
.line 457
|
|
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->asFloatBuffer()Ljava/nio/FloatBuffer;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static a(Ljava/nio/ByteBuffer;)V
|
|
.locals 4
|
|
|
|
.line 504
|
|
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->capacity()I
|
|
|
|
move-result v0
|
|
|
|
.line 505
|
|
sget-object v1, Lcom/badlogic/gdx/utils/BufferUtils;->a:Lcom/badlogic/gdx/utils/Array;
|
|
|
|
monitor-enter v1
|
|
|
|
.line 506
|
|
:try_start_0
|
|
sget-object v2, Lcom/badlogic/gdx/utils/BufferUtils;->a:Lcom/badlogic/gdx/utils/Array;
|
|
|
|
const/4 v3, 0x1
|
|
|
|
invoke-virtual {v2, p0, v3}, Lcom/badlogic/gdx/utils/Array;->c(Ljava/lang/Object;Z)Z
|
|
|
|
move-result v2
|
|
|
|
if-eqz v2, :cond_0
|
|
|
|
.line 508
|
|
monitor-exit v1
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
.line 509
|
|
sget v1, Lcom/badlogic/gdx/utils/BufferUtils;->b:I
|
|
|
|
sub-int/2addr v1, v0
|
|
|
|
sput v1, Lcom/badlogic/gdx/utils/BufferUtils;->b:I
|
|
|
|
.line 510
|
|
invoke-static {p0}, Lcom/badlogic/gdx/utils/BufferUtils;->freeMemory(Ljava/nio/ByteBuffer;)V
|
|
|
|
return-void
|
|
|
|
.line 507
|
|
:cond_0
|
|
:try_start_1
|
|
new-instance p0, Ljava/lang/IllegalArgumentException;
|
|
|
|
const-string v0, "buffer not allocated with newUnsafeByteBuffer or already disposed"
|
|
|
|
invoke-direct {p0, v0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p0
|
|
|
|
:catchall_0
|
|
move-exception p0
|
|
|
|
.line 508
|
|
monitor-exit v1
|
|
:try_end_1
|
|
.catchall {:try_start_1 .. :try_end_1} :catchall_0
|
|
|
|
throw p0
|
|
.end method
|
|
|
|
.method public static a([BILjava/nio/Buffer;I)V
|
|
.locals 2
|
|
|
|
.line 68
|
|
invoke-virtual {p2}, Ljava/nio/Buffer;->position()I
|
|
|
|
move-result v0
|
|
|
|
invoke-static {p2, p3}, Lcom/badlogic/gdx/utils/BufferUtils;->a(Ljava/nio/Buffer;I)I
|
|
|
|
move-result v1
|
|
|
|
add-int/2addr v0, v1
|
|
|
|
invoke-virtual {p2, v0}, Ljava/nio/Buffer;->limit(I)Ljava/nio/Buffer;
|
|
|
|
.line 69
|
|
invoke-static {p2}, Lcom/badlogic/gdx/utils/BufferUtils;->a(Ljava/nio/Buffer;)I
|
|
|
|
move-result v0
|
|
|
|
invoke-static {p0, p1, p2, v0, p3}, Lcom/badlogic/gdx/utils/BufferUtils;->copyJni([BILjava/nio/Buffer;II)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static a([FLjava/nio/Buffer;II)V
|
|
.locals 1
|
|
|
|
.line 50
|
|
instance-of v0, p1, Ljava/nio/ByteBuffer;
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
shl-int/lit8 v0, p2, 0x2
|
|
|
|
.line 51
|
|
invoke-virtual {p1, v0}, Ljava/nio/Buffer;->limit(I)Ljava/nio/Buffer;
|
|
|
|
goto :goto_0
|
|
|
|
.line 52
|
|
:cond_0
|
|
instance-of v0, p1, Ljava/nio/FloatBuffer;
|
|
|
|
if-eqz v0, :cond_1
|
|
|
|
invoke-virtual {p1, p2}, Ljava/nio/Buffer;->limit(I)Ljava/nio/Buffer;
|
|
|
|
.line 54
|
|
:cond_1
|
|
:goto_0
|
|
invoke-static {p0, p1, p2, p3}, Lcom/badlogic/gdx/utils/BufferUtils;->copyJni([FLjava/nio/Buffer;II)V
|
|
|
|
const/4 p0, 0x0
|
|
|
|
.line 55
|
|
invoke-virtual {p1, p0}, Ljava/nio/Buffer;->position(I)Ljava/nio/Buffer;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static b(I)Ljava/nio/ByteBuffer;
|
|
.locals 1
|
|
|
|
.line 467
|
|
invoke-static {p0}, Ljava/nio/ByteBuffer;->allocateDirect(I)Ljava/nio/ByteBuffer;
|
|
|
|
move-result-object p0
|
|
|
|
.line 468
|
|
invoke-static {}, Ljava/nio/ByteOrder;->nativeOrder()Ljava/nio/ByteOrder;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {p0, v0}, Ljava/nio/ByteBuffer;->order(Ljava/nio/ByteOrder;)Ljava/nio/ByteBuffer;
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static c(I)Ljava/nio/IntBuffer;
|
|
.locals 1
|
|
|
|
mul-int/lit8 p0, p0, 0x4
|
|
|
|
.line 485
|
|
invoke-static {p0}, Ljava/nio/ByteBuffer;->allocateDirect(I)Ljava/nio/ByteBuffer;
|
|
|
|
move-result-object p0
|
|
|
|
.line 486
|
|
invoke-static {}, Ljava/nio/ByteOrder;->nativeOrder()Ljava/nio/ByteOrder;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {p0, v0}, Ljava/nio/ByteBuffer;->order(Ljava/nio/ByteOrder;)Ljava/nio/ByteBuffer;
|
|
|
|
.line 487
|
|
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->asIntBuffer()Ljava/nio/IntBuffer;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method private static native copyJni([BILjava/nio/Buffer;II)V
|
|
.end method
|
|
|
|
.method private static native copyJni([FLjava/nio/Buffer;II)V
|
|
.end method
|
|
|
|
.method public static d(I)Ljava/nio/ByteBuffer;
|
|
.locals 2
|
|
|
|
.line 517
|
|
invoke-static {p0}, Lcom/badlogic/gdx/utils/BufferUtils;->newDisposableByteBuffer(I)Ljava/nio/ByteBuffer;
|
|
|
|
move-result-object v0
|
|
|
|
.line 518
|
|
invoke-static {}, Ljava/nio/ByteOrder;->nativeOrder()Ljava/nio/ByteOrder;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-virtual {v0, v1}, Ljava/nio/ByteBuffer;->order(Ljava/nio/ByteOrder;)Ljava/nio/ByteBuffer;
|
|
|
|
.line 519
|
|
sget v1, Lcom/badlogic/gdx/utils/BufferUtils;->b:I
|
|
|
|
add-int/2addr v1, p0
|
|
|
|
sput v1, Lcom/badlogic/gdx/utils/BufferUtils;->b:I
|
|
|
|
.line 520
|
|
sget-object p0, Lcom/badlogic/gdx/utils/BufferUtils;->a:Lcom/badlogic/gdx/utils/Array;
|
|
|
|
monitor-enter p0
|
|
|
|
.line 521
|
|
:try_start_0
|
|
sget-object v1, Lcom/badlogic/gdx/utils/BufferUtils;->a:Lcom/badlogic/gdx/utils/Array;
|
|
|
|
invoke-virtual {v1, v0}, Lcom/badlogic/gdx/utils/Array;->a(Ljava/lang/Object;)V
|
|
|
|
.line 522
|
|
monitor-exit p0
|
|
|
|
return-object v0
|
|
|
|
:catchall_0
|
|
move-exception v0
|
|
|
|
monitor-exit p0
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
throw v0
|
|
.end method
|
|
|
|
.method private static native freeMemory(Ljava/nio/ByteBuffer;)V
|
|
.end method
|
|
|
|
.method private static native newDisposableByteBuffer(I)Ljava/nio/ByteBuffer;
|
|
.end method
|