Skip to content

Commit eb27ade

Browse files
authored
Merge pull request #127 from xpenatan/master
Release v1.0.2
2 parents 3ce4e2f + b5b0a7f commit eb27ade

File tree

24 files changed

+569
-351
lines changed

24 files changed

+569
-351
lines changed

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
[-SNAPSHOT]
22

3+
[1.0.2]
4+
- Small file storage improvement
5+
- Use file type for checking if asset is loaded
6+
- Improve arraybuffer performance
7+
- Improve texture opengl method
8+
- Fix sync loading (FreeType)
9+
310
[1.0.1]
411
- Fix an issue when creating database and trying to load assets.
512
- Quick fix to filter out assets.txt file and to delete it before adding new files

backends/backend-teavm/emu/com/badlogic/gdx/assets/AssetLoadingTaskEmu.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,17 @@ public Void call() throws Exception {
8080
public boolean update() {
8181
// GTW: check if we have a file that was not preloaded and is not done loading yet
8282
AssetLoader.AssetLoad assetLoader = AssetLoader.getInstance();
83-
84-
String path = resolve(loader, assetDesc).path();
85-
86-
if(!assetLoader.isAssetLoaded(Files.FileType.Internal, path)) {
83+
FileHandle fileHandle = resolve(loader, assetDesc);
84+
String path = fileHandle.path();
85+
Files.FileType type = fileHandle.type();
86+
if(!assetLoader.isAssetLoaded(type, path)) {
8787
if(!assetLoader.isAssetInQueue(path)) {
8888
count++;
8989
if(count == 2) {
9090
cancel = true;
9191
}
9292
else {
93-
assetLoader.loadAsset(true, path, AssetType.Binary, Files.FileType.Internal, null);
93+
assetLoader.loadAsset(true, path, AssetType.Binary, type, null);
9494
}
9595
}
9696
}

backends/backend-teavm/emu/com/badlogic/gdx/utils/GdxRuntimeExceptionEmu.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

backends/backend-teavm/emu/org/teavm/classlib/java/nio/ByteBufferImplEmu.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.teavm.classlib.java.nio;
22

3+
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.ArrayBufferViewWrapper;
34
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Int8ArrayWrapper;
45
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.TypedArrays;
56
import com.github.xpenatan.gdx.backends.teavm.gen.Emulate;
@@ -8,19 +9,37 @@
89
@Emulate(valueStr = "java.nio.ByteBufferImpl", updateCode = true)
910
public abstract class ByteBufferImplEmu extends TByteBufferImpl implements HasArrayBufferView {
1011

11-
public ByteBufferImplEmu(int capacity, boolean direct) {
12-
super(capacity, direct);
13-
}
12+
@Emulate
13+
Int8ArrayWrapper backupArray;
14+
@Emulate
15+
int positionCache;
16+
@Emulate
17+
int remainingCache;
1418

1519
public ByteBufferImplEmu(int start, int capacity, byte[] array, int position, int limit, boolean direct, boolean readOnly) {
1620
super(start, capacity, array, position, limit, direct, readOnly);
1721
}
1822

1923
@Override
2024
@Emulate
21-
public Int8ArrayWrapper getTypedArray() {
25+
public ArrayBufferViewWrapper getArrayBufferView() {
26+
Int8ArrayWrapper int8Array = (Int8ArrayWrapper)getOriginalArrayBufferView();
27+
int position1 = position();
28+
int remaining1 = remaining();
29+
if(backupArray == null || positionCache != position1 || remaining1 != remainingCache) {
30+
positionCache = position1;
31+
remainingCache = remaining1;
32+
backupArray = int8Array.subarray(position1, remaining1);
33+
}
34+
return backupArray;
35+
}
36+
37+
@Override
38+
@Emulate
39+
public ArrayBufferViewWrapper getOriginalArrayBufferView() {
2240
Object array = array();
23-
return TypedArrays.getArrayBufferView((JSObject)array);
41+
Int8ArrayWrapper int8Array = TypedArrays.getArrayBufferView((JSObject)array);
42+
return int8Array;
2443
}
2544

2645
@Override
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.teavm.classlib.java.nio;
2+
3+
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.ArrayBufferViewWrapper;
4+
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Float32ArrayWrapper;
5+
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.TypedArrays;
6+
import com.github.xpenatan.gdx.backends.teavm.gen.Emulate;
7+
8+
@Emulate(valueStr = "java.nio.TFloatBufferOverArray", updateCode = true)
9+
public abstract class FloatBufferOverArrayEmu extends TFloatBufferOverArray implements HasArrayBufferView {
10+
11+
@Emulate
12+
Float32ArrayWrapper backupArray;
13+
@Emulate
14+
int positionCache;
15+
@Emulate
16+
int remainingCache;
17+
18+
public FloatBufferOverArrayEmu(int start, int capacity, float[] array, int position, int limit, boolean readOnly) {
19+
super(start, capacity, array, position, limit, readOnly);
20+
}
21+
22+
@Override
23+
@Emulate
24+
public ArrayBufferViewWrapper getArrayBufferView() {
25+
Float32ArrayWrapper originalBuffer = (Float32ArrayWrapper)getOriginalArrayBufferView();
26+
int position1 = position();
27+
int remaining1 = remaining();
28+
if(backupArray == null || positionCache != position1 || remaining1 != remainingCache) {
29+
positionCache = position1;
30+
remainingCache = remaining1;
31+
backupArray = originalBuffer.subarray(position1, remaining1);
32+
}
33+
return backupArray;
34+
}
35+
36+
@Override
37+
@Emulate
38+
public ArrayBufferViewWrapper getOriginalArrayBufferView() {
39+
return TypedArrays.getTypedArray(array);
40+
}
41+
42+
@Override
43+
@Emulate
44+
public int getElementSize() {
45+
return 4;
46+
}
47+
}

backends/backend-teavm/emu/org/teavm/classlib/java/nio/FloatBufferOverByteBufferEmu.java

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,51 @@
11
package org.teavm.classlib.java.nio;
22

33
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.ArrayBufferViewWrapper;
4+
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Float32ArrayWrapper;
45
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Int8ArrayWrapper;
6+
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.TypedArrays;
57
import com.github.xpenatan.gdx.backends.teavm.gen.Emulate;
68

79
@Emulate(valueStr = "java.nio.FloatBufferOverByteBuffer", updateCode = true)
810
public abstract class FloatBufferOverByteBufferEmu extends TFloatBufferOverByteBuffer implements HasArrayBufferView {
911

12+
@Emulate
13+
Float32ArrayWrapper backupArray;
14+
@Emulate
15+
Float32ArrayWrapper floatArray;
16+
@Emulate
17+
int positionCache;
18+
@Emulate
19+
int remainingCache;
20+
1021
public FloatBufferOverByteBufferEmu(int start, int capacity, TByteBufferImpl byteBuffer, int position, int limit, boolean readOnly) {
1122
super(start, capacity, byteBuffer, position, limit, readOnly);
1223
}
1324

1425
@Override
1526
@Emulate
16-
public Int8ArrayWrapper getTypedArray() {
27+
public ArrayBufferViewWrapper getArrayBufferView() {
28+
// Int8Array
29+
Int8ArrayWrapper int8Array = (Int8ArrayWrapper)getOriginalArrayBufferView();
30+
if(floatArray == null) {
31+
floatArray = TypedArrays.createFloat32Array(int8Array.getBuffer());
32+
}
33+
34+
int position1 = position();
35+
int remaining1 = remaining();
36+
if(backupArray == null || positionCache != position1 || remaining1 != remainingCache) {
37+
positionCache = position1;
38+
remainingCache = remaining1;
39+
backupArray = floatArray.subarray(position1, remaining1);
40+
}
41+
return backupArray;
42+
}
43+
44+
@Override
45+
@Emulate
46+
public ArrayBufferViewWrapper getOriginalArrayBufferView() {
1747
HasArrayBufferView buff = (HasArrayBufferView)byteByffer;
18-
return buff.getTypedArray();
48+
return buff.getOriginalArrayBufferView();
1949
}
2050

2151
@Override
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package org.teavm.classlib.java.nio;
22

3-
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Int8ArrayWrapper;
3+
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.ArrayBufferViewWrapper;
44

55
public interface HasArrayBufferView {
6-
Int8ArrayWrapper getTypedArray();
6+
ArrayBufferViewWrapper getArrayBufferView();
7+
ArrayBufferViewWrapper getOriginalArrayBufferView();
78
int getElementSize();
89
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.teavm.classlib.java.nio;
2+
3+
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.ArrayBufferViewWrapper;
4+
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Int32ArrayWrapper;
5+
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.TypedArrays;
6+
import com.github.xpenatan.gdx.backends.teavm.gen.Emulate;
7+
8+
@Emulate(valueStr = "java.nio.TIntBufferOverArray", updateCode = true)
9+
public abstract class IntBufferOverArrayEmu extends TIntBufferOverArray implements HasArrayBufferView {
10+
11+
@Emulate
12+
Int32ArrayWrapper backupArray;
13+
@Emulate
14+
int positionCache;
15+
@Emulate
16+
int remainingCache;
17+
18+
public IntBufferOverArrayEmu(int start, int capacity, int[] array, int position, int limit, boolean readOnly) {
19+
super(start, capacity, array, position, limit, readOnly);
20+
}
21+
22+
@Override
23+
@Emulate
24+
public ArrayBufferViewWrapper getArrayBufferView() {
25+
Int32ArrayWrapper originalBuffer = (Int32ArrayWrapper)getOriginalArrayBufferView();
26+
int position1 = position();
27+
int remaining1 = remaining();
28+
if(backupArray == null || positionCache != position1 || remaining1 != remainingCache) {
29+
positionCache = position1;
30+
remainingCache = remaining1;
31+
backupArray = originalBuffer.subarray(position1, remaining1);
32+
}
33+
return backupArray;
34+
}
35+
36+
@Override
37+
@Emulate
38+
public ArrayBufferViewWrapper getOriginalArrayBufferView() {
39+
return TypedArrays.getTypedArray(array);
40+
}
41+
42+
@Override
43+
@Emulate
44+
public int getElementSize() {
45+
return 4;
46+
}
47+
}

backends/backend-teavm/emu/org/teavm/classlib/java/nio/IntBufferOverByteBufferEmu.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,51 @@
11
package org.teavm.classlib.java.nio;
22

3+
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.ArrayBufferViewWrapper;
4+
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Int32ArrayWrapper;
35
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Int8ArrayWrapper;
6+
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.TypedArrays;
47
import com.github.xpenatan.gdx.backends.teavm.gen.Emulate;
58

69
@Emulate(valueStr = "java.nio.IntBufferOverByteBuffer", updateCode = true)
710
public abstract class IntBufferOverByteBufferEmu extends TIntBufferOverByteBuffer implements HasArrayBufferView {
811

12+
@Emulate
13+
Int32ArrayWrapper backupArray;
14+
@Emulate
15+
Int32ArrayWrapper intArray;
16+
@Emulate
17+
int positionCache;
18+
@Emulate
19+
int remainingCache;
20+
21+
922
public IntBufferOverByteBufferEmu(int start, int capacity, TByteBufferImpl byteBuffer, int position, int limit, boolean readOnly) {
1023
super(start, capacity, byteBuffer, position, limit, readOnly);
1124
}
1225

1326
@Override
1427
@Emulate
15-
public Int8ArrayWrapper getTypedArray() {
28+
public ArrayBufferViewWrapper getArrayBufferView() {
29+
// Int8Array
30+
Int8ArrayWrapper int8Array = (Int8ArrayWrapper)getOriginalArrayBufferView();
31+
if(intArray == null) {
32+
intArray = TypedArrays.createInt32Array(int8Array.getBuffer());
33+
}
34+
int position1 = position();
35+
int remaining1 = remaining();
36+
if(backupArray == null || positionCache != position1 || remaining1 != remainingCache) {
37+
positionCache = position1;
38+
remainingCache = remaining1;
39+
backupArray = intArray.subarray(position1, remaining1);
40+
}
41+
return backupArray;
42+
}
43+
44+
@Override
45+
@Emulate
46+
public ArrayBufferViewWrapper getOriginalArrayBufferView() {
1647
HasArrayBufferView buff = (HasArrayBufferView)byteByffer;
17-
return buff.getTypedArray();
48+
return buff.getOriginalArrayBufferView();
1849
}
1950

2051
@Override
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.teavm.classlib.java.nio;
2+
3+
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.ArrayBufferViewWrapper;
4+
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Int16ArrayWrapper;
5+
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.TypedArrays;
6+
import com.github.xpenatan.gdx.backends.teavm.gen.Emulate;
7+
8+
@Emulate(valueStr = "java.nio.TShortBufferOverArray", updateCode = true)
9+
public abstract class ShortBufferOverArrayEmu extends TShortBufferOverArray implements HasArrayBufferView {
10+
11+
@Emulate
12+
Int16ArrayWrapper backupArray;
13+
@Emulate
14+
int positionCache;
15+
@Emulate
16+
int remainingCache;
17+
18+
public ShortBufferOverArrayEmu(int start, int capacity, short[] array, int position, int limit, boolean readOnly) {
19+
super(start, capacity, array, position, limit, readOnly);
20+
}
21+
22+
@Override
23+
@Emulate
24+
public ArrayBufferViewWrapper getArrayBufferView() {
25+
Int16ArrayWrapper originalBuffer = (Int16ArrayWrapper)getOriginalArrayBufferView();
26+
int position1 = position();
27+
int remaining1 = remaining();
28+
if(backupArray == null || positionCache != position1 || remaining1 != remainingCache) {
29+
positionCache = position1;
30+
remainingCache = remaining1;
31+
backupArray = originalBuffer.subarray(position1, remaining1);
32+
}
33+
return backupArray;
34+
}
35+
36+
@Override
37+
@Emulate
38+
public ArrayBufferViewWrapper getOriginalArrayBufferView() {
39+
return TypedArrays.getTypedArray(array);
40+
}
41+
42+
@Override
43+
@Emulate
44+
public int getElementSize() {
45+
return 2;
46+
}
47+
}

0 commit comments

Comments
 (0)