summaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/gallery3d/glrenderer
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/com/android/gallery3d/glrenderer')
-rw-r--r--tests/src/com/android/gallery3d/glrenderer/GLCanvasMock.java71
-rw-r--r--tests/src/com/android/gallery3d/glrenderer/GLCanvasTest.java386
-rw-r--r--tests/src/com/android/gallery3d/glrenderer/GLMock.java197
-rw-r--r--tests/src/com/android/gallery3d/glrenderer/GLStub.java1490
-rw-r--r--tests/src/com/android/gallery3d/glrenderer/TextureTest.java208
5 files changed, 2352 insertions, 0 deletions
diff --git a/tests/src/com/android/gallery3d/glrenderer/GLCanvasMock.java b/tests/src/com/android/gallery3d/glrenderer/GLCanvasMock.java
new file mode 100644
index 000000000..a57c18840
--- /dev/null
+++ b/tests/src/com/android/gallery3d/glrenderer/GLCanvasMock.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.glrenderer;
+
+import com.android.gallery3d.glrenderer.BasicTexture;
+import com.android.gallery3d.ui.GLCanvasStub;
+
+import javax.microedition.khronos.opengles.GL11;
+
+public class GLCanvasMock extends GLCanvasStub {
+ // fillRect
+ int mFillRectCalled;
+ float mFillRectWidth;
+ float mFillRectHeight;
+ int mFillRectColor;
+ // drawMixed
+ int mDrawMixedCalled;
+ float mDrawMixedRatio;
+ // drawTexture;
+ int mDrawTextureCalled;
+
+ private GL11 mGL;
+
+ public GLCanvasMock(GL11 gl) {
+ mGL = gl;
+ }
+
+ public GLCanvasMock() {
+ mGL = new GLStub();
+ }
+
+ @Override
+ public GL11 getGLInstance() {
+ return mGL;
+ }
+
+ @Override
+ public void fillRect(float x, float y, float width, float height, int color) {
+ mFillRectCalled++;
+ mFillRectWidth = width;
+ mFillRectHeight = height;
+ mFillRectColor = color;
+ }
+
+ @Override
+ public void drawTexture(
+ BasicTexture texture, int x, int y, int width, int height) {
+ mDrawTextureCalled++;
+ }
+
+ @Override
+ public void drawMixed(BasicTexture from, BasicTexture to,
+ float ratio, int x, int y, int w, int h) {
+ mDrawMixedCalled++;
+ mDrawMixedRatio = ratio;
+ }
+}
diff --git a/tests/src/com/android/gallery3d/glrenderer/GLCanvasTest.java b/tests/src/com/android/gallery3d/glrenderer/GLCanvasTest.java
new file mode 100644
index 000000000..416c11414
--- /dev/null
+++ b/tests/src/com/android/gallery3d/glrenderer/GLCanvasTest.java
@@ -0,0 +1,386 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.glrenderer;
+
+import android.test.suitebuilder.annotation.SmallTest;
+import android.util.Log;
+
+import junit.framework.TestCase;
+
+import java.util.Arrays;
+
+import javax.microedition.khronos.opengles.GL10;
+import javax.microedition.khronos.opengles.GL11;
+
+public class GLCanvasTest extends TestCase {
+ private static final String TAG = "GLCanvasTest";
+
+ private static GLPaint newColorPaint(int color) {
+ GLPaint paint = new GLPaint();
+ paint.setColor(color);
+ return paint;
+ }
+
+ @SmallTest
+ public void testSetSize() {
+ GL11 glStub = new GLStub();
+ GLCanvas canvas = new GLES11Canvas(glStub);
+ canvas.setSize(100, 200);
+ canvas.setSize(1000, 100);
+ try {
+ canvas.setSize(-1, 100);
+ fail();
+ } catch (Throwable ex) {
+ // expected.
+ }
+ }
+
+ @SmallTest
+ public void testClearBuffer() {
+ new ClearBufferTest().run();
+ }
+
+ private static class ClearBufferTest extends GLMock {
+ void run() {
+ GLCanvas canvas = new GLES11Canvas(this);
+ assertEquals(0, mGLClearCalled);
+ canvas.clearBuffer();
+ assertEquals(GL10.GL_COLOR_BUFFER_BIT, mGLClearMask);
+ assertEquals(1, mGLClearCalled);
+ }
+ }
+
+ @SmallTest
+ public void testSetColor() {
+ new SetColorTest().run();
+ }
+
+ // This test assumes we use pre-multipled alpha blending and should
+ // set the blending function and color correctly.
+ private static class SetColorTest extends GLMock {
+ void run() {
+ int[] testColors = new int[] {
+ 0, 0xFFFFFFFF, 0xFF000000, 0x00FFFFFF, 0x80FF8001,
+ 0x7F010101, 0xFEFEFDFC, 0x017F8081, 0x027F8081, 0x2ADE4C4D
+ };
+
+ GLCanvas canvas = new GLES11Canvas(this);
+ canvas.setSize(400, 300);
+ // Test one color to make sure blend function is set.
+ assertEquals(0, mGLColorCalled);
+ canvas.drawLine(0, 0, 1, 1, newColorPaint(0x7F804020));
+ assertEquals(1, mGLColorCalled);
+ assertEquals(0x7F402010, mGLColor);
+ assertPremultipliedBlending(this);
+
+ // Test other colors to make sure premultiplication is right
+ for (int c : testColors) {
+ float a = (c >>> 24) / 255f;
+ float r = ((c >> 16) & 0xff) / 255f;
+ float g = ((c >> 8) & 0xff) / 255f;
+ float b = (c & 0xff) / 255f;
+ int pre = makeColor4f(a * r, a * g, a * b, a);
+
+ mGLColorCalled = 0;
+ canvas.drawLine(0, 0, 1, 1, newColorPaint(c));
+ assertEquals(1, mGLColorCalled);
+ assertEquals(pre, mGLColor);
+ }
+ }
+ }
+
+ @SmallTest
+ public void testSetGetMultiplyAlpha() {
+ GL11 glStub = new GLStub();
+ GLCanvas canvas = new GLES11Canvas(glStub);
+
+ canvas.setAlpha(1f);
+ assertEquals(1f, canvas.getAlpha());
+
+ canvas.setAlpha(0f);
+ assertEquals(0f, canvas.getAlpha());
+
+ canvas.setAlpha(0.5f);
+ assertEquals(0.5f, canvas.getAlpha());
+
+ canvas.multiplyAlpha(0.5f);
+ assertEquals(0.25f, canvas.getAlpha());
+
+ canvas.multiplyAlpha(0f);
+ assertEquals(0f, canvas.getAlpha());
+
+ try {
+ canvas.setAlpha(-0.01f);
+ fail();
+ } catch (Throwable ex) {
+ // expected.
+ }
+
+ try {
+ canvas.setAlpha(1.01f);
+ fail();
+ } catch (Throwable ex) {
+ // expected.
+ }
+ }
+
+ @SmallTest
+ public void testAlpha() {
+ new AlphaTest().run();
+ }
+
+ private static class AlphaTest extends GLMock {
+ void run() {
+ GLCanvas canvas = new GLES11Canvas(this);
+ canvas.setSize(400, 300);
+
+ assertEquals(0, mGLColorCalled);
+ canvas.setAlpha(0.48f);
+ canvas.drawLine(0, 0, 1, 1, newColorPaint(0xFF804020));
+ assertPremultipliedBlending(this);
+ assertEquals(1, mGLColorCalled);
+ assertEquals(0x7A3D1F0F, mGLColor);
+ }
+ }
+
+ @SmallTest
+ public void testDrawLine() {
+ new DrawLineTest().run();
+ }
+
+ // This test assumes the drawLine() function use glDrawArrays() with
+ // GL_LINE_STRIP mode to draw the line and the input coordinates are used
+ // directly.
+ private static class DrawLineTest extends GLMock {
+ private int mDrawArrayCalled = 0;
+ private final int[] mResult = new int[4];
+
+ @Override
+ public void glDrawArrays(int mode, int first, int count) {
+ assertNotNull(mGLVertexPointer);
+ assertEquals(GL10.GL_LINE_STRIP, mode);
+ assertEquals(2, count);
+ mGLVertexPointer.bindByteBuffer();
+
+ double[] coord = new double[4];
+ mGLVertexPointer.getArrayElement(first, coord);
+ mResult[0] = (int) coord[0];
+ mResult[1] = (int) coord[1];
+ mGLVertexPointer.getArrayElement(first + 1, coord);
+ mResult[2] = (int) coord[0];
+ mResult[3] = (int) coord[1];
+ mDrawArrayCalled++;
+ }
+
+ void run() {
+ GLCanvas canvas = new GLES11Canvas(this);
+ canvas.setSize(400, 300);
+ canvas.drawLine(2, 7, 1, 8, newColorPaint(0) /* color */);
+ assertTrue(mGLVertexArrayEnabled);
+ assertEquals(1, mDrawArrayCalled);
+
+ Log.v(TAG, "result = " + Arrays.toString(mResult));
+ int[] answer = new int[] {2, 7, 1, 8};
+ for (int i = 0; i < answer.length; i++) {
+ assertEquals(answer[i], mResult[i]);
+ }
+ }
+ }
+
+ @SmallTest
+ public void testFillRect() {
+ new FillRectTest().run();
+ }
+
+ // This test assumes the drawLine() function use glDrawArrays() with
+ // GL_TRIANGLE_STRIP mode to draw the line and the input coordinates
+ // are used directly.
+ private static class FillRectTest extends GLMock {
+ private int mDrawArrayCalled = 0;
+ private final int[] mResult = new int[8];
+
+ @Override
+ public void glDrawArrays(int mode, int first, int count) {
+ assertNotNull(mGLVertexPointer);
+ assertEquals(GL10.GL_TRIANGLE_STRIP, mode);
+ assertEquals(4, count);
+ mGLVertexPointer.bindByteBuffer();
+
+ double[] coord = new double[4];
+ for (int i = 0; i < 4; i++) {
+ mGLVertexPointer.getArrayElement(first + i, coord);
+ mResult[i * 2 + 0] = (int) coord[0];
+ mResult[i * 2 + 1] = (int) coord[1];
+ }
+
+ mDrawArrayCalled++;
+ }
+
+ void run() {
+ GLCanvas canvas = new GLES11Canvas(this);
+ canvas.setSize(400, 300);
+ canvas.fillRect(2, 7, 1, 8, 0 /* color */);
+ assertTrue(mGLVertexArrayEnabled);
+ assertEquals(1, mDrawArrayCalled);
+ Log.v(TAG, "result = " + Arrays.toString(mResult));
+
+ // These are the four vertics that should be used.
+ int[] answer = new int[] {
+ 2, 7,
+ 3, 7,
+ 3, 15,
+ 2, 15};
+ int count[] = new int[4];
+
+ // Count the number of appearances for each vertex.
+ for (int i = 0; i < 4; i++) {
+ for (int j = 0; j < 4; j++) {
+ if (answer[i * 2] == mResult[j * 2] &&
+ answer[i * 2 + 1] == mResult[j * 2 + 1]) {
+ count[i]++;
+ }
+ }
+ }
+
+ // Each vertex should appear exactly once.
+ for (int i = 0; i < 4; i++) {
+ assertEquals(1, count[i]);
+ }
+ }
+ }
+
+ @SmallTest
+ public void testTransform() {
+ new TransformTest().run();
+ }
+
+ // This test assumes glLoadMatrixf is used to load the model view matrix,
+ // and glOrthof is used to load the projection matrix.
+ //
+ // The projection matrix is set to an orthogonal projection which is the
+ // inverse of viewport transform. So the model view matrix maps input
+ // directly to screen coordinates (default no scaling, and the y-axis is
+ // reversed).
+ //
+ // The matrix here are all listed in column major order.
+ //
+ private static class TransformTest extends GLMock {
+ private final float[] mModelViewMatrixUsed = new float[16];
+ private final float[] mProjectionMatrixUsed = new float[16];
+
+ @Override
+ public void glDrawArrays(int mode, int first, int count) {
+ copy(mModelViewMatrixUsed, mGLModelViewMatrix);
+ copy(mProjectionMatrixUsed, mGLProjectionMatrix);
+ }
+
+ private void copy(float[] dest, float[] src) {
+ System.arraycopy(src, 0, dest, 0, 16);
+ }
+
+ void run() {
+ GLCanvas canvas = new GLES11Canvas(this);
+ canvas.setSize(40, 50);
+ int color = 0;
+
+ // Initial matrix
+ canvas.drawLine(0, 0, 1, 1, newColorPaint(color));
+ assertMatrixEq(new float[] {
+ 1, 0, 0, 0,
+ 0, -1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 50, 0, 1
+ }, mModelViewMatrixUsed);
+
+ assertMatrixEq(new float[] {
+ 2f / 40, 0, 0, 0,
+ 0, 2f / 50, 0, 0,
+ 0, 0, -1, 0,
+ -1, -1, 0, 1
+ }, mProjectionMatrixUsed);
+
+ // Translation
+ canvas.translate(3, 4, 5);
+ canvas.drawLine(0, 0, 1, 1, newColorPaint(color));
+ assertMatrixEq(new float[] {
+ 1, 0, 0, 0,
+ 0, -1, 0, 0,
+ 0, 0, 1, 0,
+ 3, 46, 5, 1
+ }, mModelViewMatrixUsed);
+ canvas.save();
+
+ // Scaling
+ canvas.scale(0.7f, 0.6f, 0.5f);
+ canvas.drawLine(0, 0, 1, 1, newColorPaint(color));
+ assertMatrixEq(new float[] {
+ 0.7f, 0, 0, 0,
+ 0, -0.6f, 0, 0,
+ 0, 0, 0.5f, 0,
+ 3, 46, 5, 1
+ }, mModelViewMatrixUsed);
+
+ // Rotation
+ canvas.rotate(90, 0, 0, 1);
+ canvas.drawLine(0, 0, 1, 1, newColorPaint(color));
+ assertMatrixEq(new float[] {
+ 0, -0.6f, 0, 0,
+ -0.7f, 0, 0, 0,
+ 0, 0, 0.5f, 0,
+ 3, 46, 5, 1
+ }, mModelViewMatrixUsed);
+ canvas.restore();
+
+ // After restoring to the point just after translation,
+ // do rotation again.
+ canvas.rotate(180, 1, 0, 0);
+ canvas.drawLine(0, 0, 1, 1, newColorPaint(color));
+ assertMatrixEq(new float[] {
+ 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, -1, 0,
+ 3, 46, 5, 1
+ }, mModelViewMatrixUsed);
+ }
+ }
+
+ private static void assertPremultipliedBlending(GLMock mock) {
+ assertTrue(mock.mGLBlendFuncCalled > 0);
+ assertTrue(mock.mGLBlendEnabled);
+ assertEquals(GL11.GL_ONE, mock.mGLBlendFuncSFactor);
+ assertEquals(GL11.GL_ONE_MINUS_SRC_ALPHA, mock.mGLBlendFuncDFactor);
+ }
+
+ private static void assertMatrixEq(float[] expected, float[] actual) {
+ try {
+ for (int i = 0; i < 16; i++) {
+ assertFloatEq(expected[i], actual[i]);
+ }
+ } catch (Throwable t) {
+ Log.v(TAG, "expected = " + Arrays.toString(expected) +
+ ", actual = " + Arrays.toString(actual));
+ fail();
+ }
+ }
+
+ public static void assertFloatEq(float expected, float actual) {
+ if (Math.abs(actual - expected) > 1e-6) {
+ Log.v(TAG, "expected: " + expected + ", actual: " + actual);
+ fail();
+ }
+ }
+}
diff --git a/tests/src/com/android/gallery3d/glrenderer/GLMock.java b/tests/src/com/android/gallery3d/glrenderer/GLMock.java
new file mode 100644
index 000000000..b242217a2
--- /dev/null
+++ b/tests/src/com/android/gallery3d/glrenderer/GLMock.java
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.glrenderer;
+
+import com.android.gallery3d.ui.PointerInfo;
+
+import java.nio.Buffer;
+import java.util.HashMap;
+import javax.microedition.khronos.opengles.GL10;
+import javax.microedition.khronos.opengles.GL11;
+
+public class GLMock extends GLStub {
+ @SuppressWarnings("unused")
+ private static final String TAG = "GLMock";
+
+ // glClear
+ int mGLClearCalled;
+ int mGLClearMask;
+ // glBlendFunc
+ int mGLBlendFuncCalled;
+ int mGLBlendFuncSFactor;
+ int mGLBlendFuncDFactor;
+ // glColor4[fx]
+ int mGLColorCalled;
+ int mGLColor;
+ // glEnable, glDisable
+ boolean mGLBlendEnabled;
+ boolean mGLStencilEnabled;
+ // glEnableClientState
+ boolean mGLVertexArrayEnabled;
+ // glVertexPointer
+ PointerInfo mGLVertexPointer;
+ // glMatrixMode
+ int mGLMatrixMode = GL10.GL_MODELVIEW;
+ // glLoadMatrixf
+ float[] mGLModelViewMatrix = new float[16];
+ float[] mGLProjectionMatrix = new float[16];
+ // glBindTexture
+ int mGLBindTextureId;
+ // glTexEnvf
+ HashMap<Integer, Float> mGLTexEnv0 = new HashMap<Integer, Float>();
+ HashMap<Integer, Float> mGLTexEnv1 = new HashMap<Integer, Float>();
+ // glActiveTexture
+ int mGLActiveTexture = GL11.GL_TEXTURE0;
+
+ @Override
+ public void glClear(int mask) {
+ mGLClearCalled++;
+ mGLClearMask = mask;
+ }
+
+ @Override
+ public void glBlendFunc(int sfactor, int dfactor) {
+ mGLBlendFuncSFactor = sfactor;
+ mGLBlendFuncDFactor = dfactor;
+ mGLBlendFuncCalled++;
+ }
+
+ @Override
+ public void glColor4f(float red, float green, float blue,
+ float alpha) {
+ mGLColorCalled++;
+ mGLColor = makeColor4f(red, green, blue, alpha);
+ }
+
+ @Override
+ public void glColor4x(int red, int green, int blue, int alpha) {
+ mGLColorCalled++;
+ mGLColor = makeColor4x(red, green, blue, alpha);
+ }
+
+ @Override
+ public void glEnable(int cap) {
+ if (cap == GL11.GL_BLEND) {
+ mGLBlendEnabled = true;
+ } else if (cap == GL11.GL_STENCIL_TEST) {
+ mGLStencilEnabled = true;
+ }
+ }
+
+ @Override
+ public void glDisable(int cap) {
+ if (cap == GL11.GL_BLEND) {
+ mGLBlendEnabled = false;
+ } else if (cap == GL11.GL_STENCIL_TEST) {
+ mGLStencilEnabled = false;
+ }
+ }
+
+ @Override
+ public void glEnableClientState(int array) {
+ if (array == GL10.GL_VERTEX_ARRAY) {
+ mGLVertexArrayEnabled = true;
+ }
+ }
+
+ @Override
+ public void glVertexPointer(int size, int type, int stride, Buffer pointer) {
+ mGLVertexPointer = new PointerInfo(size, type, stride, pointer);
+ }
+
+ @Override
+ public void glMatrixMode(int mode) {
+ mGLMatrixMode = mode;
+ }
+
+ @Override
+ public void glLoadMatrixf(float[] m, int offset) {
+ if (mGLMatrixMode == GL10.GL_MODELVIEW) {
+ System.arraycopy(m, offset, mGLModelViewMatrix, 0, 16);
+ } else if (mGLMatrixMode == GL10.GL_PROJECTION) {
+ System.arraycopy(m, offset, mGLProjectionMatrix, 0, 16);
+ }
+ }
+
+ @Override
+ public void glOrthof(
+ float left, float right, float bottom, float top,
+ float zNear, float zFar) {
+ float tx = -(right + left) / (right - left);
+ float ty = -(top + bottom) / (top - bottom);
+ float tz = - (zFar + zNear) / (zFar - zNear);
+ float[] m = new float[] {
+ 2 / (right - left), 0, 0, 0,
+ 0, 2 / (top - bottom), 0, 0,
+ 0, 0, -2 / (zFar - zNear), 0,
+ tx, ty, tz, 1
+ };
+ glLoadMatrixf(m, 0);
+ }
+
+ @Override
+ public void glBindTexture(int target, int texture) {
+ if (target == GL11.GL_TEXTURE_2D) {
+ mGLBindTextureId = texture;
+ }
+ }
+
+ @Override
+ public void glTexEnvf(int target, int pname, float param) {
+ if (target == GL11.GL_TEXTURE_ENV) {
+ if (mGLActiveTexture == GL11.GL_TEXTURE0) {
+ mGLTexEnv0.put(pname, param);
+ } else if (mGLActiveTexture == GL11.GL_TEXTURE1) {
+ mGLTexEnv1.put(pname, param);
+ } else {
+ throw new AssertionError();
+ }
+ }
+ }
+
+ public int getTexEnvi(int pname) {
+ return getTexEnvi(mGLActiveTexture, pname);
+ }
+
+ public int getTexEnvi(int activeTexture, int pname) {
+ if (activeTexture == GL11.GL_TEXTURE0) {
+ return (int) mGLTexEnv0.get(pname).floatValue();
+ } else if (activeTexture == GL11.GL_TEXTURE1) {
+ return (int) mGLTexEnv1.get(pname).floatValue();
+ } else {
+ throw new AssertionError();
+ }
+ }
+
+ @Override
+ public void glActiveTexture(int texture) {
+ mGLActiveTexture = texture;
+ }
+
+ public static int makeColor4f(float red, float green, float blue,
+ float alpha) {
+ return (Math.round(alpha * 255) << 24) |
+ (Math.round(red * 255) << 16) |
+ (Math.round(green * 255) << 8) |
+ Math.round(blue * 255);
+ }
+
+ public static int makeColor4x(int red, int green, int blue, int alpha) {
+ final float X = 65536f;
+ return makeColor4f(red / X, green / X, blue / X, alpha / X);
+ }
+}
diff --git a/tests/src/com/android/gallery3d/glrenderer/GLStub.java b/tests/src/com/android/gallery3d/glrenderer/GLStub.java
new file mode 100644
index 000000000..4b66040dd
--- /dev/null
+++ b/tests/src/com/android/gallery3d/glrenderer/GLStub.java
@@ -0,0 +1,1490 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.glrenderer;
+
+import javax.microedition.khronos.opengles.GL;
+import javax.microedition.khronos.opengles.GL10;
+import javax.microedition.khronos.opengles.GL10Ext;
+import javax.microedition.khronos.opengles.GL11;
+import javax.microedition.khronos.opengles.GL11Ext;
+
+public class GLStub implements GL, GL10, GL10Ext, GL11, GL11Ext {
+ @SuppressWarnings("unused")
+ private static final String TAG = "GLStub";
+
+ public void glActiveTexture(
+ int texture
+ ){}
+
+ public void glAlphaFunc(
+ int func,
+ float ref
+ ){}
+
+ public void glAlphaFuncx(
+ int func,
+ int ref
+ ){}
+
+ public void glBindTexture(
+ int target,
+ int texture
+ ){}
+
+ public void glBlendFunc(
+ int sfactor,
+ int dfactor
+ ){}
+
+ public void glClear(
+ int mask
+ ){}
+
+ public void glClearColor(
+ float red,
+ float green,
+ float blue,
+ float alpha
+ ){}
+
+ public void glClearColorx(
+ int red,
+ int green,
+ int blue,
+ int alpha
+ ){}
+
+ public void glClearDepthf(
+ float depth
+ ){}
+
+ public void glClearDepthx(
+ int depth
+ ){}
+
+ public void glClearStencil(
+ int s
+ ){}
+
+ public void glClientActiveTexture(
+ int texture
+ ){}
+
+ public void glColor4f(
+ float red,
+ float green,
+ float blue,
+ float alpha
+ ){}
+
+ public void glColor4x(
+ int red,
+ int green,
+ int blue,
+ int alpha
+ ){}
+
+ public void glColorMask(
+ boolean red,
+ boolean green,
+ boolean blue,
+ boolean alpha
+ ){}
+
+ public void glColorPointer(
+ int size,
+ int type,
+ int stride,
+ java.nio.Buffer pointer
+ ){}
+
+ public void glCompressedTexImage2D(
+ int target,
+ int level,
+ int internalformat,
+ int width,
+ int height,
+ int border,
+ int imageSize,
+ java.nio.Buffer data
+ ){}
+
+ public void glCompressedTexSubImage2D(
+ int target,
+ int level,
+ int xoffset,
+ int yoffset,
+ int width,
+ int height,
+ int format,
+ int imageSize,
+ java.nio.Buffer data
+ ){}
+
+ public void glCopyTexImage2D(
+ int target,
+ int level,
+ int internalformat,
+ int x,
+ int y,
+ int width,
+ int height,
+ int border
+ ){}
+
+ public void glCopyTexSubImage2D(
+ int target,
+ int level,
+ int xoffset,
+ int yoffset,
+ int x,
+ int y,
+ int width,
+ int height
+ ){}
+
+ public void glCullFace(
+ int mode
+ ){}
+
+ public void glDeleteTextures(
+ int n,
+ int[] textures,
+ int offset
+ ){}
+
+ public void glDeleteTextures(
+ int n,
+ java.nio.IntBuffer textures
+ ){}
+
+ public void glDepthFunc(
+ int func
+ ){}
+
+ public void glDepthMask(
+ boolean flag
+ ){}
+
+ public void glDepthRangef(
+ float zNear,
+ float zFar
+ ){}
+
+ public void glDepthRangex(
+ int zNear,
+ int zFar
+ ){}
+
+ public void glDisable(
+ int cap
+ ){}
+
+ public void glDisableClientState(
+ int array
+ ){}
+
+ public void glDrawArrays(
+ int mode,
+ int first,
+ int count
+ ){}
+
+ public void glDrawElements(
+ int mode,
+ int count,
+ int type,
+ java.nio.Buffer indices
+ ){}
+
+ public void glEnable(
+ int cap
+ ){}
+
+ public void glEnableClientState(
+ int array
+ ){}
+
+ public void glFinish(
+ ){}
+
+ public void glFlush(
+ ){}
+
+ public void glFogf(
+ int pname,
+ float param
+ ){}
+
+ public void glFogfv(
+ int pname,
+ float[] params,
+ int offset
+ ){}
+
+ public void glFogfv(
+ int pname,
+ java.nio.FloatBuffer params
+ ){}
+
+ public void glFogx(
+ int pname,
+ int param
+ ){}
+
+ public void glFogxv(
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glFogxv(
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glFrontFace(
+ int mode
+ ){}
+
+ public void glFrustumf(
+ float left,
+ float right,
+ float bottom,
+ float top,
+ float zNear,
+ float zFar
+ ){}
+
+ public void glFrustumx(
+ int left,
+ int right,
+ int bottom,
+ int top,
+ int zNear,
+ int zFar
+ ){}
+
+ public void glGenTextures(
+ int n,
+ int[] textures,
+ int offset
+ ){}
+
+ public void glGenTextures(
+ int n,
+ java.nio.IntBuffer textures
+ ){}
+
+ public int glGetError(
+ ){ throw new UnsupportedOperationException(); }
+
+ public void glGetIntegerv(
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glGetIntegerv(
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public String glGetString(
+ int name
+ ){ throw new UnsupportedOperationException(); }
+
+ public void glHint(
+ int target,
+ int mode
+ ){}
+
+ public void glLightModelf(
+ int pname,
+ float param
+ ){}
+
+ public void glLightModelfv(
+ int pname,
+ float[] params,
+ int offset
+ ){}
+
+ public void glLightModelfv(
+ int pname,
+ java.nio.FloatBuffer params
+ ){}
+
+ public void glLightModelx(
+ int pname,
+ int param
+ ){}
+
+ public void glLightModelxv(
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glLightModelxv(
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glLightf(
+ int light,
+ int pname,
+ float param
+ ){}
+
+ public void glLightfv(
+ int light,
+ int pname,
+ float[] params,
+ int offset
+ ){}
+
+ public void glLightfv(
+ int light,
+ int pname,
+ java.nio.FloatBuffer params
+ ){}
+
+ public void glLightx(
+ int light,
+ int pname,
+ int param
+ ){}
+
+ public void glLightxv(
+ int light,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glLightxv(
+ int light,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glLineWidth(
+ float width
+ ){}
+
+ public void glLineWidthx(
+ int width
+ ){}
+
+ public void glLoadIdentity(
+ ){}
+
+ public void glLoadMatrixf(
+ float[] m,
+ int offset
+ ){}
+
+ public void glLoadMatrixf(
+ java.nio.FloatBuffer m
+ ){}
+
+ public void glLoadMatrixx(
+ int[] m,
+ int offset
+ ){}
+
+ public void glLoadMatrixx(
+ java.nio.IntBuffer m
+ ){}
+
+ public void glLogicOp(
+ int opcode
+ ){}
+
+ public void glMaterialf(
+ int face,
+ int pname,
+ float param
+ ){}
+
+ public void glMaterialfv(
+ int face,
+ int pname,
+ float[] params,
+ int offset
+ ){}
+
+ public void glMaterialfv(
+ int face,
+ int pname,
+ java.nio.FloatBuffer params
+ ){}
+
+ public void glMaterialx(
+ int face,
+ int pname,
+ int param
+ ){}
+
+ public void glMaterialxv(
+ int face,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glMaterialxv(
+ int face,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glMatrixMode(
+ int mode
+ ){}
+
+ public void glMultMatrixf(
+ float[] m,
+ int offset
+ ){}
+
+ public void glMultMatrixf(
+ java.nio.FloatBuffer m
+ ){}
+
+ public void glMultMatrixx(
+ int[] m,
+ int offset
+ ){}
+
+ public void glMultMatrixx(
+ java.nio.IntBuffer m
+ ){}
+
+ public void glMultiTexCoord4f(
+ int target,
+ float s,
+ float t,
+ float r,
+ float q
+ ){}
+
+ public void glMultiTexCoord4x(
+ int target,
+ int s,
+ int t,
+ int r,
+ int q
+ ){}
+
+ public void glNormal3f(
+ float nx,
+ float ny,
+ float nz
+ ){}
+
+ public void glNormal3x(
+ int nx,
+ int ny,
+ int nz
+ ){}
+
+ public void glNormalPointer(
+ int type,
+ int stride,
+ java.nio.Buffer pointer
+ ){}
+
+ public void glOrthof(
+ float left,
+ float right,
+ float bottom,
+ float top,
+ float zNear,
+ float zFar
+ ){}
+
+ public void glOrthox(
+ int left,
+ int right,
+ int bottom,
+ int top,
+ int zNear,
+ int zFar
+ ){}
+
+ public void glPixelStorei(
+ int pname,
+ int param
+ ){}
+
+ public void glPointSize(
+ float size
+ ){}
+
+ public void glPointSizex(
+ int size
+ ){}
+
+ public void glPolygonOffset(
+ float factor,
+ float units
+ ){}
+
+ public void glPolygonOffsetx(
+ int factor,
+ int units
+ ){}
+
+ public void glPopMatrix(
+ ){}
+
+ public void glPushMatrix(
+ ){}
+
+ public void glReadPixels(
+ int x,
+ int y,
+ int width,
+ int height,
+ int format,
+ int type,
+ java.nio.Buffer pixels
+ ){}
+
+ public void glRotatef(
+ float angle,
+ float x,
+ float y,
+ float z
+ ){}
+
+ public void glRotatex(
+ int angle,
+ int x,
+ int y,
+ int z
+ ){}
+
+ public void glSampleCoverage(
+ float value,
+ boolean invert
+ ){}
+
+ public void glSampleCoveragex(
+ int value,
+ boolean invert
+ ){}
+
+ public void glScalef(
+ float x,
+ float y,
+ float z
+ ){}
+
+ public void glScalex(
+ int x,
+ int y,
+ int z
+ ){}
+
+ public void glScissor(
+ int x,
+ int y,
+ int width,
+ int height
+ ){}
+
+ public void glShadeModel(
+ int mode
+ ){}
+
+ public void glStencilFunc(
+ int func,
+ int ref,
+ int mask
+ ){}
+
+ public void glStencilMask(
+ int mask
+ ){}
+
+ public void glStencilOp(
+ int fail,
+ int zfail,
+ int zpass
+ ){}
+
+ public void glTexCoordPointer(
+ int size,
+ int type,
+ int stride,
+ java.nio.Buffer pointer
+ ){}
+
+ public void glTexEnvf(
+ int target,
+ int pname,
+ float param
+ ){}
+
+ public void glTexEnvfv(
+ int target,
+ int pname,
+ float[] params,
+ int offset
+ ){}
+
+ public void glTexEnvfv(
+ int target,
+ int pname,
+ java.nio.FloatBuffer params
+ ){}
+
+ public void glTexEnvx(
+ int target,
+ int pname,
+ int param
+ ){}
+
+ public void glTexEnvxv(
+ int target,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glTexEnvxv(
+ int target,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glTexImage2D(
+ int target,
+ int level,
+ int internalformat,
+ int width,
+ int height,
+ int border,
+ int format,
+ int type,
+ java.nio.Buffer pixels
+ ){}
+
+ public void glTexParameterf(
+ int target,
+ int pname,
+ float param
+ ){}
+
+ public void glTexParameterx(
+ int target,
+ int pname,
+ int param
+ ){}
+
+ public void glTexSubImage2D(
+ int target,
+ int level,
+ int xoffset,
+ int yoffset,
+ int width,
+ int height,
+ int format,
+ int type,
+ java.nio.Buffer pixels
+ ){}
+
+ public void glTranslatef(
+ float x,
+ float y,
+ float z
+ ){}
+
+ public void glTranslatex(
+ int x,
+ int y,
+ int z
+ ){}
+
+ public void glVertexPointer(
+ int size,
+ int type,
+ int stride,
+ java.nio.Buffer pointer
+ ){}
+
+ public void glViewport(
+ int x,
+ int y,
+ int width,
+ int height
+ ){}
+
+ public int glQueryMatrixxOES(
+ int[] mantissa,
+ int mantissaOffset,
+ int[] exponent,
+ int exponentOffset
+ ){ throw new UnsupportedOperationException(); }
+
+ public int glQueryMatrixxOES(
+ java.nio.IntBuffer mantissa,
+ java.nio.IntBuffer exponent
+ ){ throw new UnsupportedOperationException(); }
+
+ public void glGetPointerv(int pname, java.nio.Buffer[] params){}
+ public void glBindBuffer(
+ int target,
+ int buffer
+ ){}
+
+ public void glBufferData(
+ int target,
+ int size,
+ java.nio.Buffer data,
+ int usage
+ ){}
+
+ public void glBufferSubData(
+ int target,
+ int offset,
+ int size,
+ java.nio.Buffer data
+ ){}
+
+ public void glClipPlanef(
+ int plane,
+ float[] equation,
+ int offset
+ ){}
+
+ public void glClipPlanef(
+ int plane,
+ java.nio.FloatBuffer equation
+ ){}
+
+ public void glClipPlanex(
+ int plane,
+ int[] equation,
+ int offset
+ ){}
+
+ public void glClipPlanex(
+ int plane,
+ java.nio.IntBuffer equation
+ ){}
+
+ public void glColor4ub(
+ byte red,
+ byte green,
+ byte blue,
+ byte alpha
+ ){}
+
+ public void glColorPointer(
+ int size,
+ int type,
+ int stride,
+ int offset
+ ){}
+
+ public void glDeleteBuffers(
+ int n,
+ int[] buffers,
+ int offset
+ ){}
+
+ public void glDeleteBuffers(
+ int n,
+ java.nio.IntBuffer buffers
+ ){}
+
+ public void glDrawElements(
+ int mode,
+ int count,
+ int type,
+ int offset
+ ){}
+
+ public void glGenBuffers(
+ int n,
+ int[] buffers,
+ int offset
+ ){}
+
+ public void glGenBuffers(
+ int n,
+ java.nio.IntBuffer buffers
+ ){}
+
+ public void glGetBooleanv(
+ int pname,
+ boolean[] params,
+ int offset
+ ){}
+
+ public void glGetBooleanv(
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glGetBufferParameteriv(
+ int target,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glGetBufferParameteriv(
+ int target,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glGetClipPlanef(
+ int pname,
+ float[] eqn,
+ int offset
+ ){}
+
+ public void glGetClipPlanef(
+ int pname,
+ java.nio.FloatBuffer eqn
+ ){}
+
+ public void glGetClipPlanex(
+ int pname,
+ int[] eqn,
+ int offset
+ ){}
+
+ public void glGetClipPlanex(
+ int pname,
+ java.nio.IntBuffer eqn
+ ){}
+
+ public void glGetFixedv(
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glGetFixedv(
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glGetFloatv(
+ int pname,
+ float[] params,
+ int offset
+ ){}
+
+ public void glGetFloatv(
+ int pname,
+ java.nio.FloatBuffer params
+ ){}
+
+ public void glGetLightfv(
+ int light,
+ int pname,
+ float[] params,
+ int offset
+ ){}
+
+ public void glGetLightfv(
+ int light,
+ int pname,
+ java.nio.FloatBuffer params
+ ){}
+
+ public void glGetLightxv(
+ int light,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glGetLightxv(
+ int light,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glGetMaterialfv(
+ int face,
+ int pname,
+ float[] params,
+ int offset
+ ){}
+
+ public void glGetMaterialfv(
+ int face,
+ int pname,
+ java.nio.FloatBuffer params
+ ){}
+
+ public void glGetMaterialxv(
+ int face,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glGetMaterialxv(
+ int face,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glGetTexEnviv(
+ int env,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glGetTexEnviv(
+ int env,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glGetTexEnvxv(
+ int env,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glGetTexEnvxv(
+ int env,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glGetTexParameterfv(
+ int target,
+ int pname,
+ float[] params,
+ int offset
+ ){}
+
+ public void glGetTexParameterfv(
+ int target,
+ int pname,
+ java.nio.FloatBuffer params
+ ){}
+
+ public void glGetTexParameteriv(
+ int target,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glGetTexParameteriv(
+ int target,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glGetTexParameterxv(
+ int target,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glGetTexParameterxv(
+ int target,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public boolean glIsBuffer(
+ int buffer
+ ){ throw new UnsupportedOperationException(); }
+
+ public boolean glIsEnabled(
+ int cap
+ ){ throw new UnsupportedOperationException(); }
+
+ public boolean glIsTexture(
+ int texture
+ ){ throw new UnsupportedOperationException(); }
+
+ public void glNormalPointer(
+ int type,
+ int stride,
+ int offset
+ ){}
+
+ public void glPointParameterf(
+ int pname,
+ float param
+ ){}
+
+ public void glPointParameterfv(
+ int pname,
+ float[] params,
+ int offset
+ ){}
+
+ public void glPointParameterfv(
+ int pname,
+ java.nio.FloatBuffer params
+ ){}
+
+ public void glPointParameterx(
+ int pname,
+ int param
+ ){}
+
+ public void glPointParameterxv(
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glPointParameterxv(
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glPointSizePointerOES(
+ int type,
+ int stride,
+ java.nio.Buffer pointer
+ ){}
+
+ public void glTexCoordPointer(
+ int size,
+ int type,
+ int stride,
+ int offset
+ ){}
+
+ public void glTexEnvi(
+ int target,
+ int pname,
+ int param
+ ){}
+
+ public void glTexEnviv(
+ int target,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glTexEnviv(
+ int target,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glTexParameterfv(
+ int target,
+ int pname,
+ float[] params,
+ int offset
+ ){}
+
+ public void glTexParameterfv(
+ int target,
+ int pname,
+ java.nio.FloatBuffer params
+ ){}
+
+ public void glTexParameteri(
+ int target,
+ int pname,
+ int param
+ ){}
+
+ public void glTexParameteriv(
+ int target,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glTexParameteriv(
+ int target,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glTexParameterxv(
+ int target,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glTexParameterxv(
+ int target,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glVertexPointer(
+ int size,
+ int type,
+ int stride,
+ int offset
+ ){}
+
+ public void glCurrentPaletteMatrixOES(
+ int matrixpaletteindex
+ ){}
+
+ public void glDrawTexfOES(
+ float x,
+ float y,
+ float z,
+ float width,
+ float height
+ ){}
+
+ public void glDrawTexfvOES(
+ float[] coords,
+ int offset
+ ){}
+
+ public void glDrawTexfvOES(
+ java.nio.FloatBuffer coords
+ ){}
+
+ public void glDrawTexiOES(
+ int x,
+ int y,
+ int z,
+ int width,
+ int height
+ ){}
+
+ public void glDrawTexivOES(
+ int[] coords,
+ int offset
+ ){}
+
+ public void glDrawTexivOES(
+ java.nio.IntBuffer coords
+ ){}
+
+ public void glDrawTexsOES(
+ short x,
+ short y,
+ short z,
+ short width,
+ short height
+ ){}
+
+ public void glDrawTexsvOES(
+ short[] coords,
+ int offset
+ ){}
+
+ public void glDrawTexsvOES(
+ java.nio.ShortBuffer coords
+ ){}
+
+ public void glDrawTexxOES(
+ int x,
+ int y,
+ int z,
+ int width,
+ int height
+ ){}
+
+ public void glDrawTexxvOES(
+ int[] coords,
+ int offset
+ ){}
+
+ public void glDrawTexxvOES(
+ java.nio.IntBuffer coords
+ ){}
+
+ public void glLoadPaletteFromModelViewMatrixOES(
+ ){}
+
+ public void glMatrixIndexPointerOES(
+ int size,
+ int type,
+ int stride,
+ java.nio.Buffer pointer
+ ){}
+
+ public void glMatrixIndexPointerOES(
+ int size,
+ int type,
+ int stride,
+ int offset
+ ){}
+
+ public void glWeightPointerOES(
+ int size,
+ int type,
+ int stride,
+ java.nio.Buffer pointer
+ ){}
+
+ public void glWeightPointerOES(
+ int size,
+ int type,
+ int stride,
+ int offset
+ ){}
+
+ public void glBindFramebufferOES(
+ int target,
+ int framebuffer
+ ){}
+
+ public void glBindRenderbufferOES(
+ int target,
+ int renderbuffer
+ ){}
+
+ public void glBlendEquation(
+ int mode
+ ){}
+
+ public void glBlendEquationSeparate(
+ int modeRGB,
+ int modeAlpha
+ ){}
+
+ public void glBlendFuncSeparate(
+ int srcRGB,
+ int dstRGB,
+ int srcAlpha,
+ int dstAlpha
+ ){}
+
+ public int glCheckFramebufferStatusOES(
+ int target
+ ){ throw new UnsupportedOperationException(); }
+
+ public void glDeleteFramebuffersOES(
+ int n,
+ int[] framebuffers,
+ int offset
+ ){}
+
+ public void glDeleteFramebuffersOES(
+ int n,
+ java.nio.IntBuffer framebuffers
+ ){}
+
+ public void glDeleteRenderbuffersOES(
+ int n,
+ int[] renderbuffers,
+ int offset
+ ){}
+
+ public void glDeleteRenderbuffersOES(
+ int n,
+ java.nio.IntBuffer renderbuffers
+ ){}
+
+ public void glFramebufferRenderbufferOES(
+ int target,
+ int attachment,
+ int renderbuffertarget,
+ int renderbuffer
+ ){}
+
+ public void glFramebufferTexture2DOES(
+ int target,
+ int attachment,
+ int textarget,
+ int texture,
+ int level
+ ){}
+
+ public void glGenerateMipmapOES(
+ int target
+ ){}
+
+ public void glGenFramebuffersOES(
+ int n,
+ int[] framebuffers,
+ int offset
+ ){}
+
+ public void glGenFramebuffersOES(
+ int n,
+ java.nio.IntBuffer framebuffers
+ ){}
+
+ public void glGenRenderbuffersOES(
+ int n,
+ int[] renderbuffers,
+ int offset
+ ){}
+
+ public void glGenRenderbuffersOES(
+ int n,
+ java.nio.IntBuffer renderbuffers
+ ){}
+
+ public void glGetFramebufferAttachmentParameterivOES(
+ int target,
+ int attachment,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glGetFramebufferAttachmentParameterivOES(
+ int target,
+ int attachment,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glGetRenderbufferParameterivOES(
+ int target,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glGetRenderbufferParameterivOES(
+ int target,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glGetTexGenfv(
+ int coord,
+ int pname,
+ float[] params,
+ int offset
+ ){}
+
+ public void glGetTexGenfv(
+ int coord,
+ int pname,
+ java.nio.FloatBuffer params
+ ){}
+
+ public void glGetTexGeniv(
+ int coord,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glGetTexGeniv(
+ int coord,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glGetTexGenxv(
+ int coord,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glGetTexGenxv(
+ int coord,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public boolean glIsFramebufferOES(
+ int framebuffer
+ ){ throw new UnsupportedOperationException(); }
+
+ public boolean glIsRenderbufferOES(
+ int renderbuffer
+ ){ throw new UnsupportedOperationException(); }
+
+ public void glRenderbufferStorageOES(
+ int target,
+ int internalformat,
+ int width,
+ int height
+ ){}
+
+ public void glTexGenf(
+ int coord,
+ int pname,
+ float param
+ ){}
+
+ public void glTexGenfv(
+ int coord,
+ int pname,
+ float[] params,
+ int offset
+ ){}
+
+ public void glTexGenfv(
+ int coord,
+ int pname,
+ java.nio.FloatBuffer params
+ ){}
+
+ public void glTexGeni(
+ int coord,
+ int pname,
+ int param
+ ){}
+
+ public void glTexGeniv(
+ int coord,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glTexGeniv(
+ int coord,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+
+ public void glTexGenx(
+ int coord,
+ int pname,
+ int param
+ ){}
+
+ public void glTexGenxv(
+ int coord,
+ int pname,
+ int[] params,
+ int offset
+ ){}
+
+ public void glTexGenxv(
+ int coord,
+ int pname,
+ java.nio.IntBuffer params
+ ){}
+}
diff --git a/tests/src/com/android/gallery3d/glrenderer/TextureTest.java b/tests/src/com/android/gallery3d/glrenderer/TextureTest.java
new file mode 100644
index 000000000..9e7955418
--- /dev/null
+++ b/tests/src/com/android/gallery3d/glrenderer/TextureTest.java
@@ -0,0 +1,208 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.glrenderer;
+
+import android.graphics.Bitmap;
+import android.graphics.Bitmap.Config;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import com.android.gallery3d.glrenderer.BasicTexture;
+import com.android.gallery3d.glrenderer.BitmapTexture;
+import com.android.gallery3d.glrenderer.ColorTexture;
+import com.android.gallery3d.glrenderer.GLCanvas;
+import com.android.gallery3d.glrenderer.GLES11Canvas;
+import com.android.gallery3d.glrenderer.UploadedTexture;
+
+import junit.framework.TestCase;
+
+import javax.microedition.khronos.opengles.GL11;
+
+public class TextureTest extends TestCase {
+ @SuppressWarnings("unused")
+ private static final String TAG = "TextureTest";
+
+ class MyBasicTexture extends BasicTexture {
+ int mOnBindCalled;
+ int mOpaqueCalled;
+
+ MyBasicTexture(GLCanvas canvas, int id) {
+ super(canvas, id, 0);
+ }
+
+ @Override
+ protected boolean onBind(GLCanvas canvas) {
+ mOnBindCalled++;
+ return true;
+ }
+
+ @Override
+ protected int getTarget() {
+ return GL11.GL_TEXTURE_2D;
+ }
+
+ @Override
+ public boolean isOpaque() {
+ mOpaqueCalled++;
+ return true;
+ }
+
+ void upload() {
+ mState = STATE_LOADED;
+ }
+ }
+
+ @SmallTest
+ public void testBasicTexture() {
+ GL11 glStub = new GLStub();
+ GLCanvas canvas = new GLES11Canvas(glStub);
+ MyBasicTexture texture = new MyBasicTexture(canvas, 47);
+
+ assertEquals(47, texture.getId());
+ texture.setSize(1, 1);
+ assertEquals(1, texture.getWidth());
+ assertEquals(1, texture.getHeight());
+ assertEquals(1, texture.getTextureWidth());
+ assertEquals(1, texture.getTextureHeight());
+ texture.setSize(3, 5);
+ assertEquals(3, texture.getWidth());
+ assertEquals(5, texture.getHeight());
+ assertEquals(4, texture.getTextureWidth());
+ assertEquals(8, texture.getTextureHeight());
+
+ assertFalse(texture.isLoaded());
+ texture.upload();
+ assertTrue(texture.isLoaded());
+
+ // For a different GL, it's not loaded.
+ GLCanvas canvas2 = new GLES11Canvas(glStub);
+ assertFalse(texture.isLoaded());
+
+ assertEquals(0, texture.mOnBindCalled);
+ assertEquals(0, texture.mOpaqueCalled);
+ texture.draw(canvas, 100, 200, 1, 1);
+ assertEquals(1, texture.mOnBindCalled);
+ assertEquals(1, texture.mOpaqueCalled);
+ texture.draw(canvas, 0, 0);
+ assertEquals(2, texture.mOnBindCalled);
+ assertEquals(2, texture.mOpaqueCalled);
+ }
+
+ @SmallTest
+ public void testColorTexture() {
+ GLCanvasMock canvas = new GLCanvasMock();
+ ColorTexture texture = new ColorTexture(0x12345678);
+
+ texture.setSize(42, 47);
+ assertEquals(texture.getWidth(), 42);
+ assertEquals(texture.getHeight(), 47);
+ assertEquals(0, canvas.mFillRectCalled);
+ texture.draw(canvas, 0, 0);
+ assertEquals(1, canvas.mFillRectCalled);
+ assertEquals(0x12345678, canvas.mFillRectColor);
+ assertEquals(42f, canvas.mFillRectWidth);
+ assertEquals(47f, canvas.mFillRectHeight);
+ assertFalse(texture.isOpaque());
+ assertTrue(new ColorTexture(0xFF000000).isOpaque());
+ }
+
+ private class MyUploadedTexture extends UploadedTexture {
+ int mGetCalled;
+ int mFreeCalled;
+ Bitmap mBitmap;
+ @Override
+ protected Bitmap onGetBitmap() {
+ mGetCalled++;
+ Config config = Config.ARGB_8888;
+ mBitmap = Bitmap.createBitmap(47, 42, config);
+ return mBitmap;
+ }
+ @Override
+ protected void onFreeBitmap(Bitmap bitmap) {
+ mFreeCalled++;
+ assertSame(mBitmap, bitmap);
+ mBitmap.recycle();
+ mBitmap = null;
+ }
+ }
+
+ @SmallTest
+ public void testUploadedTexture() {
+ GL11 glStub = new GLStub();
+ GLCanvas canvas = new GLES11Canvas(glStub);
+ MyUploadedTexture texture = new MyUploadedTexture();
+
+ // draw it and the bitmap should be fetched.
+ assertEquals(0, texture.mFreeCalled);
+ assertEquals(0, texture.mGetCalled);
+ texture.draw(canvas, 0, 0);
+ assertEquals(1, texture.mGetCalled);
+ assertTrue(texture.isLoaded());
+ assertTrue(texture.isContentValid());
+
+ // invalidate content and it should be freed.
+ texture.invalidateContent();
+ assertFalse(texture.isContentValid());
+ assertEquals(1, texture.mFreeCalled);
+ assertTrue(texture.isLoaded()); // But it's still loaded
+
+ // draw it again and the bitmap should be fetched again.
+ texture.draw(canvas, 0, 0);
+ assertEquals(2, texture.mGetCalled);
+ assertTrue(texture.isLoaded());
+ assertTrue(texture.isContentValid());
+
+ // recycle the texture and it should be freed again.
+ texture.recycle();
+ assertEquals(2, texture.mFreeCalled);
+ // TODO: these two are broken and waiting for fix.
+ //assertFalse(texture.isLoaded(canvas));
+ //assertFalse(texture.isContentValid(canvas));
+ }
+
+ class MyTextureForMixed extends BasicTexture {
+ MyTextureForMixed(GLCanvas canvas, int id) {
+ super(canvas, id, 0);
+ }
+
+ @Override
+ protected boolean onBind(GLCanvas canvas) {
+ return true;
+ }
+
+ @Override
+ protected int getTarget() {
+ return GL11.GL_TEXTURE_2D;
+ }
+
+ @Override
+ public boolean isOpaque() {
+ return true;
+ }
+ }
+
+ @SmallTest
+ public void testBitmapTexture() {
+ Config config = Config.ARGB_8888;
+ Bitmap bitmap = Bitmap.createBitmap(47, 42, config);
+ assertFalse(bitmap.isRecycled());
+ BitmapTexture texture = new BitmapTexture(bitmap);
+ texture.recycle();
+ assertFalse(bitmap.isRecycled());
+ bitmap.recycle();
+ assertTrue(bitmap.isRecycled());
+ }
+}