From a9e4bccecbbc48ad2fa85cf1560f177bd4b1b972 Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Thu, 14 Jun 2018 12:20:01 +0200 Subject: [PATCH] Fixed a bug --- .../java/ar/com/hjg/pngj/Deinterlacer.java | 11 ++++++--- .../ar/com/hjg/pngj/ImageLineSetDefault.java | 4 +++- .../java/ar/com/hjg/pngj/RowInfo.java | 8 +++++-- .../java/ar/com/hjg/pngj/chunks/PngChunk.java | 10 +++++++- .../ar/com/hjg/pngj/chunks/PngChunkBKGD.java | 4 +++- .../ar/com/hjg/pngj/chunks/PngChunkCHRM.java | 16 +++++++++---- .../ar/com/hjg/pngj/chunks/PngChunkFCTL.java | 16 ++++++++++--- .../ar/com/hjg/pngj/chunks/PngChunkSBIT.java | 10 ++++++-- .../ar/com/hjg/pngj/chunks/PngChunkTIME.java | 12 +++++++++- .../ar/com/hjg/pngj/chunks/PngChunkTRNS.java | 6 ++++- .../hjg/pngj/pixels/PixelsWriterMultiple.java | 4 +++- .../warp/picalculator/deps/StorageUtils.java | 5 ++-- .../device/graphicengine/RAWFont.java | 3 ++- .../picalculator/extra/mario/MarioBlock.java | 3 ++- .../warp/picalculator/gui/GraphicUtils.java | 17 ++++++++++---- .../gui/graphicengine/gpu/GPURenderer.java | 23 +++++++++++++++---- 16 files changed, 119 insertions(+), 33 deletions(-) diff --git a/src/jar-specific/java/ar/com/hjg/pngj/Deinterlacer.java b/src/jar-specific/java/ar/com/hjg/pngj/Deinterlacer.java index ffb7260c..3d84fd09 100644 --- a/src/jar-specific/java/ar/com/hjg/pngj/Deinterlacer.java +++ b/src/jar-specific/java/ar/com/hjg/pngj/Deinterlacer.java @@ -3,9 +3,14 @@ package ar.com.hjg.pngj; public class Deinterlacer { final ImageInfo imi; private int pass; // 1-7 - private int rows, cols; - int dY, dX, oY, oX; // current step and offset (in pixels) - int oXsamples, dXsamples; // step in samples + private int rows; +private int cols; + int dY; // current step and offset (in pixels) +int dX; +int oY; +int oX; + int oXsamples; // step in samples +int dXsamples; // current row in the virtual subsampled image; this increments (by 1) from 0 to rows/dy 7 times private int currRowSubimg; diff --git a/src/jar-specific/java/ar/com/hjg/pngj/ImageLineSetDefault.java b/src/jar-specific/java/ar/com/hjg/pngj/ImageLineSetDefault.java index 4dbdce30..bf3d59d4 100644 --- a/src/jar-specific/java/ar/com/hjg/pngj/ImageLineSetDefault.java +++ b/src/jar-specific/java/ar/com/hjg/pngj/ImageLineSetDefault.java @@ -12,7 +12,9 @@ public abstract class ImageLineSetDefault implements IImag protected final ImageInfo imgInfo; private final boolean singleCursor; - private final int nlines, offset, step; + private final int nlines; +private final int offset; +private final int step; protected List imageLines; // null if single cursor protected T imageLine; // null unless single cursor protected int currentRow = -1; // only relevant (and not much) for cursor diff --git a/src/jar-specific/java/ar/com/hjg/pngj/RowInfo.java b/src/jar-specific/java/ar/com/hjg/pngj/RowInfo.java index e033989c..0d5f0a51 100644 --- a/src/jar-specific/java/ar/com/hjg/pngj/RowInfo.java +++ b/src/jar-specific/java/ar/com/hjg/pngj/RowInfo.java @@ -7,12 +7,16 @@ class RowInfo { public final ImageInfo imgInfo; public final Deinterlacer deinterlacer; public final boolean imode; // Interlaced - int dY, dX, oY, oX; // current step and offset (in pixels) + int dY; // current step and offset (in pixels) +int dX; +int oY; +int oX; int rowNseq; // row number (from 0) in sequential read order int rowNreal; // row number in the real image int rowNsubImg; // current row in the virtual subsampled image; this increments (by 1) from 0 to // rows/dy 7 times - int rowsSubImg, colsSubImg; // size of current subimage , in pixels + int rowsSubImg; // size of current subimage , in pixels +int colsSubImg; int bytesRow; int pass; // 1-7 byte[] buf; // non-deep copy diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunk.java b/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunk.java index 16b82204..f5153652 100644 --- a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunk.java +++ b/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunk.java @@ -26,7 +26,15 @@ public abstract class PngChunk { /** * Autocomputed at creation time */ - public final boolean crit, pub, safe; + public final boolean crit; +/** + * Autocomputed at creation time + */ +public final boolean pub; +/** + * Autocomputed at creation time + */ +public final boolean safe; protected final ImageInfo imgInfo; diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkBKGD.java b/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkBKGD.java index 5ef2b305..cb3fdeb5 100644 --- a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkBKGD.java +++ b/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkBKGD.java @@ -15,7 +15,9 @@ public class PngChunkBKGD extends PngChunkSingle { public final static String ID = ChunkHelper.bKGD; // only one of these is meaningful private int gray; - private int red, green, blue; + private int red; +private int green; +private int blue; private int paletteIndex; public PngChunkBKGD(ImageInfo info) { diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkCHRM.java b/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkCHRM.java index f1b28fdc..57338cd1 100644 --- a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkCHRM.java +++ b/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkCHRM.java @@ -13,10 +13,18 @@ public class PngChunkCHRM extends PngChunkSingle { public final static String ID = ChunkHelper.cHRM; // http://www.w3.org/TR/PNG/#11cHRM - private double whitex, whitey; - private double redx, redy; - private double greenx, greeny; - private double bluex, bluey; + private double whitex; + +private double whitey; + private double redx; + +private double redy; + private double greenx; + +private double greeny; + private double bluex; + +private double bluey; public PngChunkCHRM(ImageInfo info) { super(ID, info); diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkFCTL.java b/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkFCTL.java index f55617cb..8fa125e0 100644 --- a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkFCTL.java +++ b/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkFCTL.java @@ -19,9 +19,19 @@ public class PngChunkFCTL extends PngChunkMultiple { public final static byte APNG_BLEND_OP_OVER = 1; private int seqNum; - private int width, height, xOff, yOff; - private int delayNum, delayDen; - private byte disposeOp, blendOp; + private int width; + +private int height; + +private int xOff; + +private int yOff; + private int delayNum; + +private int delayDen; + private byte disposeOp; + +private byte blendOp; public PngChunkFCTL(ImageInfo info) { super(ID, info); diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkSBIT.java b/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkSBIT.java index 6c6c7a62..eb2ebbde 100644 --- a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkSBIT.java +++ b/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkSBIT.java @@ -16,8 +16,14 @@ public class PngChunkSBIT extends PngChunkSingle { // http://www.w3.org/TR/PNG/#11sBIT // significant bits - private int graysb, alphasb; - private int redsb, greensb, bluesb; + private int graysb; + +private int alphasb; + private int redsb; + +private int greensb; + +private int bluesb; public PngChunkSBIT(ImageInfo info) { super(ID, info); diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkTIME.java b/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkTIME.java index 21e15132..40a0f4c2 100644 --- a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkTIME.java +++ b/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkTIME.java @@ -15,7 +15,17 @@ public class PngChunkTIME extends PngChunkSingle { public final static String ID = ChunkHelper.tIME; // http://www.w3.org/TR/PNG/#11tIME - private int year, mon, day, hour, min, sec; + private int year; + +private int mon; + +private int day; + +private int hour; + +private int min; + +private int sec; public PngChunkTIME(ImageInfo info) { super(ID, info); diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkTRNS.java b/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkTRNS.java index 82ad30fd..aa79c6ad 100644 --- a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkTRNS.java +++ b/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkTRNS.java @@ -18,7 +18,11 @@ public class PngChunkTRNS extends PngChunkSingle { // only one of these is meaningful, depending on the image type private int gray; - private int red, green, blue; + private int red; + +private int green; + +private int blue; private int[] paletteAlpha = new int[] {}; public PngChunkTRNS(ImageInfo info) { diff --git a/src/jar-specific/java/ar/com/hjg/pngj/pixels/PixelsWriterMultiple.java b/src/jar-specific/java/ar/com/hjg/pngj/pixels/PixelsWriterMultiple.java index 367dd981..427b41a2 100644 --- a/src/jar-specific/java/ar/com/hjg/pngj/pixels/PixelsWriterMultiple.java +++ b/src/jar-specific/java/ar/com/hjg/pngj/pixels/PixelsWriterMultiple.java @@ -29,7 +29,9 @@ public class PixelsWriterMultiple extends PixelsWriter { // smaller than rowsPerBand protected int rowInBand = -1; protected int bandNum = -1; - protected int firstRowInThisBand, lastRowInThisBand; + protected int firstRowInThisBand; + +protected int lastRowInThisBand; private boolean tryAdaptive = true; protected static final int HINT_MEMORY_DEFAULT_KB = 100; diff --git a/src/jar-specific/java/org/warp/picalculator/deps/StorageUtils.java b/src/jar-specific/java/org/warp/picalculator/deps/StorageUtils.java index d6454d11..3308bb96 100644 --- a/src/jar-specific/java/org/warp/picalculator/deps/StorageUtils.java +++ b/src/jar-specific/java/org/warp/picalculator/deps/StorageUtils.java @@ -25,6 +25,7 @@ import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.warp.picalculator.ClassUtils; import org.warp.picalculator.Main; import com.jogamp.common.util.IOUtil; @@ -50,7 +51,7 @@ public class StorageUtils { @Deprecated() public static File getResource(String string) throws IOException, URISyntaxException { - final URL res = Main.instance.getClass().getResource(string); + final URL res = ClassUtils.classLoader.getResource(string); final boolean isResource = res != null; if (isResource) { try { @@ -93,7 +94,7 @@ public class StorageUtils { } public static InputStream getResourceStream(String string) throws IOException, URISyntaxException { - final URL res = Main.instance.getClass().getResource(string); + final URL res = ClassUtils.classLoader.getResource(string); final boolean isResource = res != null; if (isResource) { try { diff --git a/src/main/java/org/warp/picalculator/device/graphicengine/RAWFont.java b/src/main/java/org/warp/picalculator/device/graphicengine/RAWFont.java index 3a16fd0f..3b563710 100755 --- a/src/main/java/org/warp/picalculator/device/graphicengine/RAWFont.java +++ b/src/main/java/org/warp/picalculator/device/graphicengine/RAWFont.java @@ -11,6 +11,7 @@ import java.util.logging.Logger; import javax.imageio.ImageIO; +import org.warp.picalculator.ClassUtils; import org.warp.picalculator.Main; import org.warp.picalculator.Utils; import org.warp.picalculator.deps.DSystem; @@ -75,7 +76,7 @@ public class RAWFont { } private void loadFont(String string) throws IOException { - final URL res = Main.instance.getClass().getResource(string); + final URL res = ClassUtils.classLoader.getClass().getResource(string); final int[] file = Utils.realBytes(Utils.convertStreamToByteArray(res.openStream(), res.getFile().length())); final int filelength = file.length; if (filelength >= 16) { diff --git a/src/main/java/org/warp/picalculator/extra/mario/MarioBlock.java b/src/main/java/org/warp/picalculator/extra/mario/MarioBlock.java index 0a287be0..48deff06 100644 --- a/src/main/java/org/warp/picalculator/extra/mario/MarioBlock.java +++ b/src/main/java/org/warp/picalculator/extra/mario/MarioBlock.java @@ -1,7 +1,8 @@ package org.warp.picalculator.extra.mario; public class MarioBlock { - private final int x, y; + private final int x; + private final int y; private final byte id; public MarioBlock(int x, int y, byte b) { diff --git a/src/main/java/org/warp/picalculator/gui/GraphicUtils.java b/src/main/java/org/warp/picalculator/gui/GraphicUtils.java index 0e56bfd5..066bd0fb 100755 --- a/src/main/java/org/warp/picalculator/gui/GraphicUtils.java +++ b/src/main/java/org/warp/picalculator/gui/GraphicUtils.java @@ -18,11 +18,18 @@ public class GraphicUtils { } @SuppressWarnings("unused") - private static final float RAD, DEG; - private static final int SIN_BITS, SIN_MASK, SIN_COUNT; - private static final float radFull, radToIndex; - private static final float degFull, degToIndex; - private static final float[] sin, cos; + private static final float RAD; + @SuppressWarnings("unused") + private static final float DEG; + private static final int SIN_BITS; + private static final int SIN_MASK; + private static final int SIN_COUNT; + private static final float radFull; + private static final float radToIndex; + private static final float degFull; + private static final float degToIndex; + private static final float[] sin; + private static final float[] cos; static { RAD = (float) Math.PI / 180.0f; diff --git a/src/main/java/org/warp/picalculator/gui/graphicengine/gpu/GPURenderer.java b/src/main/java/org/warp/picalculator/gui/graphicengine/gpu/GPURenderer.java index f9d4ae56..9b25cb53 100755 --- a/src/main/java/org/warp/picalculator/gui/graphicengine/gpu/GPURenderer.java +++ b/src/main/java/org/warp/picalculator/gui/graphicengine/gpu/GPURenderer.java @@ -28,10 +28,25 @@ public class GPURenderer implements Renderer { public static GL2ES1 gl; private static final int ELEMENTS_MAX_COUNT_PER_BUFFER = StaticVars.enableVBO ? 128 : 1; - private static final int ELEMENT_VERTICES_COUNT = 6, vertSize = 3, texSize = 2, colSize = 4, vertBuffer = 0, - texBuffer = 1, colBuffer = 2, vertMax = vertSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER, - texMax = texSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER, - colMax = colSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER; + private static final int ELEMENT_VERTICES_COUNT = 6; + + private static final int vertSize = 3; + + private static final int texSize = 2; + + private static final int colSize = 4; + + private static final int vertBuffer = 0; + + private static final int texBuffer = 1; + + private static final int colBuffer = 2; + + private static final int vertMax = vertSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER; + + private static final int texMax = texSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER; + + private static final int colMax = colSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER; private int[] handlers; private final DeallocationHelper deallocationHelper = new DeallocationHelper();