summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/gallery3d/ui')
-rw-r--r--src/com/android/gallery3d/ui/BasicTexture.java3
-rw-r--r--src/com/android/gallery3d/ui/BitmapScreenNail.java10
-rw-r--r--src/com/android/gallery3d/ui/BitmapTileProvider.java2
-rw-r--r--src/com/android/gallery3d/ui/ExtTexture.java89
-rw-r--r--src/com/android/gallery3d/ui/GLCanvas.java6
-rw-r--r--src/com/android/gallery3d/ui/GLCanvasImpl.java47
-rw-r--r--src/com/android/gallery3d/ui/GLId.java40
-rw-r--r--src/com/android/gallery3d/ui/NinePatchTexture.java2
-rw-r--r--src/com/android/gallery3d/ui/PhotoView.java29
-rw-r--r--src/com/android/gallery3d/ui/ScreenNail.java6
-rw-r--r--src/com/android/gallery3d/ui/ScreenNailHolder.java31
-rw-r--r--src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java116
-rw-r--r--src/com/android/gallery3d/ui/TileImageView.java12
-rw-r--r--src/com/android/gallery3d/ui/UploadedTexture.java7
14 files changed, 357 insertions, 43 deletions
diff --git a/src/com/android/gallery3d/ui/BasicTexture.java b/src/com/android/gallery3d/ui/BasicTexture.java
index d3dfd745c..6a9a17d92 100644
--- a/src/com/android/gallery3d/ui/BasicTexture.java
+++ b/src/com/android/gallery3d/ui/BasicTexture.java
@@ -130,6 +130,9 @@ abstract class BasicTexture implements Texture {
// It should make sure the data is uploaded to GL memory.
abstract protected boolean onBind(GLCanvas canvas);
+ // Returns the GL texture target for this texture (e.g. GL_TEXTURE_2D).
+ abstract protected int getTarget();
+
public boolean isLoaded(GLCanvas canvas) {
return mState == STATE_LOADED;
}
diff --git a/src/com/android/gallery3d/ui/BitmapScreenNail.java b/src/com/android/gallery3d/ui/BitmapScreenNail.java
index 117a9ac30..5a1006845 100644
--- a/src/com/android/gallery3d/ui/BitmapScreenNail.java
+++ b/src/com/android/gallery3d/ui/BitmapScreenNail.java
@@ -56,7 +56,11 @@ public class BitmapScreenNail implements ScreenNail {
}
@Override
- public void recycle() {
+ public void noDraw() {
+ }
+
+ @Override
+ public void pauseDraw() {
if (mTexture != null) {
mTexture.recycle();
}
@@ -71,10 +75,6 @@ public class BitmapScreenNail implements ScreenNail {
}
@Override
- public void disableDraw() {
- }
-
- @Override
public void draw(GLCanvas canvas, RectF source, RectF dest) {
if (mTexture == null) {
mTexture = new BitmapTexture(mBitmap);
diff --git a/src/com/android/gallery3d/ui/BitmapTileProvider.java b/src/com/android/gallery3d/ui/BitmapTileProvider.java
index 99b64d42e..1e78cfd33 100644
--- a/src/com/android/gallery3d/ui/BitmapTileProvider.java
+++ b/src/com/android/gallery3d/ui/BitmapTileProvider.java
@@ -96,7 +96,7 @@ public class BitmapTileProvider implements TileImageView.Model {
BitmapUtils.recycleSilently(bitmap);
}
if (mScreenNail != null) {
- mScreenNail.recycle();
+ mScreenNail.pauseDraw();
}
}
diff --git a/src/com/android/gallery3d/ui/ExtTexture.java b/src/com/android/gallery3d/ui/ExtTexture.java
new file mode 100644
index 000000000..e39f317a3
--- /dev/null
+++ b/src/com/android/gallery3d/ui/ExtTexture.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2012 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.ui;
+
+import android.graphics.SurfaceTexture;
+import javax.microedition.khronos.opengles.GL11;
+import javax.microedition.khronos.opengles.GL11Ext;
+
+// ExtTexture is a texture whose content comes from a external texture.
+// Before drawing, setSize() should be called.
+public class ExtTexture extends BasicTexture {
+
+ private static int[] sTextureId = new int[1];
+ private static float[] sCropRect = new float[4];
+ private int mTarget;
+
+ public ExtTexture(int target) {
+ GLId.glGenTextures(1, sTextureId, 0);
+ mId = sTextureId[0];
+ mTarget = target;
+ }
+
+ private void uploadToCanvas(GLCanvas canvas) {
+ GL11 gl = canvas.getGLInstance();
+
+ int width = getWidth();
+ int height = getHeight();
+ // Define a vertically flipped crop rectangle for OES_draw_texture.
+ // The four values in sCropRect are: left, bottom, width, and
+ // height. Negative value of width or height means flip.
+ sCropRect[0] = 0;
+ sCropRect[1] = height;
+ sCropRect[2] = width;
+ sCropRect[3] = -height;
+
+ // Set texture parameters.
+ gl.glBindTexture(mTarget, mId);
+ gl.glTexParameterfv(mTarget,
+ GL11Ext.GL_TEXTURE_CROP_RECT_OES, sCropRect, 0);
+ gl.glTexParameteri(mTarget,
+ GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP_TO_EDGE);
+ gl.glTexParameteri(mTarget,
+ GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP_TO_EDGE);
+ gl.glTexParameterf(mTarget,
+ GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
+ gl.glTexParameterf(mTarget,
+ GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
+
+ setAssociatedCanvas(canvas);
+ mState = UploadedTexture.STATE_LOADED;
+ }
+
+ @Override
+ protected boolean onBind(GLCanvas canvas) {
+ if (!isLoaded(canvas)) {
+ uploadToCanvas(canvas);
+ }
+
+ return true;
+ }
+
+ @Override
+ public int getTarget() {
+ return mTarget;
+ }
+
+ public boolean isOpaque() {
+ return true;
+ }
+
+ @Override
+ public void yield() {
+ // we cannot free the texture because we have no backup.
+ }
+}
diff --git a/src/com/android/gallery3d/ui/GLCanvas.java b/src/com/android/gallery3d/ui/GLCanvas.java
index 1359115f8..9b8053ffc 100644
--- a/src/com/android/gallery3d/ui/GLCanvas.java
+++ b/src/com/android/gallery3d/ui/GLCanvas.java
@@ -85,9 +85,13 @@ public interface GLCanvas {
public void drawMesh(BasicTexture tex, int x, int y, int xyBuffer,
int uvBuffer, int indexBuffer, int indexCount);
- // Draws a the source rectangle part of the texture to the target rectangle.
+ // Draws the source rectangle part of the texture to the target rectangle.
public void drawTexture(BasicTexture texture, RectF source, RectF target);
+ // Draw a texture with a specified texture transform.
+ public void drawTexture(BasicTexture texture, float[] mTextureTransform,
+ int x, int y, int w, int h);
+
// Draw two textures to the specified rectangle. The actual texture used is
// from * (1 - ratio) + to * ratio
// The two textures must have the same size.
diff --git a/src/com/android/gallery3d/ui/GLCanvasImpl.java b/src/com/android/gallery3d/ui/GLCanvasImpl.java
index 68f5636f7..686e712bd 100644
--- a/src/com/android/gallery3d/ui/GLCanvasImpl.java
+++ b/src/com/android/gallery3d/ui/GLCanvasImpl.java
@@ -136,7 +136,7 @@ public class GLCanvasImpl implements GLCanvas {
xyBuffer.put(BOX_COORDINATES, 0, BOX_COORDINATES.length).position(0);
int[] name = new int[1];
- gl.glGenBuffers(1, name, 0);
+ GLId.glGenBuffers(1, name, 0);
mBoxCoords = name[0];
gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, mBoxCoords);
@@ -377,6 +377,16 @@ public class GLCanvasImpl implements GLCanvas {
textureRect(target.left, target.top, target.width(), target.height());
}
+ public void drawTexture(BasicTexture texture, float[] mTextureTransform,
+ int x, int y, int w, int h) {
+ mGLState.setBlendEnabled(mBlendEnabled
+ && (!texture.isOpaque() || mAlpha < OPAQUE_ALPHA));
+ if (!bindTexture(texture)) return;
+ setTextureCoords(mTextureTransform);
+ mGLState.setTextureAlpha(mAlpha);
+ textureRect(x, y, w, h);
+ }
+
// This function changes the source coordinate to the texture coordinates.
// It also clips the source and target coordinates if it is beyond the
// bound of the texture.
@@ -415,8 +425,9 @@ public class GLCanvasImpl implements GLCanvas {
private boolean bindTexture(BasicTexture texture) {
if (!texture.onBind(this)) return false;
- mGLState.setTexture2DEnabled(true);
- mGL.glBindTexture(GL11.GL_TEXTURE_2D, texture.getId());
+ int target = texture.getTarget();
+ mGLState.setTextureTarget(target);
+ mGL.glBindTexture(target, texture.getId());
return true;
}
@@ -513,7 +524,7 @@ public class GLCanvasImpl implements GLCanvas {
private int mTexEnvMode = GL11.GL_REPLACE;
private float mTextureAlpha = 1.0f;
- private boolean mTexture2DEnabled = true;
+ private int mTextureTarget = 0;
private boolean mBlendEnabled = true;
private float mLineWidth = 1.0f;
private boolean mLineSmooth = false;
@@ -578,7 +589,7 @@ public class GLCanvasImpl implements GLCanvas {
// again in setTextureAlpha(float) later.
mTextureAlpha = -1.0f;
- setTexture2DEnabled(false);
+ setTextureTarget(0);
float prealpha = (color >>> 24) * alpha * 65535f / 255f / 255f;
mGL.glColor4x(
@@ -588,13 +599,15 @@ public class GLCanvasImpl implements GLCanvas {
Math.round(255 * prealpha));
}
- public void setTexture2DEnabled(boolean enabled) {
- if (mTexture2DEnabled == enabled) return;
- mTexture2DEnabled = enabled;
- if (enabled) {
- mGL.glEnable(GL11.GL_TEXTURE_2D);
- } else {
- mGL.glDisable(GL11.GL_TEXTURE_2D);
+ // target is a value like GL_TEXTURE_2D. If target = 0, texturing is disabled.
+ public void setTextureTarget(int target) {
+ if (mTextureTarget == target) return;
+ if (mTextureTarget != 0) {
+ mGL.glDisable(mTextureTarget);
+ }
+ mTextureTarget = target;
+ if (mTextureTarget != 0) {
+ mGL.glEnable(mTextureTarget);
}
}
@@ -634,6 +647,12 @@ public class GLCanvasImpl implements GLCanvas {
mGL.glMatrixMode(GL11.GL_MODELVIEW);
}
+ private void setTextureCoords(float[] mTextureTransform) {
+ mGL.glMatrixMode(GL11.GL_TEXTURE);
+ mGL.glLoadMatrixf(mTextureTransform, 0);
+ mGL.glMatrixMode(GL11.GL_MODELVIEW);
+ }
+
// unloadTexture and deleteBuffer can be called from the finalizer thread,
// so we synchronized on the mUnboundTextures object.
public boolean unloadTexture(BasicTexture t) {
@@ -654,13 +673,13 @@ public class GLCanvasImpl implements GLCanvas {
synchronized (mUnboundTextures) {
IntArray ids = mUnboundTextures;
if (ids.size() > 0) {
- mGL.glDeleteTextures(ids.size(), ids.getInternalArray(), 0);
+ GLId.glDeleteTextures(ids.size(), ids.getInternalArray(), 0);
ids.clear();
}
ids = mDeleteBuffers;
if (ids.size() > 0) {
- mGL.glDeleteBuffers(ids.size(), ids.getInternalArray(), 0);
+ GLId.glDeleteBuffers(ids.size(), ids.getInternalArray(), 0);
ids.clear();
}
}
diff --git a/src/com/android/gallery3d/ui/GLId.java b/src/com/android/gallery3d/ui/GLId.java
new file mode 100644
index 000000000..c228c350d
--- /dev/null
+++ b/src/com/android/gallery3d/ui/GLId.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2012 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.ui;
+
+// This mimics corresponding GL functions.
+public class GLId {
+ static int sNextId = 1;
+
+ public synchronized static void glGenTextures(int n, int[] textures, int offset) {
+ while (n-- > 0) {
+ textures[offset + n] = sNextId++;
+ }
+ }
+
+ public synchronized static void glGenBuffers(int n, int[] buffers, int offset) {
+ while (n-- > 0) {
+ buffers[offset + n] = sNextId++;
+ }
+ }
+
+ public synchronized static void glDeleteTextures(int n, int[] textures, int offset) {
+ }
+
+ public synchronized static void glDeleteBuffers(int n, int[] buffers, int offset) {
+ }
+}
diff --git a/src/com/android/gallery3d/ui/NinePatchTexture.java b/src/com/android/gallery3d/ui/NinePatchTexture.java
index 6a2ba0037..957229eb5 100644
--- a/src/com/android/gallery3d/ui/NinePatchTexture.java
+++ b/src/com/android/gallery3d/ui/NinePatchTexture.java
@@ -398,7 +398,7 @@ class NinePatchInstance {
private void prepareBuffers(GLCanvas canvas) {
mBufferNames = new int[3];
GL11 gl = canvas.getGLInstance();
- gl.glGenBuffers(3, mBufferNames, 0);
+ GLId.glGenBuffers(3, mBufferNames, 0);
gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, mBufferNames[0]);
gl.glBufferData(GL11.GL_ARRAY_BUFFER,
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
index 252f3484d..77e3d99e7 100644
--- a/src/com/android/gallery3d/ui/PhotoView.java
+++ b/src/com/android/gallery3d/ui/PhotoView.java
@@ -225,7 +225,7 @@ public class PhotoView extends GLView {
return;
}
ScreenNailEntry entry = mScreenNails[which];
- entry.set(screenNail);
+ entry.updateScreenNail(screenNail);
}
// -1 previous, 0 current, 1 next
@@ -650,10 +650,8 @@ public class PhotoView extends GLView {
ScreenNailEntry prevNail = mScreenNails[ENTRY_PREVIOUS];
ScreenNailEntry nextNail = mScreenNails[ENTRY_NEXT];
mTileView.invalidateTiles();
- if (prevNail.mScreenNail != null) prevNail.mScreenNail.recycle();
- prevNail.set(mTileView.mScreenNail);
- mTileView.updateScreenNail(nextNail.mScreenNail);
- nextNail.set(null);
+ prevNail.updateScreenNail(mTileView.releaseScreenNail());
+ mTileView.updateScreenNail(nextNail.releaseScreenNail());
mModel.next();
}
@@ -662,10 +660,8 @@ public class PhotoView extends GLView {
ScreenNailEntry prevNail = mScreenNails[ENTRY_PREVIOUS];
ScreenNailEntry nextNail = mScreenNails[ENTRY_NEXT];
mTileView.invalidateTiles();
- if (nextNail.mScreenNail != null) nextNail.mScreenNail.recycle();
- nextNail.set(mTileView.mScreenNail);
- mTileView.updateScreenNail(prevNail.mScreenNail);
- nextNail.set(null);
+ nextNail.updateScreenNail(mTileView.releaseScreenNail());
+ mTileView.updateScreenNail(prevNail.releaseScreenNail());
mModel.previous();
}
@@ -715,10 +711,10 @@ public class PhotoView extends GLView {
private ScreenNail mScreenNail;
- public void set(ScreenNail screenNail) {
+ public void updateScreenNail(ScreenNail screenNail) {
mEnabled = (screenNail != null);
if (mScreenNail == screenNail) return;
- if (mScreenNail != null) mScreenNail.recycle();
+ if (mScreenNail != null) mScreenNail.pauseDraw();
mScreenNail = screenNail;
if (mScreenNail != null) {
mRotation = mScreenNail.getRotation();
@@ -726,6 +722,13 @@ public class PhotoView extends GLView {
}
}
+ // Release the ownership of the ScreenNail from this entry.
+ public ScreenNail releaseScreenNail() {
+ ScreenNail s = mScreenNail;
+ mScreenNail = null;
+ return s;
+ }
+
public void layoutRightEdgeAt(int x) {
mVisible = x > 0;
mOffsetX = x - getRotated(
@@ -767,7 +770,7 @@ public class PhotoView extends GLView {
public void draw(GLCanvas canvas, boolean applyFadingAnimation) {
if (mScreenNail == null) return;
if (!mVisible) {
- mScreenNail.disableDraw();
+ mScreenNail.noDraw();
return;
}
@@ -877,7 +880,7 @@ public class PhotoView extends GLView {
mTransitionMode = TRANS_NONE;
mTileView.freeTextures();
for (ScreenNailEntry entry : mScreenNails) {
- entry.set(null);
+ entry.updateScreenNail(null);
}
}
diff --git a/src/com/android/gallery3d/ui/ScreenNail.java b/src/com/android/gallery3d/ui/ScreenNail.java
index a2377fe2a..58ae8c942 100644
--- a/src/com/android/gallery3d/ui/ScreenNail.java
+++ b/src/com/android/gallery3d/ui/ScreenNail.java
@@ -21,11 +21,9 @@ public interface ScreenNail {
public int getWidth();
public int getHeight();
public int getRotation();
- public void recycle();
public void draw(GLCanvas canvas, int x, int y, int width, int height);
-
- // We need this method to tell ScreenNail to stop displaying.
- public void disableDraw();
+ public void noDraw(); // we do not need to draw this ScreenNail in this frame.
+ public void pauseDraw(); // we do not expect to draw this ScreenNail for some time.
// This is only used by TileImageView to back up the tiles not yet loaded.
public void draw(GLCanvas canvas, RectF source, RectF dest);
diff --git a/src/com/android/gallery3d/ui/ScreenNailHolder.java b/src/com/android/gallery3d/ui/ScreenNailHolder.java
new file mode 100644
index 000000000..a7d541767
--- /dev/null
+++ b/src/com/android/gallery3d/ui/ScreenNailHolder.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2012 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.ui;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+public abstract class ScreenNailHolder implements Parcelable {
+ public int describeContents() {
+ return 0;
+ }
+
+ public void writeToParcel(Parcel dest, int flags) {
+ }
+
+ public abstract ScreenNail attach();
+ public abstract void detach();
+}
diff --git a/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java b/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java
new file mode 100644
index 000000000..3a8f2b0a4
--- /dev/null
+++ b/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2012 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.ui;
+
+import android.graphics.RectF;
+import android.graphics.SurfaceTexture;
+import android.opengl.GLES11Ext;
+import android.util.Log;
+
+import com.android.gallery3d.ui.GLCanvas;
+import com.android.gallery3d.ui.ScreenNail;
+import com.android.gallery3d.ui.ExtTexture;
+
+public abstract class SurfaceTextureScreenNail implements ScreenNail,
+ SurfaceTexture.OnFrameAvailableListener {
+ private static final String TAG = "SurfaceTextureScreenNail";
+ private ExtTexture mExtTexture;
+ private SurfaceTexture mSurfaceTexture;
+ private int mWidth, mHeight;
+ private float[] mTransform = new float[16];
+ private boolean mHasTexture = false;
+
+ public SurfaceTextureScreenNail() {
+ }
+
+ public void acquireSurfaceTexture() {
+ mExtTexture = new ExtTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES);
+ mExtTexture.setSize(mWidth, mHeight);
+ mSurfaceTexture = new SurfaceTexture(mExtTexture.getId());
+ mSurfaceTexture.setOnFrameAvailableListener(this);
+ synchronized (this) {
+ mHasTexture = true;
+ }
+ }
+
+ public SurfaceTexture getSurfaceTexture() {
+ return mSurfaceTexture;
+ }
+
+ public void releaseSurfaceTexture() {
+ synchronized (this) {
+ mHasTexture = false;
+ }
+ mExtTexture.recycle();
+ mExtTexture = null;
+ mSurfaceTexture.release();
+ mSurfaceTexture = null;
+ }
+
+ public void setSize(int width, int height) {
+ mWidth = width;
+ mHeight = height;
+ }
+
+ @Override
+ public int getWidth() {
+ return mWidth;
+ }
+
+ @Override
+ public int getHeight() {
+ return mHeight;
+ }
+
+ @Override
+ public int getRotation() {
+ return 0;
+ }
+
+ @Override
+ public void draw(GLCanvas canvas, int x, int y, int width, int height) {
+ synchronized (this) {
+ if (!mHasTexture) return;
+ mSurfaceTexture.updateTexImage();
+ mSurfaceTexture.getTransformMatrix(mTransform);
+
+ // Flip vertically.
+ canvas.save(GLCanvas.SAVE_FLAG_MATRIX);
+ int cx = x + width / 2;
+ int cy = y + height / 2;
+ canvas.translate(cx, cy);
+ canvas.scale(1, -1, 1);
+ canvas.translate(-cx, -cy);
+ canvas.drawTexture(mExtTexture, mTransform, x, y, width, height);
+ canvas.restore();
+ }
+ }
+
+ @Override
+ public void draw(GLCanvas canvas, RectF source, RectF dest) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ abstract public void noDraw();
+
+ @Override
+ abstract public void pauseDraw();
+
+ @Override
+ abstract public void onFrameAvailable(SurfaceTexture surfaceTexture);
+}
diff --git a/src/com/android/gallery3d/ui/TileImageView.java b/src/com/android/gallery3d/ui/TileImageView.java
index 638a7f94b..d2ce1677a 100644
--- a/src/com/android/gallery3d/ui/TileImageView.java
+++ b/src/com/android/gallery3d/ui/TileImageView.java
@@ -71,7 +71,7 @@ public class TileImageView extends GLView {
private static final int STATE_RECYCLED = 0x40;
private Model mModel;
- protected ScreenNail mScreenNail;
+ private ScreenNail mScreenNail;
protected int mLevelCount; // cache the value of mScaledBitmaps.length
// The mLevel variable indicates which level of bitmap we should use.
@@ -155,10 +155,16 @@ public class TileImageView extends GLView {
public void updateScreenNail(ScreenNail s) {
if (mScreenNail == s) return;
- if (mScreenNail != null) mScreenNail.recycle();
+ if (mScreenNail != null) mScreenNail.pauseDraw();
mScreenNail = s;
}
+ public ScreenNail releaseScreenNail() {
+ ScreenNail s = mScreenNail;
+ mScreenNail = null;
+ return s;
+ }
+
public void notifyModelInvalidated() {
invalidateTiles();
if (mModel == null) {
@@ -421,7 +427,7 @@ public class TileImageView extends GLView {
try {
if (level != mLevelCount) {
if (mScreenNail != null) {
- mScreenNail.disableDraw();
+ mScreenNail.noDraw();
}
int size = (TILE_SIZE << level);
diff --git a/src/com/android/gallery3d/ui/UploadedTexture.java b/src/com/android/gallery3d/ui/UploadedTexture.java
index c4d8d82f8..85aa1c4b2 100644
--- a/src/com/android/gallery3d/ui/UploadedTexture.java
+++ b/src/com/android/gallery3d/ui/UploadedTexture.java
@@ -228,7 +228,7 @@ abstract class UploadedTexture extends BasicTexture {
sCropRect[3] = -bHeight;
// Upload the bitmap to a new texture.
- gl.glGenTextures(1, sTextureId, 0);
+ GLId.glGenTextures(1, sTextureId, 0);
gl.glBindTexture(GL11.GL_TEXTURE_2D, sTextureId[0]);
gl.glTexParameterfv(GL11.GL_TEXTURE_2D,
GL11Ext.GL_TEXTURE_CROP_RECT_OES, sCropRect, 0);
@@ -299,6 +299,11 @@ abstract class UploadedTexture extends BasicTexture {
return isContentValid(canvas);
}
+ @Override
+ protected int getTarget() {
+ return GL11.GL_TEXTURE_2D;
+ }
+
public void setOpaque(boolean isOpaque) {
mOpaque = isOpaque;
}