summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2012-10-22 16:11:01 -0700
committerJohn Reck <jreck@google.com>2012-10-22 16:11:01 -0700
commitccd5750055f6b692f4d5bb9fd1a1a8428966cbed (patch)
treebb263bb55229476b232272484badbdba614fe87f
parent82da3e8e16187b8c13c1382b487b4735b7f1d94a (diff)
downloadandroid_packages_apps_Snap-ccd5750055f6b692f4d5bb9fd1a1a8428966cbed.zip
android_packages_apps_Snap-ccd5750055f6b692f4d5bb9fd1a1a8428966cbed.tar.gz
android_packages_apps_Snap-ccd5750055f6b692f4d5bb9fd1a1a8428966cbed.tar.bz2
Drive GLRootView with Choreographer
Bug: 7332724 By routing requestRender through postOnAnimation we can drive the GLRootView's rendering with the UI thread's coreographer, which ensures that touch events are processed before drawing Change-Id: Iac2b3229e9a09ee0319c64c5fc7cb906512a379c
-rw-r--r--gallerycommon/src/com/android/gallery3d/common/ApiHelper.java3
-rw-r--r--src/com/android/gallery3d/ui/GLRootView.java15
2 files changed, 18 insertions, 0 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java
index a393025..837777e 100644
--- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java
+++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java
@@ -167,6 +167,9 @@ public class ApiHelper {
public static final boolean HAS_VIEW_PROPERTY_ANIMATOR =
Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1;
+ public static final boolean HAS_POST_ON_ANIMATION =
+ Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN;
+
public static int getIntFieldIfExists(Class<?> klass, String fieldName,
Class<?> obj, int defaultVal) {
try {
diff --git a/src/com/android/gallery3d/ui/GLRootView.java b/src/com/android/gallery3d/ui/GLRootView.java
index dbdfb67..b400b05 100644
--- a/src/com/android/gallery3d/ui/GLRootView.java
+++ b/src/com/android/gallery3d/ui/GLRootView.java
@@ -177,6 +177,21 @@ public class GLRootView extends GLSurfaceView
}
if (mRenderRequested) return;
mRenderRequested = true;
+ if (ApiHelper.HAS_POST_ON_ANIMATION) {
+ postOnAnimation(mRequestRenderOnAnimationFrame);
+ } else {
+ super.requestRender();
+ }
+ }
+
+ private Runnable mRequestRenderOnAnimationFrame = new Runnable() {
+ @Override
+ public void run() {
+ superRequestRender();
+ }
+ };
+
+ private void superRequestRender() {
super.requestRender();
}