diff options
-rw-r--r-- | src/com/android/gallery3d/ui/GLRoot.java | 2 | ||||
-rw-r--r-- | src/com/android/gallery3d/ui/GLRootView.java | 24 | ||||
-rw-r--r-- | tests/src/com/android/gallery3d/ui/GLRootMock.java | 2 | ||||
-rw-r--r-- | tests/src/com/android/gallery3d/ui/GLRootStub.java | 2 |
4 files changed, 30 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/ui/GLRoot.java b/src/com/android/gallery3d/ui/GLRoot.java index 313d81a5f..5ed323a88 100644 --- a/src/com/android/gallery3d/ui/GLRoot.java +++ b/src/com/android/gallery3d/ui/GLRoot.java @@ -41,4 +41,6 @@ public interface GLRoot { public int getDisplayRotation(); public int getCompensation(); public Matrix getCompensationMatrix(); + public void freeze(); + public void unfreeze(); } diff --git a/src/com/android/gallery3d/ui/GLRootView.java b/src/com/android/gallery3d/ui/GLRootView.java index 7f8f1f4ff..1f25b9085 100644 --- a/src/com/android/gallery3d/ui/GLRootView.java +++ b/src/com/android/gallery3d/ui/GLRootView.java @@ -33,6 +33,7 @@ import com.android.gallery3d.util.Profile; import java.util.ArrayDeque; import java.util.ArrayList; +import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.ReentrantLock; import javax.microedition.khronos.egl.EGLConfig; @@ -97,6 +98,9 @@ public class GLRootView extends GLSurfaceView private final IdleRunner mIdleRunner = new IdleRunner(); private final ReentrantLock mRenderLock = new ReentrantLock(); + private final Condition mFreezeCondition = + mRenderLock.newCondition(); + private boolean mFreeze; private long mLastDrawFinishTime; private boolean mInDownState = false; @@ -301,6 +305,11 @@ public class GLRootView extends GLSurfaceView t0 = System.nanoTime(); } mRenderLock.lock(); + + while (mFreeze) { + mFreezeCondition.awaitUninterruptibly(); + } + try { onDrawFrameLocked(gl); } finally { @@ -486,4 +495,19 @@ public class GLRootView extends GLSurfaceView public Matrix getCompensationMatrix() { return mCompensationMatrix; } + + @Override + public void freeze() { + mRenderLock.lock(); + mFreeze = true; + mRenderLock.unlock(); + } + + @Override + public void unfreeze() { + mRenderLock.lock(); + mFreeze = false; + mFreezeCondition.signalAll(); + mRenderLock.unlock(); + } } diff --git a/tests/src/com/android/gallery3d/ui/GLRootMock.java b/tests/src/com/android/gallery3d/ui/GLRootMock.java index 4af7a1f59..1253e50ae 100644 --- a/tests/src/com/android/gallery3d/ui/GLRootMock.java +++ b/tests/src/com/android/gallery3d/ui/GLRootMock.java @@ -39,4 +39,6 @@ public class GLRootMock implements GLRoot { public int getDisplayRotation() { return 0; } public int getCompensation() { return 0; } public Matrix getCompensationMatrix() { return null; } + public void freeze() {} + public void unfreeze() {} } diff --git a/tests/src/com/android/gallery3d/ui/GLRootStub.java b/tests/src/com/android/gallery3d/ui/GLRootStub.java index 878eeddb4..5c88c47ec 100644 --- a/tests/src/com/android/gallery3d/ui/GLRootStub.java +++ b/tests/src/com/android/gallery3d/ui/GLRootStub.java @@ -32,4 +32,6 @@ public class GLRootStub implements GLRoot { public int getDisplayRotation() { return 0; } public int getCompensation() { return 0; } public Matrix getCompensationMatrix() { return null; } + public void freeze() {} + public void unfreeze() {} } |