Skip to content

Commit

Permalink
Merge pull request #135 from xpenatan/master
Browse files Browse the repository at this point in the history
Release v1.0.4
  • Loading branch information
xpenatan authored Oct 25, 2024
2 parents af9f041 + cbff64c commit a8c6bad
Show file tree
Hide file tree
Showing 22 changed files with 131 additions and 209 deletions.
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
[-SNAPSHOT]

[1.0.4]
- Fix music id
- add custom gltf resource path
- Code improvement when using physical pixels
- Fix file handle list returning wrong path
- UsePhysicalPixels is set to false by default
- Fix webgl buffers

[1.0.3]
- Don't download assets if preload assets is true
- add PowerPreference option
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@
@Emulate(valueStr = "java.nio.ByteBufferImpl", updateCode = true)
public abstract class ByteBufferImplEmu extends TByteBufferImpl implements HasArrayBufferView {

@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);
}
Expand All @@ -24,14 +17,7 @@ public ByteBufferImplEmu(int start, int capacity, byte[] array, int position, in
@Emulate
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;
return int8Array;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
@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);
}
Expand All @@ -23,14 +16,7 @@ public FloatBufferOverArrayEmu(int start, int capacity, float[] array, int posit
@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;
return originalBuffer;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
@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;
@Emulate
int capacityCache;

public FloatBufferOverByteBufferEmu(int start, int capacity, TByteBufferImpl byteBuffer, int position, int limit, boolean readOnly) {
super(start, capacity, byteBuffer, position, limit, readOnly);
Expand All @@ -27,18 +27,15 @@ public FloatBufferOverByteBufferEmu(int start, int capacity, TByteBufferImpl byt
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) {
int capacity1 = capacity();
if(positionCache != position1 || remainingCache != remaining1 || capacityCache != capacity1) {
floatArray = TypedArrays.createFloat32Array(int8Array.getBuffer());
positionCache = position1;
remainingCache = remaining1;
backupArray = floatArray.subarray(position1, remaining1);
}
return backupArray;
return floatArray;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
@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);
}
Expand All @@ -23,14 +16,7 @@ public IntBufferOverArrayEmu(int start, int capacity, int[] array, int position,
@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;
return originalBuffer;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
@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;

@Emulate
int capacityCache;

public IntBufferOverByteBufferEmu(int start, int capacity, TByteBufferImpl byteBuffer, int position, int limit, boolean readOnly) {
super(start, capacity, byteBuffer, position, limit, readOnly);
Expand All @@ -28,17 +27,15 @@ public IntBufferOverByteBufferEmu(int start, int capacity, TByteBufferImpl byteB
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) {
int capacity1 = capacity();
if(positionCache != position1 || remainingCache != remaining1 || capacityCache != capacity1) {
intArray = TypedArrays.createInt32Array(int8Array.getBuffer());
positionCache = position1;
remainingCache = remaining1;
backupArray = intArray.subarray(position1, remaining1);
}
return backupArray;
return intArray;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
@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);
}
Expand All @@ -23,14 +16,7 @@ public ShortBufferOverArrayEmu(int start, int capacity, short[] array, int posit
@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;
return originalBuffer;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
@Emulate(valueStr = "java.nio.ShortBufferOverByteBuffer", updateCode = true)
public abstract class ShortBufferOverByteBufferEmu extends TShortBufferOverByteBuffer implements HasArrayBufferView {

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

public ShortBufferOverByteBufferEmu(int start, int capacity, TByteBufferImpl byteBuffer, int position, int limit, boolean readOnly) {
super(start, capacity, byteBuffer, position, limit, readOnly);
Expand All @@ -27,17 +27,16 @@ public ShortBufferOverByteBufferEmu(int start, int capacity, TByteBufferImpl byt
public ArrayBufferViewWrapper getArrayBufferView() {
// Int8Array
Int8ArrayWrapper int8Array = (Int8ArrayWrapper)getOriginalArrayBufferView();
if(shortArray == null) {
shortArray = TypedArrays.createInt16Array(int8Array.getBuffer());
}
int position1 = position();
int remaining1 = remaining();
if(backupArray == null || positionCache != position1 || remaining1 != remainingCache) {
int capacity1 = capacity();
if(positionCache != position1 || remainingCache != remaining1 || capacityCache != capacity1) {
shortArray = TypedArrays.createInt16Array(int8Array.getBuffer());
positionCache = position1;
remainingCache = remaining1;
backupArray = shortArray.subarray(position1, remaining1);
capacityCache = capacity1;
}
return backupArray;
return shortArray;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,7 @@ public void handleEvent(EventWrapper evt) {
}

if(graphics != null) {
// event calls us with logical pixel size, so if we use physical pixels internally,
// we need to convert them
if(config.usePhysicalPixels) {
double density = graphics.getNativeScreenDensity();
width = (int)(width * density);
height = (int)(height * density);
}
graphics.setCanvasSize(width, height);
graphics.setCanvasSize(width, height, config.usePhysicalPixels);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class TeaApplicationConfiguration {
* Setting to false mostly makes sense for fixed-size games or non-mobile games expecting performance issues on huge
* resolutions. If you target mobiles and desktops, consider using physical device pixels on mobile devices only by using the
* return value of {@link TeaApplication#isMobileDevice()} . */
public boolean usePhysicalPixels = true;
public boolean usePhysicalPixels = false;

/**
* default, low-power or high-performance
Expand Down
Loading

0 comments on commit a8c6bad

Please sign in to comment.