Skip to content

Commit 71d73a0

Browse files
Romain GuyAndroid (Google) Code Review
authored andcommitted
Merge "Add a method to hide/show a SurfaceView's surface." into froyo
2 parents cb52cb5 + afc3e11 commit 71d73a0

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

core/java/android/view/SurfaceView.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package android.view;
1818

19+
import android.util.DisplayMetrics;
1920
import com.android.internal.view.BaseIWindow;
2021

2122
import android.content.Context;
@@ -212,6 +213,46 @@ public void setVisibility(int visibility) {
212213
mRequestedVisible = mWindowVisibility && mViewVisibility;
213214
updateWindow(false);
214215
}
216+
217+
/**
218+
* This method is not intended for general use. It was created
219+
* temporarily to improve performance of 3D layers in Launcher
220+
* and should be removed and fixed properly.
221+
*
222+
* Do not call this method. Ever.
223+
*
224+
* @hide
225+
*/
226+
protected void showSurface() {
227+
if (mSession != null) {
228+
updateWindow(true);
229+
}
230+
}
231+
232+
/**
233+
* This method is not intended for general use. It was created
234+
* temporarily to improve performance of 3D layers in Launcher
235+
* and should be removed and fixed properly.
236+
*
237+
* Do not call this method. Ever.
238+
*
239+
* @hide
240+
*/
241+
protected void hideSurface() {
242+
if (mSession != null && mWindow != null) {
243+
mSurfaceLock.lock();
244+
try {
245+
DisplayMetrics metrics = getResources().getDisplayMetrics();
246+
mLayout.x = metrics.widthPixels * 3;
247+
mSession.relayout(mWindow, mLayout, mWidth, mHeight, VISIBLE, false,
248+
mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mSurface);
249+
} catch (RemoteException e) {
250+
// Ignore
251+
} finally {
252+
mSurfaceLock.unlock();
253+
}
254+
}
255+
}
215256

216257
@Override
217258
protected void onDetachedFromWindow() {

0 commit comments

Comments
 (0)