diff options
author | Owen Lin <owenlin@google.com> | 2012-08-29 19:45:37 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-08-29 19:45:38 -0700 |
commit | e05f0fa8b946d4eb5c8c8c0361150b90e877c87d (patch) | |
tree | d57a9ea9bd2516d8a252c9d09e9d79373742b841 | |
parent | 47301935ff08dc6f8b879ef49be3872fd84543cd (diff) | |
parent | fb6aafde995cfaeb57f3009f10a4c0c843993162 (diff) | |
download | android_packages_apps_Snap-e05f0fa8b946d4eb5c8c8c0361150b90e877c87d.tar.gz android_packages_apps_Snap-e05f0fa8b946d4eb5c8c8c0361150b90e877c87d.tar.bz2 android_packages_apps_Snap-e05f0fa8b946d4eb5c8c8c0361150b90e877c87d.zip |
Merge "Fix OOM in TileImageView." into gb-ub-photos-arches
-rw-r--r-- | src/com/android/gallery3d/ui/TextureUploader.java | 2 | ||||
-rw-r--r-- | src/com/android/gallery3d/ui/TileImageView.java | 13 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/com/android/gallery3d/ui/TextureUploader.java b/src/com/android/gallery3d/ui/TextureUploader.java index 714b09795..9a8c47fc6 100644 --- a/src/com/android/gallery3d/ui/TextureUploader.java +++ b/src/com/android/gallery3d/ui/TextureUploader.java @@ -29,7 +29,7 @@ public class TextureUploader implements OnGLIdleListener { private final ArrayDeque<UploadedTexture> mBgTextures = new ArrayDeque<UploadedTexture>(INIT_CAPACITY); private final GLRoot mGLRoot; - private transient boolean mIsQueued = false; + private volatile boolean mIsQueued = false; public TextureUploader(GLRoot root) { mGLRoot = root; diff --git a/src/com/android/gallery3d/ui/TileImageView.java b/src/com/android/gallery3d/ui/TileImageView.java index fc61efd64..9eb4f4787 100644 --- a/src/com/android/gallery3d/ui/TileImageView.java +++ b/src/com/android/gallery3d/ui/TileImageView.java @@ -270,6 +270,7 @@ public class TileImageView extends GLView { protected synchronized void invalidateTiles() { mDecodeQueue.clean(); mUploadQueue.clean(); + // TODO disable decoder int n = mActiveTiles.size(); for (int i = 0; i < n; i++) { @@ -553,21 +554,23 @@ public class TileImageView extends GLView { @Override public boolean onGLIdle(GLCanvas canvas, boolean renderRequested) { - if (renderRequested) return false; + // Skips uploading if there is a pending rendering request. + // Returns true to keep uploading in next rendering loop. + if (renderRequested) return true; int quota = UPLOAD_LIMIT; - Tile tile; - while (true) { + Tile tile = null; + while (quota > 0) { synchronized (TileImageView.this) { tile = mUploadQueue.pop(); } - if (tile == null || quota <= 0) break; + if (tile == null) break; if (!tile.isContentValid()) { Utils.assertTrue(tile.mTileState == STATE_DECODED); tile.updateContent(canvas); --quota; } } - mActive.set(tile != null); + if (tile == null) mActive.set(false); return tile != null; } } |