summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2010-06-07 17:04:33 -0700
committerRomain Guy <romainguy@google.com>2010-06-08 11:34:43 -0700
commitafc3e11f10828e113331eb24b65e4f9759f67747 (patch)
tree01bf8cdb92ec37ce290e40851b33e76736ba0031 /core/java/android
parentdf2e2eff9446c0220515fa7aab7857135e04e12e (diff)
downloadframeworks_base-afc3e11f10828e113331eb24b65e4f9759f67747.zip
frameworks_base-afc3e11f10828e113331eb24b65e4f9759f67747.tar.gz
frameworks_base-afc3e11f10828e113331eb24b65e4f9759f67747.tar.bz2
Add a method to hide/show a SurfaceView's surface.
This can be used to move a surface offscreen to avoid the cost of compositing it. This preserves the window and therefore the OpenGL context when used in h/w accelerated apps. Change-Id: I280295376601b17989d0fc8a271af66650016f09
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/view/SurfaceView.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 2a3f032..53f0c2e 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -16,6 +16,7 @@
package android.view;
+import android.util.DisplayMetrics;
import com.android.internal.view.BaseIWindow;
import android.content.Context;
@@ -212,6 +213,46 @@ public class SurfaceView extends View {
mRequestedVisible = mWindowVisibility && mViewVisibility;
updateWindow(false);
}
+
+ /**
+ * This method is not intended for general use. It was created
+ * temporarily to improve performance of 3D layers in Launcher
+ * and should be removed and fixed properly.
+ *
+ * Do not call this method. Ever.
+ *
+ * @hide
+ */
+ protected void showSurface() {
+ if (mSession != null) {
+ updateWindow(true);
+ }
+ }
+
+ /**
+ * This method is not intended for general use. It was created
+ * temporarily to improve performance of 3D layers in Launcher
+ * and should be removed and fixed properly.
+ *
+ * Do not call this method. Ever.
+ *
+ * @hide
+ */
+ protected void hideSurface() {
+ if (mSession != null && mWindow != null) {
+ mSurfaceLock.lock();
+ try {
+ DisplayMetrics metrics = getResources().getDisplayMetrics();
+ mLayout.x = metrics.widthPixels * 3;
+ mSession.relayout(mWindow, mLayout, mWidth, mHeight, VISIBLE, false,
+ mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mSurface);
+ } catch (RemoteException e) {
+ // Ignore
+ } finally {
+ mSurfaceLock.unlock();
+ }
+ }
+ }
@Override
protected void onDetachedFromWindow() {