summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/ui
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2012-05-16 10:54:14 -0700
committerOwen Lin <owenlin@google.com>2012-05-16 13:29:53 -0700
commit40ffdb6244ba8492af8d29dce6d5bacdfd021af6 (patch)
tree0954a3d434e941f47ded71d05a5062be145eaa87 /src/com/android/gallery3d/ui
parent4fa3d5bb57d166d915225b60e9f659e9c91fb9b3 (diff)
downloadandroid_packages_apps_Snap-40ffdb6244ba8492af8d29dce6d5bacdfd021af6.tar.gz
android_packages_apps_Snap-40ffdb6244ba8492af8d29dce6d5bacdfd021af6.tar.bz2
android_packages_apps_Snap-40ffdb6244ba8492af8d29dce6d5bacdfd021af6.zip
Fix a dead lock while we freeze the screen.
bug: 6504696 Change-Id: If960967142bb0df773ce075bf76f5726c37e1d27
Diffstat (limited to 'src/com/android/gallery3d/ui')
-rw-r--r--src/com/android/gallery3d/ui/GLRoot.java1
-rw-r--r--src/com/android/gallery3d/ui/GLRootView.java40
2 files changed, 40 insertions, 1 deletions
diff --git a/src/com/android/gallery3d/ui/GLRoot.java b/src/com/android/gallery3d/ui/GLRoot.java
index 5ed323a88..f4b7572a7 100644
--- a/src/com/android/gallery3d/ui/GLRoot.java
+++ b/src/com/android/gallery3d/ui/GLRoot.java
@@ -17,6 +17,7 @@
package com.android.gallery3d.ui;
import android.graphics.Matrix;
+
import com.android.gallery3d.anim.CanvasAnimation;
public interface GLRoot {
diff --git a/src/com/android/gallery3d/ui/GLRootView.java b/src/com/android/gallery3d/ui/GLRootView.java
index 1f25b9085..73e982509 100644
--- a/src/com/android/gallery3d/ui/GLRootView.java
+++ b/src/com/android/gallery3d/ui/GLRootView.java
@@ -19,12 +19,12 @@ package com.android.gallery3d.ui;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.PixelFormat;
-import android.graphics.Rect;
import android.opengl.GLSurfaceView;
import android.os.Process;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.MotionEvent;
+import android.view.SurfaceHolder;
import com.android.gallery3d.anim.CanvasAnimation;
import com.android.gallery3d.common.Utils;
@@ -467,6 +467,7 @@ public class GLRootView extends GLSurfaceView
@Override
public void onPause() {
+ unfreeze();
super.onPause();
if (DEBUG_PROFILE) {
Log.d(TAG, "Stop profiling");
@@ -510,4 +511,41 @@ public class GLRootView extends GLSurfaceView
mFreezeCondition.signalAll();
mRenderLock.unlock();
}
+
+ // We need to unfreeze in the following methods and in onPause().
+ // These methods will wait on GLThread. If we have freezed the GLRootView,
+ // the GLThread will wait on main thread to call unfreeze and cause dead
+ // lock.
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
+ unfreeze();
+ super.surfaceChanged(holder, format, w, h);
+ }
+
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ unfreeze();
+ super.surfaceCreated(holder);
+ }
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ unfreeze();
+ super.surfaceDestroyed(holder);
+ }
+
+ @Override
+ protected void onDetachedFromWindow() {
+ unfreeze();
+ super.onDetachedFromWindow();
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ try {
+ unfreeze();
+ } finally {
+ super.finalize();
+ }
+ }
}