diff options
author | Chih-Chung Chang <chihchung@google.com> | 2010-04-09 20:48:02 +0800 |
---|---|---|
committer | Chih-Chung Chang <chihchung@google.com> | 2010-04-09 20:48:02 +0800 |
commit | 2acd452b2fe877b57d00278958ea4b34bad75159 (patch) | |
tree | cb5b1affc4ff23239e111cda29f25f83359fa2af /src/com/android/camera/ui/GLRootView.java | |
parent | a30b554cc3707638172f8072f437cf8627dedda0 (diff) | |
download | LegacyCamera-2acd452b2fe877b57d00278958ea4b34bad75159.zip LegacyCamera-2acd452b2fe877b57d00278958ea4b34bad75159.tar.gz LegacyCamera-2acd452b2fe877b57d00278958ea4b34bad75159.tar.bz2 |
Add a hack to avoid allocating GL surface with different sizes.
Bug: 2515291
Change-Id: Ib0d886dcd355ddd3af09cc31089ed8c446911536
Diffstat (limited to 'src/com/android/camera/ui/GLRootView.java')
-rw-r--r-- | src/com/android/camera/ui/GLRootView.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/com/android/camera/ui/GLRootView.java b/src/com/android/camera/ui/GLRootView.java index ce97cf5..7baeb5d 100644 --- a/src/com/android/camera/ui/GLRootView.java +++ b/src/com/android/camera/ui/GLRootView.java @@ -76,6 +76,9 @@ public class GLRootView extends GLSurfaceView private boolean mIsQueueActive = true; + private int mFirstWidth; + private int mFirstHeight; + // TODO: move this part (handler) into GLSurfaceView private final Looper mLooper; @@ -551,4 +554,35 @@ public class GLRootView extends GLSurfaceView protected Looper getTimerLooper() { return mLooper; } + + // After the device goes to sleep and back, the lock screen may cause the + // orientation to become portrait. So we will allocate a surface with a + // different size. This causes problem when we try to allocate the surface + // again with the original size because the graphics memory is fragmented. + // The hack is to hide the surface when we are in different size than the + // first landscape size we get. This hack can fail is the first landscape + // size is not the final size for this view (say, press power key right + // after starting the app). + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + Log.v(TAG, "onSizeChanged: first = " + mFirstWidth + "x" + + mFirstHeight + ", new = " + w + "x" + h); + + // Record the first landscape size + if (mFirstWidth == 0 && w > h) { + mFirstWidth = w; + mFirstHeight = h; + } + + // Hide if the size doesn't match the first landscape size + if (mFirstWidth == w && mFirstHeight == h) { + Log.v(TAG, "show"); + setVisibility(VISIBLE); + } else { + Log.v(TAG, "hide"); + setVisibility(INVISIBLE); + } + + super.onSizeChanged(w, h, oldw, oldh); + } } |