summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYang Yu <yuyang@codeaurora.org>2013-09-27 15:01:26 +0800
committerSteve Kondik <shade@chemlab.org>2013-10-16 09:13:57 -0700
commit6f8554116ab4ff93420194da39f99026cfdd05a5 (patch)
tree51c798cafc002c37a67e2ecd30f5afb1507f065c
parentfdeb27477e7dddc0a822f35e3969776f2b88667f (diff)
downloadandroid_packages_apps_Gallery2-6f8554116ab4ff93420194da39f99026cfdd05a5.tar.gz
android_packages_apps_Gallery2-6f8554116ab4ff93420194da39f99026cfdd05a5.tar.bz2
android_packages_apps_Gallery2-6f8554116ab4ff93420194da39f99026cfdd05a5.zip
Gallery2: Clear the undefined buffer for the first 15 frames
The view is undefined before the first frame of camera preview data come up. This makes the UI has random corruption when open camera and exit quickly. However, we have no way to know the timing of the first frame. It will take about 700~800ms before first camera preview data comes up, and the time of drawing one frame is about 50ms, so need to clear 15 frames before first camera preview data comes up. Change-Id: Ibc9a5662a15ad58919384ce00cb3a7557b17cae8
-rw-r--r--src/com/android/gallery3d/ui/GLRootView.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/ui/GLRootView.java b/src/com/android/gallery3d/ui/GLRootView.java
index 10aaac7bf..13bb30c8e 100644
--- a/src/com/android/gallery3d/ui/GLRootView.java
+++ b/src/com/android/gallery3d/ui/GLRootView.java
@@ -66,6 +66,7 @@ public class GLRootView extends GLSurfaceView
private static final boolean DEBUG_FPS = false;
private int mFrameCount = 0;
private long mFrameCountingStart = 0;
+ private int mClearCount = 0;
private static final boolean DEBUG_INVALIDATE = false;
private int mInvalidateColor = 0;
@@ -339,8 +340,14 @@ public class GLRootView extends GLSurfaceView
@Override
public void onDrawFrame(GL10 gl) {
- //clear the undefined buffer before draw
- mCanvas.clearBuffer();
+ //The view is undefined before the first frame of camera preview data
+ //come up. This makes the UI has random corruption when open camera
+ //and exit quickly. However, we have no way to know the timing of
+ //the first frame. So, we clear the buffer for first 15 frames.
+ if(mFirstDraw || (mClearCount < 15)){
+ mCanvas.clearBuffer();
+ mClearCount++;
+ }
AnimationTime.update();
long t0;
@@ -542,6 +549,12 @@ public class GLRootView extends GLSurfaceView
}
@Override
+ public void onResume() {
+ super.onResume();
+ mClearCount = 0;
+ }
+
+ @Override
public void setOrientationSource(OrientationSource source) {
mOrientationSource = source;
}