summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2012-10-24 20:35:45 +0800
committerOwen Lin <owenlin@google.com>2012-10-25 12:24:52 +0800
commitd71a718afe02282153d86b78f6a44c4783203d54 (patch)
tree7f5e020f2b4debf04bee224f4b8ff6edfa8eee68 /src
parentadee31f028d839e7baa8f9e052dc4e4d60b137da (diff)
downloadandroid_packages_apps_Gallery2-d71a718afe02282153d86b78f6a44c4783203d54.tar.gz
android_packages_apps_Gallery2-d71a718afe02282153d86b78f6a44c4783203d54.tar.bz2
android_packages_apps_Gallery2-d71a718afe02282153d86b78f6a44c4783203d54.zip
Fix tiling effect when open a photo.
1. Don't draw the tiles of full image before screen nail is ready. 2. Upload multiple tiles in each frame in order to show photo quickly. bug: 7403409 Change-Id: Ic5a88a29fe302068e97ab81ab260d0cc572dd7ff
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/ui/TiledScreenNail.java4
-rw-r--r--src/com/android/gallery3d/ui/TiledTexture.java11
2 files changed, 13 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/ui/TiledScreenNail.java b/src/com/android/gallery3d/ui/TiledScreenNail.java
index d2b34e3bf..74665f584 100644
--- a/src/com/android/gallery3d/ui/TiledScreenNail.java
+++ b/src/com/android/gallery3d/ui/TiledScreenNail.java
@@ -189,6 +189,10 @@ public class TiledScreenNail implements ScreenNail {
}
public boolean isAnimating() {
+ // The TiledTexture may not be uploaded completely yet.
+ // In that case, we count it as animating state and we will draw
+ // the placeholder in TileImageView.
+ if (mTexture == null || !mTexture.isReady()) return true;
if (mAnimationStartTime < 0) return false;
if (AnimationTime.get() - mAnimationStartTime >= DURATION) {
mAnimationStartTime = ANIMATION_DONE;
diff --git a/src/com/android/gallery3d/ui/TiledTexture.java b/src/com/android/gallery3d/ui/TiledTexture.java
index 8598a3fff..4352ed425 100644
--- a/src/com/android/gallery3d/ui/TiledTexture.java
+++ b/src/com/android/gallery3d/ui/TiledTexture.java
@@ -24,6 +24,7 @@ import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
+import android.os.SystemClock;
import com.android.gallery3d.ui.GLRoot.OnGLIdleListener;
@@ -40,6 +41,10 @@ public class TiledTexture implements Texture {
private static final int TILE_SIZE = CONTENT_SIZE + 2 * BORDER_SIZE;
private static final int INIT_CAPACITY = 8;
+ // We are targeting at 60fps, so we have 16ms for each frame.
+ // In this 16ms, we use about 4~8 ms to upload tiles.
+ private static final long UPLOAD_TILE_LIMIT = 4; // ms
+
private static Tile sFreeTileHead = null;
private static final Object sFreeTileLock = new Object();
@@ -79,17 +84,19 @@ public class TiledTexture implements Texture {
mGlRoot.addOnGLIdleListener(this);
}
-
@Override
public boolean onGLIdle(GLCanvas canvas, boolean renderRequested) {
ArrayDeque<TiledTexture> deque = mTextures;
synchronized (this) {
- if (!deque.isEmpty()) {
+ long now = SystemClock.uptimeMillis();
+ long dueTime = now + UPLOAD_TILE_LIMIT;
+ while(now < dueTime && !deque.isEmpty()) {
TiledTexture t = deque.peekFirst();
if (t.uploadNextTile(canvas)) {
deque.removeFirst();
mGlRoot.requestRender();
}
+ now = SystemClock.uptimeMillis();
}
mIsQueued = !mTextures.isEmpty();