summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/ui
diff options
context:
space:
mode:
authorLikai Ding <likaid@codeaurora.org>2016-07-14 15:30:28 +0800
committerLikai Ding <likaid@codeaurora.org>2016-07-20 13:36:34 +0800
commit7c1f6788830573f9b3dc378a80b9d288ffd9ccea (patch)
tree024cac9c9223211a9bc8f9bcc4630b19aad379b3 /src/com/android/gallery3d/ui
parent3cd6f49bd8ba93feb1b308e6f0f32a06b47c9fc8 (diff)
downloadandroid_packages_apps_Gallery2-7c1f6788830573f9b3dc378a80b9d288ffd9ccea.tar.gz
android_packages_apps_Gallery2-7c1f6788830573f9b3dc378a80b9d288ffd9ccea.tar.bz2
android_packages_apps_Gallery2-7c1f6788830573f9b3dc378a80b9d288ffd9ccea.zip
Gallery: speed up TileImageView
For a 1920x1080 screen, 40 256x256 tiles are needed. However, tile uploading is limited to 1 tile per frame, which will last for 40 frames in this case. Remove the limit and use available time in onGLIdle(). Change-Id: I688a158dff0c03aca2d7f063df6134b0ffc0b08a CRs-Fixed: 962597
Diffstat (limited to 'src/com/android/gallery3d/ui')
-rw-r--r--src/com/android/gallery3d/ui/TileImageView.java23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/com/android/gallery3d/ui/TileImageView.java b/src/com/android/gallery3d/ui/TileImageView.java
index 16e2fc129..05bc9aff5 100644
--- a/src/com/android/gallery3d/ui/TileImageView.java
+++ b/src/com/android/gallery3d/ui/TileImageView.java
@@ -90,7 +90,6 @@ public class TileImageView extends GLView {
private int mOffsetX;
private int mOffsetY;
- private int mUploadQuota;
private boolean mRenderComplete;
private final RectF mSourceRect = new RectF();
@@ -404,7 +403,6 @@ public class TileImageView extends GLView {
@Override
protected void render(GLCanvas canvas) {
- mUploadQuota = UPLOAD_LIMIT;
mRenderComplete = true;
int level = mLevel;
@@ -560,12 +558,10 @@ public class TileImageView extends GLView {
@Override
public boolean onGLIdle(GLCanvas canvas, boolean renderRequested, long dueTime) {
- // 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;
+ long now = System.nanoTime();
+ long uploadTime = 0;
Tile tile = null;
- while (quota > 0) {
+ while (now + uploadTime < dueTime) {
synchronized (TileImageView.this) {
tile = mUploadQueue.pop();
}
@@ -575,8 +571,10 @@ public class TileImageView extends GLView {
Utils.assertTrue(tile.mTileState == STATE_DECODED);
tile.updateContent(canvas);
if (!hasBeenLoaded) tile.draw(canvas, 0, 0);
- --quota;
}
+ long t1 = System.nanoTime();
+ uploadTime = t1 - now;
+ now = t1;
}
if (tile == null) mActive.set(false);
return tile != null;
@@ -596,13 +594,8 @@ public class TileImageView extends GLView {
if (tile != null) {
if (!tile.isContentValid()) {
if (tile.mTileState == STATE_DECODED) {
- if (mUploadQuota > 0) {
- --mUploadQuota;
- tile.updateContent(canvas);
- } else {
- mRenderComplete = false;
- }
- } else if (tile.mTileState != STATE_DECODE_FAIL){
+ mRenderComplete = false;
+ } else if (tile.mTileState != STATE_DECODE_FAIL) {
mRenderComplete = false;
queueForDecode(tile);
}