From 1b71df25c68733a49cc56c3d214c9eb4a90453f8 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Sun, 16 Dec 2012 17:01:21 +0000 Subject: [PATCH] renamed utility getPixels/putPixels methods --- android/core/src/processing/opengl/PGL.java | 90 +++++++++++++++---- .../processing/opengl/PGraphicsOpenGL.java | 4 +- 2 files changed, 74 insertions(+), 20 deletions(-) diff --git a/android/core/src/processing/opengl/PGL.java b/android/core/src/processing/opengl/PGL.java index 02a3496ae..bc5c8bd94 100644 --- a/android/core/src/processing/opengl/PGL.java +++ b/android/core/src/processing/opengl/PGL.java @@ -2215,6 +2215,24 @@ public class PGL { } + protected static void getByteArray(ByteBuffer buf, byte[] arr) { + if (!buf.hasArray() || buf.array() != arr) { + buf.position(0); + buf.get(arr); + buf.rewind(); + } + } + + + protected static void putByteArray(ByteBuffer buf, byte[] arr) { + if (!buf.hasArray() || buf.array() != arr) { + buf.position(0); + buf.put(arr); + buf.rewind(); + } + } + + protected static void fillByteBuffer(ByteBuffer buf, int i0, int i1, byte val) { int n = i1 - i0; @@ -2276,6 +2294,24 @@ public class PGL { } + protected static void getShortArray(ShortBuffer buf, short[] arr) { + if (!buf.hasArray() || buf.array() != arr) { + buf.position(0); + buf.get(arr); + buf.rewind(); + } + } + + + protected static void putShortArray(ShortBuffer buf, short[] arr) { + if (!buf.hasArray() || buf.array() != arr) { + buf.position(0); + buf.put(arr); + buf.rewind(); + } + } + + protected static void fillShortBuffer(ShortBuffer buf, int i0, int i1, short val) { int n = i1 - i0; @@ -2337,6 +2373,24 @@ public class PGL { } + protected static void getIntArray(IntBuffer buf, int[] arr) { + if (!buf.hasArray() || buf.array() != arr) { + buf.position(0); + buf.get(arr); + buf.rewind(); + } + } + + + protected static void putIntArray(IntBuffer buf, int[] arr) { + if (!buf.hasArray() || buf.array() != arr) { + buf.position(0); + buf.put(arr); + buf.rewind(); + } + } + + protected static void fillIntBuffer(IntBuffer buf, int i0, int i1, int val) { int n = i1 - i0; int[] temp = new int[n]; @@ -2397,6 +2451,24 @@ public class PGL { } + protected static void getFloatArray(FloatBuffer buf, float[] arr) { + if (!buf.hasArray() || buf.array() != arr) { + buf.position(0); + buf.get(arr); + buf.rewind(); + } + } + + + protected static void putFloatArray(FloatBuffer buf, float[] arr) { + if (!buf.hasArray() || buf.array() != arr) { + buf.position(0); + buf.put(arr); + buf.rewind(); + } + } + + protected static void fillFloatBuffer(FloatBuffer buf, int i0, int i1, float val) { int n = i1 - i0; @@ -2408,24 +2480,6 @@ public class PGL { } - protected static void getPixels(IntBuffer buf, int[] arr) { - if (USE_DIRECT_BUFFERS) { - buf.position(0); - buf.get(arr); - buf.rewind(); - } - } - - - protected static void putPixels(IntBuffer buf, int[] arr) { - if (USE_DIRECT_BUFFERS) { - buf.position(0); - buf.put(arr); - buf.rewind(); - } - } - - /////////////////////////////////////////////////////////// // Android specific stuff diff --git a/android/core/src/processing/opengl/PGraphicsOpenGL.java b/android/core/src/processing/opengl/PGraphicsOpenGL.java index 572b6e4ce..92f84deab 100644 --- a/android/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/android/core/src/processing/opengl/PGraphicsOpenGL.java @@ -5067,7 +5067,7 @@ public class PGraphicsOpenGL extends PGraphics { endPixelsOp(); try { // Idem... - PGL.getPixels(pixelBuffer, pixels); + PGL.getIntArray(pixelBuffer, pixels); PGL.nativeToJavaARGB(pixels, width, height); } catch (ArrayIndexOutOfBoundsException e) { } @@ -5100,7 +5100,7 @@ public class PGraphicsOpenGL extends PGraphics { PGL.javaToNativeARGB(nativePixels, w, h); } catch (ArrayIndexOutOfBoundsException e) { } - PGL.putPixels(nativePixelBuffer, nativePixels); + PGL.putIntArray(nativePixelBuffer, nativePixels); // Copying pixel buffer to screen texture... if (primarySurface && !pgl.isFBOBacked()) { // First making sure that the screen texture is valid. Only in the case