summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Stanford <noah@livio.io>2022-01-11 14:58:13 -0500
committerNoah Stanford <noah@livio.io>2022-01-11 14:58:13 -0500
commitb2bf54232e955080e6a969d7ee5b770c86a1ee87 (patch)
treea126cb7b7c770046861645e80aa41e15fe69ae37
parentff103a88b51c35813ff0a12059fb0df6d1239f2c (diff)
downloadsdl_android-b2bf54232e955080e6a969d7ee5b770c86a1ee87.tar.gz
Revert changes to Grafika files
-rw-r--r--android/sdl_android/src/androidTest/java/com/android/grafika/gles/OffscreenSurfaceTest.java167
-rw-r--r--android/sdl_android/src/main/java/com/android/grafika/gles/Drawable2d.java10
-rw-r--r--android/sdl_android/src/main/java/com/android/grafika/gles/EglCore.java12
-rw-r--r--android/sdl_android/src/main/java/com/android/grafika/gles/EglSurfaceBase.java4
-rw-r--r--android/sdl_android/src/main/java/com/android/grafika/gles/GlUtil.java20
-rw-r--r--android/sdl_android/src/main/java/com/android/grafika/gles/Texture2dProgram.java20
6 files changed, 116 insertions, 117 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/android/grafika/gles/OffscreenSurfaceTest.java b/android/sdl_android/src/androidTest/java/com/android/grafika/gles/OffscreenSurfaceTest.java
index 24fa25579..2f93c8307 100644
--- a/android/sdl_android/src/androidTest/java/com/android/grafika/gles/OffscreenSurfaceTest.java
+++ b/android/sdl_android/src/androidTest/java/com/android/grafika/gles/OffscreenSurfaceTest.java
@@ -18,89 +18,88 @@ import static junit.framework.TestCase.assertTrue;
@RunWith(AndroidJUnit4.class)
public class OffscreenSurfaceTest {
- private final String TAG = OffscreenSurfaceTest.class.getSimpleName();
- private final int mWidth = 1280;
- private final int mHeight = 720;
- private final int mIterations = 100;
-
- @Test
- public void testReadPixels() {
- EglCore eglCore = new EglCore(null, 0);
- OffscreenSurface offscreenSurface = new OffscreenSurface(eglCore, mWidth, mHeight);
- float time = runReadPixelsTest(offscreenSurface);
- Log.d(TAG, "runReadPixelsTest returns " + time + " msec");
- }
-
- // HELPER test method
-
- /**
- * Does a simple bit of rendering and then reads the pixels back.
- *
- * @return total time (msec order) spent on glReadPixels()
- */
- private float runReadPixelsTest(OffscreenSurface eglSurface) {
- long totalTime = 0;
-
- eglSurface.makeCurrent();
-
- ByteBuffer pixelBuf = ByteBuffer.allocateDirect(mWidth * mHeight * 4);
- pixelBuf.order(ByteOrder.LITTLE_ENDIAN);
-
- Log.d(TAG, "Running...");
- float colorMult = 1.0f / mIterations;
- for (int i = 0; i < mIterations; i++) {
- if ((i % (mIterations / 8)) == 0) {
- Log.d(TAG, "iteration " + i);
- }
-
- // Clear the screen to a solid color, then add a rectangle. Change the color
- // each time.
- float r = i * colorMult;
- float g = 1.0f - r;
- float b = (r + g) / 2.0f;
- GLES20.glClearColor(r, g, b, 1.0f);
- GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
-
- GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
- GLES20.glScissor(mWidth / 4, mHeight / 4, mWidth / 2, mHeight / 2);
- GLES20.glClearColor(b, g, r, 1.0f);
- GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
- GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
-
- // Try to ensure that rendering has finished.
- GLES20.glFinish();
- GLES20.glReadPixels(0, 0, 1, 1,
- GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, pixelBuf);
-
- // Time individual extraction. Ideally we'd be timing a bunch of these calls
- // and measuring the aggregate time, but we want the isolated time, and if we
- // just read the same buffer repeatedly we might get some sort of cache effect.
- long startWhen = System.nanoTime();
- GLES20.glReadPixels(0, 0, mWidth, mHeight,
- GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, pixelBuf);
- totalTime += System.nanoTime() - startWhen;
- }
- Log.d(TAG, "done");
-
- // It's not the good idea to request external strage permission in unit test.
- boolean requireStoragePermission = false;
- if (requireStoragePermission) {
- long startWhen = System.nanoTime();
- File file = new File(Environment.getExternalStorageDirectory(),
- "test.png");
- try {
- eglSurface.saveFrame(file);
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
- }
- Log.d(TAG, "Saved frame in " + ((System.nanoTime() - startWhen) / 1000000) + "ms");
- assertTrue(file.exists());
- } else {
- // here' we can recognize Unit Test succeeded, but anyway checks to see totalTime and buffer capacity.
- assertTrue(pixelBuf.capacity() > 0 && totalTime > 0);
- }
-
- return (float) totalTime / 1000000f;
- }
+ private final String TAG = OffscreenSurfaceTest.class.getSimpleName();
+ private final int mWidth = 1280;
+ private final int mHeight = 720;
+ private final int mIterations = 100;
+
+ @Test
+ public void testReadPixels() {
+ EglCore eglCore = new EglCore(null, 0);
+ OffscreenSurface offscreenSurface = new OffscreenSurface(eglCore, mWidth, mHeight);
+ float time = runReadPixelsTest(offscreenSurface);
+ Log.d(TAG, "runReadPixelsTest returns " + time + " msec");
+ }
+
+ // HELPER test method
+ /**
+ * Does a simple bit of rendering and then reads the pixels back.
+ *
+ * @return total time (msec order) spent on glReadPixels()
+ */
+ private float runReadPixelsTest(OffscreenSurface eglSurface) {
+ long totalTime = 0;
+
+ eglSurface.makeCurrent();
+
+ ByteBuffer pixelBuf = ByteBuffer.allocateDirect(mWidth * mHeight * 4);
+ pixelBuf.order(ByteOrder.LITTLE_ENDIAN);
+
+ Log.d(TAG, "Running...");
+ float colorMult = 1.0f / mIterations;
+ for (int i = 0; i < mIterations; i++) {
+ if ((i % (mIterations / 8)) == 0) {
+ Log.d(TAG, "iteration " + i);
+ }
+
+ // Clear the screen to a solid color, then add a rectangle. Change the color
+ // each time.
+ float r = i * colorMult;
+ float g = 1.0f - r;
+ float b = (r + g) / 2.0f;
+ GLES20.glClearColor(r, g, b, 1.0f);
+ GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
+
+ GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
+ GLES20.glScissor(mWidth / 4, mHeight / 4, mWidth / 2, mHeight / 2);
+ GLES20.glClearColor(b, g, r, 1.0f);
+ GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
+ GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
+
+ // Try to ensure that rendering has finished.
+ GLES20.glFinish();
+ GLES20.glReadPixels(0, 0, 1, 1,
+ GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, pixelBuf);
+
+ // Time individual extraction. Ideally we'd be timing a bunch of these calls
+ // and measuring the aggregate time, but we want the isolated time, and if we
+ // just read the same buffer repeatedly we might get some sort of cache effect.
+ long startWhen = System.nanoTime();
+ GLES20.glReadPixels(0, 0, mWidth, mHeight,
+ GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, pixelBuf);
+ totalTime += System.nanoTime() - startWhen;
+ }
+ Log.d(TAG, "done");
+
+ // It's not the good idea to request external strage permission in unit test.
+ boolean requireStoragePermission = false;
+ if (requireStoragePermission) {
+ long startWhen = System.nanoTime();
+ File file = new File(Environment.getExternalStorageDirectory(),
+ "test.png");
+ try {
+ eglSurface.saveFrame(file);
+ } catch (IOException ioe) {
+ throw new RuntimeException(ioe);
+ }
+ Log.d(TAG, "Saved frame in " + ((System.nanoTime() - startWhen) / 1000000) + "ms");
+ assertTrue(file.exists());
+ } else {
+ // here' we can recognize Unit Test succeeded, but anyway checks to see totalTime and buffer capacity.
+ assertTrue(pixelBuf.capacity() > 0 && totalTime > 0);
+ }
+
+ return (float)totalTime / 1000000f;
+ }
}
diff --git a/android/sdl_android/src/main/java/com/android/grafika/gles/Drawable2d.java b/android/sdl_android/src/main/java/com/android/grafika/gles/Drawable2d.java
index 4820e6a7d..52fcabf1f 100644
--- a/android/sdl_android/src/main/java/com/android/grafika/gles/Drawable2d.java
+++ b/android/sdl_android/src/main/java/com/android/grafika/gles/Drawable2d.java
@@ -28,7 +28,7 @@ public class Drawable2d {
* Simple equilateral triangle (1.0 per side). Centered on (0,0).
*/
private static final float TRIANGLE_COORDS[] = {
- 0.0f, 0.577350269f, // 0 top
+ 0.0f, 0.577350269f, // 0 top
-0.5f, -0.288675135f, // 1 bottom left
0.5f, -0.288675135f // 2 bottom right
};
@@ -51,8 +51,8 @@ public class Drawable2d {
private static final float RECTANGLE_COORDS[] = {
-0.5f, -0.5f, // 0 bottom left
0.5f, -0.5f, // 1 bottom right
- -0.5f, 0.5f, // 2 top left
- 0.5f, 0.5f, // 3 top right
+ -0.5f, 0.5f, // 2 top left
+ 0.5f, 0.5f, // 3 top right
};
private static final float RECTANGLE_TEX_COORDS[] = {
0.0f, 1.0f, // 0 bottom left
@@ -75,8 +75,8 @@ public class Drawable2d {
private static final float FULL_RECTANGLE_COORDS[] = {
-1.0f, -1.0f, // 0 bottom left
1.0f, -1.0f, // 1 bottom right
- -1.0f, 1.0f, // 2 top left
- 1.0f, 1.0f, // 3 top right
+ -1.0f, 1.0f, // 2 top left
+ 1.0f, 1.0f, // 3 top right
};
private static final float FULL_RECTANGLE_TEX_COORDS[] = {
0.0f, 0.0f, // 0 bottom left
diff --git a/android/sdl_android/src/main/java/com/android/grafika/gles/EglCore.java b/android/sdl_android/src/main/java/com/android/grafika/gles/EglCore.java
index b714f58b0..9e814a529 100644
--- a/android/sdl_android/src/main/java/com/android/grafika/gles/EglCore.java
+++ b/android/sdl_android/src/main/java/com/android/grafika/gles/EglCore.java
@@ -133,7 +133,7 @@ public final class EglCore {
int[] values = new int[1];
EGL14.eglQueryContext(mEGLDisplay, mEGLContext, EGL14.EGL_CONTEXT_CLIENT_VERSION,
values, 0);
- Log.d(TAG, "EGLContext created, client version " + values[0]);
+ Log.d(TAG,"EGLContext created, client version " + values[0]);
}
/**
@@ -170,7 +170,7 @@ public final class EglCore {
int[] numConfigs = new int[1];
if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
numConfigs, 0)) {
- Log.d(TAG, "unable to find RGB8888 / " + version + " EGLConfig");
+ Log.d(TAG,"unable to find RGB8888 / " + version + " EGLConfig");
return null;
}
return configs[0];
@@ -206,7 +206,7 @@ public final class EglCore {
// the EGL state, so if a surface or context is still current on another
// thread we can't fully release it here. Exceptions thrown from here
// are quietly discarded. Complain in the log file.
- Log.e(TAG, "WARNING: EglCore was not explicitly released -- state may be leaked");
+ Log.e(TAG,"WARNING: EglCore was not explicitly released -- state may be leaked");
release();
}
} finally {
@@ -269,7 +269,7 @@ public final class EglCore {
public void makeCurrent(EGLSurface eglSurface) {
if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
// called makeCurrent() before create?
- Log.d(TAG, "NOTE: makeCurrent w/o display");
+ Log.d(TAG,"NOTE: makeCurrent w/o display");
}
if (!EGL14.eglMakeCurrent(mEGLDisplay, eglSurface, eglSurface, mEGLContext)) {
throw new RuntimeException("eglMakeCurrent failed");
@@ -282,7 +282,7 @@ public final class EglCore {
public void makeCurrent(EGLSurface drawSurface, EGLSurface readSurface) {
if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
// called makeCurrent() before create?
- Log.d(TAG, "NOTE: makeCurrent w/o display");
+ Log.d(TAG,"NOTE: makeCurrent w/o display");
}
if (!EGL14.eglMakeCurrent(mEGLDisplay, drawSurface, readSurface, mEGLContext)) {
throw new RuntimeException("eglMakeCurrent(draw,read) failed");
@@ -357,7 +357,7 @@ public final class EglCore {
display = EGL14.eglGetCurrentDisplay();
context = EGL14.eglGetCurrentContext();
surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
- Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context + ", surface=" + surface);
+ Log.i(TAG,"Current EGL (" + msg + "): display=" + display + ", context=" + context + ", surface=" + surface);
}
/**
diff --git a/android/sdl_android/src/main/java/com/android/grafika/gles/EglSurfaceBase.java b/android/sdl_android/src/main/java/com/android/grafika/gles/EglSurfaceBase.java
index 6553dbc31..3223a4073 100644
--- a/android/sdl_android/src/main/java/com/android/grafika/gles/EglSurfaceBase.java
+++ b/android/sdl_android/src/main/java/com/android/grafika/gles/EglSurfaceBase.java
@@ -135,7 +135,7 @@ public class EglSurfaceBase {
public boolean swapBuffers() {
boolean result = mEglCore.swapBuffers(mEGLSurface);
if (!result) {
- Log.d(TAG, "WARNING: swapBuffers() failed");
+ Log.d(TAG,"WARNING: swapBuffers() failed");
}
return result;
}
@@ -192,6 +192,6 @@ public class EglSurfaceBase {
} finally {
if (bos != null) bos.close();
}
- Log.d(TAG, "Saved " + width + "x" + height + " frame as '" + filename + "'");
+ Log.d(TAG,"Saved " + width + "x" + height + " frame as '" + filename + "'");
}
}
diff --git a/android/sdl_android/src/main/java/com/android/grafika/gles/GlUtil.java b/android/sdl_android/src/main/java/com/android/grafika/gles/GlUtil.java
index 40a959c0a..4eed8d00c 100644
--- a/android/sdl_android/src/main/java/com/android/grafika/gles/GlUtil.java
+++ b/android/sdl_android/src/main/java/com/android/grafika/gles/GlUtil.java
@@ -61,7 +61,7 @@ public class GlUtil {
int program = GLES20.glCreateProgram();
checkGlError("glCreateProgram");
if (program == 0) {
- Log.d(TAG, "Could not create program");
+ Log.d(TAG,"Could not create program");
}
GLES20.glAttachShader(program, vertexShader);
checkGlError("glAttachShader");
@@ -71,8 +71,8 @@ public class GlUtil {
int[] linkStatus = new int[1];
GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0);
if (linkStatus[0] != GLES20.GL_TRUE) {
- Log.e(TAG, "Could not link program: ");
- Log.e(TAG, GLES20.glGetProgramInfoLog(program));
+ Log.e(TAG,"Could not link program: ");
+ Log.e(TAG,GLES20.glGetProgramInfoLog(program));
GLES20.glDeleteProgram(program);
program = 0;
}
@@ -92,8 +92,8 @@ public class GlUtil {
int[] compiled = new int[1];
GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0);
if (compiled[0] == 0) {
- Log.e(TAG, "Could not compile shader " + shaderType + ":");
- Log.e(TAG, " " + GLES20.glGetShaderInfoLog(shader));
+ Log.e(TAG,"Could not compile shader " + shaderType + ":");
+ Log.e(TAG," " + GLES20.glGetShaderInfoLog(shader));
GLES20.glDeleteShader(shader);
shader = 0;
}
@@ -107,7 +107,7 @@ public class GlUtil {
int error = GLES20.glGetError();
if (error != GLES20.GL_NO_ERROR) {
String msg = op + ": glError 0x" + Integer.toHexString(error);
- Log.e(TAG, msg);
+ Log.e(TAG,msg);
throw new RuntimeException(msg);
}
}
@@ -177,9 +177,9 @@ public class GlUtil {
* Writes GL version info to the log.
*/
public static void logVersionInfo() {
- Log.i(TAG, "vendor : " + GLES20.glGetString(GLES20.GL_VENDOR));
- Log.i(TAG, "renderer: " + GLES20.glGetString(GLES20.GL_RENDERER));
- Log.i(TAG, "version : " + GLES20.glGetString(GLES20.GL_VERSION));
+ Log.i(TAG,"vendor : " + GLES20.glGetString(GLES20.GL_VENDOR));
+ Log.i(TAG,"renderer: " + GLES20.glGetString(GLES20.GL_RENDERER));
+ Log.i(TAG,"version : " + GLES20.glGetString(GLES20.GL_VERSION));
if (false) {
int[] values = new int[1];
@@ -188,7 +188,7 @@ public class GlUtil {
GLES30.glGetIntegerv(GLES30.GL_MINOR_VERSION, values, 0);
int minorVersion = values[0];
if (GLES30.glGetError() == GLES30.GL_NO_ERROR) {
- Log.i(TAG, "iversion: " + majorVersion + "." + minorVersion);
+ Log.i(TAG,"iversion: " + majorVersion + "." + minorVersion);
}
}
}
diff --git a/android/sdl_android/src/main/java/com/android/grafika/gles/Texture2dProgram.java b/android/sdl_android/src/main/java/com/android/grafika/gles/Texture2dProgram.java
index 7e18d1adf..1faed6776 100644
--- a/android/sdl_android/src/main/java/com/android/grafika/gles/Texture2dProgram.java
+++ b/android/sdl_android/src/main/java/com/android/grafika/gles/Texture2dProgram.java
@@ -162,7 +162,7 @@ public class Texture2dProgram {
if (mProgramHandle == 0) {
throw new RuntimeException("Unable to create program");
}
- Log.e(TAG, "Created program " + mProgramHandle + " (" + programType + ")");
+ Log.e(TAG,"Created program " + mProgramHandle + " (" + programType + ")");
// get locations of attributes and uniforms
@@ -188,7 +188,7 @@ public class Texture2dProgram {
GlUtil.checkLocation(muColorAdjustLoc, "uColorAdjust");
// initialize default values
- setKernel(new float[]{0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f}, 0f);
+ setKernel(new float[] {0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f}, 0f);
setTexSize(256, 256);
}
}
@@ -200,7 +200,7 @@ public class Texture2dProgram {
* the program).
*/
public void release() {
- Log.d(TAG, "deleting program " + mProgramHandle);
+ Log.d(TAG,"deleting program " + mProgramHandle);
GLES20.glDeleteProgram(mProgramHandle);
mProgramHandle = -1;
}
@@ -251,7 +251,7 @@ public class Texture2dProgram {
}
System.arraycopy(values, 0, mKernel, 0, KERNEL_SIZE);
mColorAdjust = colorAdj;
- Log.d(TAG, "filt kernel: " + Arrays.toString(mKernel) + ", adj=" + colorAdj);
+ Log.d(TAG,"filt kernel: " + Arrays.toString(mKernel) + ", adj=" + colorAdj);
}
/**
@@ -262,12 +262,12 @@ public class Texture2dProgram {
float rh = 1.0f / height;
// Don't need to create a new array here, but it's syntactically convenient.
- mTexOffset = new float[]{
- -rw, -rh, 0f, -rh, rw, -rh,
- -rw, 0f, 0f, 0f, rw, 0f,
- -rw, rh, 0f, rh, rw, rh
+ mTexOffset = new float[] {
+ -rw, -rh, 0f, -rh, rw, -rh,
+ -rw, 0f, 0f, 0f, rw, 0f,
+ -rw, rh, 0f, rh, rw, rh
};
- Log.d(TAG, "filt size: " + width + "x" + height + ": " + Arrays.toString(mTexOffset));
+ Log.d(TAG,"filt size: " + width + "x" + height + ": " + Arrays.toString(mTexOffset));
}
/**
@@ -322,7 +322,7 @@ public class Texture2dProgram {
// Connect texBuffer to "aTextureCoord".
GLES20.glVertexAttribPointer(maTextureCoordLoc, 2,
GLES20.GL_FLOAT, false, texStride, texBuffer);
- GlUtil.checkGlError("glVertexAttribPointer");
+ GlUtil.checkGlError("glVertexAttribPointer");
// Populate the convolution kernel, if present.
if (muKernelLoc >= 0) {