Revert "Drop it "

This reverts commit cc66e7e7c843e295f999b23b7fa8258c2ec9dbea.
This commit is contained in:
cyberpwn 2021-09-22 08:55:45 -04:00
parent 958a09b280
commit 3ba7c18288

View File

@ -152,6 +152,27 @@ public interface MatterSlice<T> extends Hunk<T>, PaletteType<T> {
default void write(DataOutputStream dos) throws IOException {
dos.writeUTF(getType().getCanonicalName());
if(IrisSettings.get().getPerformance().isUseExperimentalMantleMemoryCompression() && (this instanceof PaletteOrHunk f && f.isPalette()))
{
PalettedContainer<T> c = f.palette();
List<T> palette = new ArrayList<>();
long[] data = c.write(palette);
Varint.writeUnsignedVarInt(palette.size(), dos);
for(T i : palette)
{
writeNode(i, dos);
}
Varint.writeUnsignedVarInt(data.length, dos);
for(long i : data)
{
dos.writeLong(i);
}
return;
}
int w = getWidth();
int h = getHeight();
MatterPalette<T> palette = new MatterPalette<T>(this);
@ -171,6 +192,29 @@ public interface MatterSlice<T> extends Hunk<T>, PaletteType<T> {
}
default void read(DataInputStream din) throws IOException {
if(IrisSettings.get().getPerformance().isUseExperimentalMantleMemoryCompression() && (this instanceof PaletteOrHunk f && f.isPalette()))
{
PalettedContainer<T> c = new PalettedContainer<>();
List<T> palette = new ArrayList<>();
int ps = Varint.readUnsignedVarInt(din);
for(int i = 0; i < ps; i++)
{
palette.add(readNode(din));
}
int ds = Varint.readUnsignedVarInt(din);
long[] data = new long[ds];
for(int i = 0; i < ds; i++)
{
data[i] = din.readLong();
}
c.read(palette, data);
return;
}
int w = getWidth();
int h = getHeight();
MatterPalette<T> palette = new MatterPalette<T>(this, din);