diff options
author | Likai Ding <likaid@codeaurora.org> | 2016-06-01 10:31:45 +0800 |
---|---|---|
committer | Likai Ding <likaid@codeaurora.org> | 2016-06-06 09:10:10 +0800 |
commit | 2d5dcfc88b71ec802bdc1123b5261c0bdffc7d5b (patch) | |
tree | 3163d02ec3e4ef1027a76ac37d2fd128c057c02d /src/com/android/gallery3d/ui | |
parent | b4a82b335c3d133f76f457102fde3f4726e0e023 (diff) | |
download | android_packages_apps_Gallery2-2d5dcfc88b71ec802bdc1123b5261c0bdffc7d5b.tar.gz android_packages_apps_Gallery2-2d5dcfc88b71ec802bdc1123b5261c0bdffc7d5b.tar.bz2 android_packages_apps_Gallery2-2d5dcfc88b71ec802bdc1123b5261c0bdffc7d5b.zip |
Gallery: faster texture upload
TileTexture.Uploader uses a fixed time slot (4ms) to upload tiles.
However, typical GL idle time is much longer than that. To better
utilize it, a third parameter is added to onGLIdle method to indicate
the due time. This can cut ~170ms on certain devices.
CRs-Fixed: 1024519
Change-Id: I8347b87f85815a4deaf10eb10f234a56b047681e
Diffstat (limited to 'src/com/android/gallery3d/ui')
-rw-r--r-- | src/com/android/gallery3d/ui/GLRoot.java | 2 | ||||
-rw-r--r-- | src/com/android/gallery3d/ui/GLRootView.java | 11 | ||||
-rw-r--r-- | src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java | 2 | ||||
-rw-r--r-- | src/com/android/gallery3d/ui/TileImageView.java | 2 |
4 files changed, 13 insertions, 4 deletions
diff --git a/src/com/android/gallery3d/ui/GLRoot.java b/src/com/android/gallery3d/ui/GLRoot.java index 33a82eaf7..caa36c334 100644 --- a/src/com/android/gallery3d/ui/GLRoot.java +++ b/src/com/android/gallery3d/ui/GLRoot.java @@ -28,7 +28,7 @@ public interface GLRoot { // Mainly used for uploading textures. public static interface OnGLIdleListener { public boolean onGLIdle( - GLCanvas canvas, boolean renderRequested); + GLCanvas canvas, boolean renderRequested, long dueTime); } public void addOnGLIdleListener(OnGLIdleListener listener); diff --git a/src/com/android/gallery3d/ui/GLRootView.java b/src/com/android/gallery3d/ui/GLRootView.java index 3d17ee007..5d9621b6d 100644 --- a/src/com/android/gallery3d/ui/GLRootView.java +++ b/src/com/android/gallery3d/ui/GLRootView.java @@ -78,6 +78,8 @@ public class GLRootView extends GLSurfaceView private static final int FLAG_INITIALIZED = 1; private static final int FLAG_NEED_LAYOUT = 2; + private static final long FRAME_INTERVAL = 16000000; + private GL11 mGL; private GLCanvas mCanvas; private GLView mContentView; @@ -111,6 +113,8 @@ public class GLRootView extends GLSurfaceView private boolean mInDownState = false; private boolean mFirstDraw = true; + private long mDueTime; + public GLRootView(Context context) { this(context, null); } @@ -339,6 +343,7 @@ public class GLRootView extends GLSurfaceView @Override public void onDrawFrame(GL10 gl) { + mDueTime = System.nanoTime() + FRAME_INTERVAL; AnimationTime.update(); long t0; if (DEBUG_PROFILE_SLOW_ONLY) { @@ -502,7 +507,11 @@ public class GLRootView extends GLSurfaceView boolean keepInQueue = false; try { if (mCanvas != null) { - keepInQueue = listener.onGLIdle(mCanvas, mRenderRequested); + long t = System.nanoTime(); + if (mDueTime < t) { + mDueTime = t + FRAME_INTERVAL / 2; + } + keepInQueue = listener.onGLIdle(mCanvas, mRenderRequested, mDueTime); } } finally { mRenderLock.unlock(); diff --git a/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java b/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java index ce672f211..74be72255 100644 --- a/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java +++ b/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java @@ -47,7 +47,7 @@ public class PreparePageFadeoutTexture implements OnGLIdleListener { } @Override - public boolean onGLIdle(GLCanvas canvas, boolean renderRequested) { + public boolean onGLIdle(GLCanvas canvas, boolean renderRequested, long dueTime) { if (!mCancelled) { try { canvas.beginRenderTarget(mTexture); diff --git a/src/com/android/gallery3d/ui/TileImageView.java b/src/com/android/gallery3d/ui/TileImageView.java index 2b978d1bf..16e2fc129 100644 --- a/src/com/android/gallery3d/ui/TileImageView.java +++ b/src/com/android/gallery3d/ui/TileImageView.java @@ -559,7 +559,7 @@ public class TileImageView extends GLView { AtomicBoolean mActive = new AtomicBoolean(false); @Override - public boolean onGLIdle(GLCanvas canvas, boolean renderRequested) { + 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; |