Skip to content

Commit

Permalink
Merge pull request #127 from xpenatan/master
Browse files Browse the repository at this point in the history
Release v1.0.2
  • Loading branch information
xpenatan authored Jul 14, 2024
2 parents 3ce4e2f + b5b0a7f commit eb27ade
Show file tree
Hide file tree
Showing 24 changed files with 569 additions and 351 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
[-SNAPSHOT]

[1.0.2]
- Small file storage improvement
- Use file type for checking if asset is loaded
- Improve arraybuffer performance
- Improve texture opengl method
- Fix sync loading (FreeType)

[1.0.1]
- Fix an issue when creating database and trying to load assets.
- Quick fix to filter out assets.txt file and to delete it before adding new files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ public Void call() throws Exception {
public boolean update() {
// GTW: check if we have a file that was not preloaded and is not done loading yet
AssetLoader.AssetLoad assetLoader = AssetLoader.getInstance();

String path = resolve(loader, assetDesc).path();

if(!assetLoader.isAssetLoaded(Files.FileType.Internal, path)) {
FileHandle fileHandle = resolve(loader, assetDesc);
String path = fileHandle.path();
Files.FileType type = fileHandle.type();
if(!assetLoader.isAssetLoaded(type, path)) {
if(!assetLoader.isAssetInQueue(path)) {
count++;
if(count == 2) {
cancel = true;
}
else {
assetLoader.loadAsset(true, path, AssetType.Binary, Files.FileType.Internal, null);
assetLoader.loadAsset(true, path, AssetType.Binary, type, null);
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.teavm.classlib.java.nio;

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

public ByteBufferImplEmu(int capacity, boolean direct) {
super(capacity, direct);
}
@Emulate
Int8ArrayWrapper backupArray;
@Emulate
int positionCache;
@Emulate
int remainingCache;

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

@Override
@Emulate
public Int8ArrayWrapper getTypedArray() {
public ArrayBufferViewWrapper getArrayBufferView() {
Int8ArrayWrapper int8Array = (Int8ArrayWrapper)getOriginalArrayBufferView();
int position1 = position();
int remaining1 = remaining();
if(backupArray == null || positionCache != position1 || remaining1 != remainingCache) {
positionCache = position1;
remainingCache = remaining1;
backupArray = int8Array.subarray(position1, remaining1);
}
return backupArray;
}

@Override
@Emulate
public ArrayBufferViewWrapper getOriginalArrayBufferView() {
Object array = array();
return TypedArrays.getArrayBufferView((JSObject)array);
Int8ArrayWrapper int8Array = TypedArrays.getArrayBufferView((JSObject)array);
return int8Array;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.teavm.classlib.java.nio;

import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.ArrayBufferViewWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Float32ArrayWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.TypedArrays;
import com.github.xpenatan.gdx.backends.teavm.gen.Emulate;

@Emulate(valueStr = "java.nio.TFloatBufferOverArray", updateCode = true)
public abstract class FloatBufferOverArrayEmu extends TFloatBufferOverArray implements HasArrayBufferView {

@Emulate
Float32ArrayWrapper backupArray;
@Emulate
int positionCache;
@Emulate
int remainingCache;

public FloatBufferOverArrayEmu(int start, int capacity, float[] array, int position, int limit, boolean readOnly) {
super(start, capacity, array, position, limit, readOnly);
}

@Override
@Emulate
public ArrayBufferViewWrapper getArrayBufferView() {
Float32ArrayWrapper originalBuffer = (Float32ArrayWrapper)getOriginalArrayBufferView();
int position1 = position();
int remaining1 = remaining();
if(backupArray == null || positionCache != position1 || remaining1 != remainingCache) {
positionCache = position1;
remainingCache = remaining1;
backupArray = originalBuffer.subarray(position1, remaining1);
}
return backupArray;
}

@Override
@Emulate
public ArrayBufferViewWrapper getOriginalArrayBufferView() {
return TypedArrays.getTypedArray(array);
}

@Override
@Emulate
public int getElementSize() {
return 4;
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,51 @@
package org.teavm.classlib.java.nio;

import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.ArrayBufferViewWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Float32ArrayWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Int8ArrayWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.TypedArrays;
import com.github.xpenatan.gdx.backends.teavm.gen.Emulate;

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

@Emulate
Float32ArrayWrapper backupArray;
@Emulate
Float32ArrayWrapper floatArray;
@Emulate
int positionCache;
@Emulate
int remainingCache;

public FloatBufferOverByteBufferEmu(int start, int capacity, TByteBufferImpl byteBuffer, int position, int limit, boolean readOnly) {
super(start, capacity, byteBuffer, position, limit, readOnly);
}

@Override
@Emulate
public Int8ArrayWrapper getTypedArray() {
public ArrayBufferViewWrapper getArrayBufferView() {
// Int8Array
Int8ArrayWrapper int8Array = (Int8ArrayWrapper)getOriginalArrayBufferView();
if(floatArray == null) {
floatArray = TypedArrays.createFloat32Array(int8Array.getBuffer());
}

int position1 = position();
int remaining1 = remaining();
if(backupArray == null || positionCache != position1 || remaining1 != remainingCache) {
positionCache = position1;
remainingCache = remaining1;
backupArray = floatArray.subarray(position1, remaining1);
}
return backupArray;
}

@Override
@Emulate
public ArrayBufferViewWrapper getOriginalArrayBufferView() {
HasArrayBufferView buff = (HasArrayBufferView)byteByffer;
return buff.getTypedArray();
return buff.getOriginalArrayBufferView();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.teavm.classlib.java.nio;

import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Int8ArrayWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.ArrayBufferViewWrapper;

public interface HasArrayBufferView {
Int8ArrayWrapper getTypedArray();
ArrayBufferViewWrapper getArrayBufferView();
ArrayBufferViewWrapper getOriginalArrayBufferView();
int getElementSize();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.teavm.classlib.java.nio;

import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.ArrayBufferViewWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Int32ArrayWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.TypedArrays;
import com.github.xpenatan.gdx.backends.teavm.gen.Emulate;

@Emulate(valueStr = "java.nio.TIntBufferOverArray", updateCode = true)
public abstract class IntBufferOverArrayEmu extends TIntBufferOverArray implements HasArrayBufferView {

@Emulate
Int32ArrayWrapper backupArray;
@Emulate
int positionCache;
@Emulate
int remainingCache;

public IntBufferOverArrayEmu(int start, int capacity, int[] array, int position, int limit, boolean readOnly) {
super(start, capacity, array, position, limit, readOnly);
}

@Override
@Emulate
public ArrayBufferViewWrapper getArrayBufferView() {
Int32ArrayWrapper originalBuffer = (Int32ArrayWrapper)getOriginalArrayBufferView();
int position1 = position();
int remaining1 = remaining();
if(backupArray == null || positionCache != position1 || remaining1 != remainingCache) {
positionCache = position1;
remainingCache = remaining1;
backupArray = originalBuffer.subarray(position1, remaining1);
}
return backupArray;
}

@Override
@Emulate
public ArrayBufferViewWrapper getOriginalArrayBufferView() {
return TypedArrays.getTypedArray(array);
}

@Override
@Emulate
public int getElementSize() {
return 4;
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,51 @@
package org.teavm.classlib.java.nio;

import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.ArrayBufferViewWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Int32ArrayWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Int8ArrayWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.TypedArrays;
import com.github.xpenatan.gdx.backends.teavm.gen.Emulate;

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

@Emulate
Int32ArrayWrapper backupArray;
@Emulate
Int32ArrayWrapper intArray;
@Emulate
int positionCache;
@Emulate
int remainingCache;


public IntBufferOverByteBufferEmu(int start, int capacity, TByteBufferImpl byteBuffer, int position, int limit, boolean readOnly) {
super(start, capacity, byteBuffer, position, limit, readOnly);
}

@Override
@Emulate
public Int8ArrayWrapper getTypedArray() {
public ArrayBufferViewWrapper getArrayBufferView() {
// Int8Array
Int8ArrayWrapper int8Array = (Int8ArrayWrapper)getOriginalArrayBufferView();
if(intArray == null) {
intArray = TypedArrays.createInt32Array(int8Array.getBuffer());
}
int position1 = position();
int remaining1 = remaining();
if(backupArray == null || positionCache != position1 || remaining1 != remainingCache) {
positionCache = position1;
remainingCache = remaining1;
backupArray = intArray.subarray(position1, remaining1);
}
return backupArray;
}

@Override
@Emulate
public ArrayBufferViewWrapper getOriginalArrayBufferView() {
HasArrayBufferView buff = (HasArrayBufferView)byteByffer;
return buff.getTypedArray();
return buff.getOriginalArrayBufferView();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.teavm.classlib.java.nio;

import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.ArrayBufferViewWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Int16ArrayWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.TypedArrays;
import com.github.xpenatan.gdx.backends.teavm.gen.Emulate;

@Emulate(valueStr = "java.nio.TShortBufferOverArray", updateCode = true)
public abstract class ShortBufferOverArrayEmu extends TShortBufferOverArray implements HasArrayBufferView {

@Emulate
Int16ArrayWrapper backupArray;
@Emulate
int positionCache;
@Emulate
int remainingCache;

public ShortBufferOverArrayEmu(int start, int capacity, short[] array, int position, int limit, boolean readOnly) {
super(start, capacity, array, position, limit, readOnly);
}

@Override
@Emulate
public ArrayBufferViewWrapper getArrayBufferView() {
Int16ArrayWrapper originalBuffer = (Int16ArrayWrapper)getOriginalArrayBufferView();
int position1 = position();
int remaining1 = remaining();
if(backupArray == null || positionCache != position1 || remaining1 != remainingCache) {
positionCache = position1;
remainingCache = remaining1;
backupArray = originalBuffer.subarray(position1, remaining1);
}
return backupArray;
}

@Override
@Emulate
public ArrayBufferViewWrapper getOriginalArrayBufferView() {
return TypedArrays.getTypedArray(array);
}

@Override
@Emulate
public int getElementSize() {
return 2;
}
}
Loading

0 comments on commit eb27ade

Please sign in to comment.