From 68386e085d3e2338be74996ff99672ff849467cb Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Fri, 18 May 2012 11:30:26 -0700 Subject: Add a new state uploading to UploadedTexture. This state means the texture is being uploaded in background and should not be drawn now to prevent janking. Sometimes, we may lose GLContext and we will need to reupload textures again. In this case, we would like to upload these texture in foreground instead of using TextureUploader. (for simplicity since this won't happen too often). bug: 6519344 Change-Id: Ic5d7547c6a0eb4b044b79aa0eb4eb52397faac03 --- .../src/com/android/gallery3d/ui/TextureTest.java | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/src/com/android/gallery3d/ui/TextureTest.java b/tests/src/com/android/gallery3d/ui/TextureTest.java index be2356c8e..9e34083b8 100644 --- a/tests/src/com/android/gallery3d/ui/TextureTest.java +++ b/tests/src/com/android/gallery3d/ui/TextureTest.java @@ -20,10 +20,10 @@ import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.test.suitebuilder.annotation.SmallTest; -import javax.microedition.khronos.opengles.GL11; - import junit.framework.TestCase; +import javax.microedition.khronos.opengles.GL11; + @SmallTest public class TextureTest extends TestCase { @SuppressWarnings("unused") @@ -34,7 +34,7 @@ public class TextureTest extends TestCase { int mOpaqueCalled; MyBasicTexture(GLCanvas canvas, int id) { - super(canvas, id, BasicTexture.STATE_UNLOADED); + super(canvas, id, 0); } @Override @@ -54,7 +54,7 @@ public class TextureTest extends TestCase { } void upload() { - mState = STATE_LOADED; + mState |= STATE_BIT_LOADED; } } @@ -76,13 +76,13 @@ public class TextureTest extends TestCase { assertEquals(4, texture.getTextureWidth()); assertEquals(8, texture.getTextureHeight()); - assertFalse(texture.isLoaded(canvas)); + assertFalse(texture.isLoaded()); texture.upload(); - assertTrue(texture.isLoaded(canvas)); + assertTrue(texture.isLoaded()); // For a different GL, it's not loaded. GLCanvas canvas2 = new GLCanvasImpl(new GLStub()); - assertFalse(texture.isLoaded(canvas2)); + assertFalse(texture.isLoaded()); assertEquals(0, texture.mOnBindCalled); assertEquals(0, texture.mOpaqueCalled); @@ -143,20 +143,20 @@ public class TextureTest extends TestCase { assertEquals(0, texture.mGetCalled); texture.draw(canvas, 0, 0); assertEquals(1, texture.mGetCalled); - assertTrue(texture.isLoaded(canvas)); - assertTrue(texture.isContentValid(canvas)); + assertTrue(texture.isLoaded()); + assertTrue(texture.isContentValid()); // invalidate content and it should be freed. texture.invalidateContent(); - assertFalse(texture.isContentValid(canvas)); + assertFalse(texture.isContentValid()); assertEquals(1, texture.mFreeCalled); - assertTrue(texture.isLoaded(canvas)); // But it's still loaded + 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(canvas)); - assertTrue(texture.isContentValid(canvas)); + assertTrue(texture.isLoaded()); + assertTrue(texture.isContentValid()); // recycle the texture and it should be freed again. texture.recycle(); @@ -168,7 +168,7 @@ public class TextureTest extends TestCase { class MyTextureForMixed extends BasicTexture { MyTextureForMixed(GLCanvas canvas, int id) { - super(canvas, id, BasicTexture.STATE_UNLOADED); + super(canvas, id, 0); } @Override -- cgit v1.2.3