diff options
| -rw-r--r-- | api/current.xml | 13 | ||||
| -rw-r--r-- | core/java/android/view/SurfaceView.java | 44 |
2 files changed, 48 insertions, 9 deletions
diff --git a/api/current.xml b/api/current.xml index 38490f3113eb..f7df7c9b7433 100644 --- a/api/current.xml +++ b/api/current.xml @@ -150079,6 +150079,19 @@ visibility="public" > </method> +<method name="setOnTop" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="onTop" type="boolean"> +</parameter> +</method> </class> <class name="TouchDelegate" extends="java.lang.Object" diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index 1426aef86099..356f55a134d2 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -236,6 +236,10 @@ public class SurfaceView extends View { @Override public boolean gatherTransparentRegion(Region region) { + if (mWindowType == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) { + return super.gatherTransparentRegion(region); + } + boolean opaque = true; if ((mPrivateFlags & SKIP_DRAW) == 0) { // this view draws, remove it from the transparent region @@ -259,20 +263,24 @@ public class SurfaceView extends View { @Override public void draw(Canvas canvas) { - // draw() is not called when SKIP_DRAW is set - if ((mPrivateFlags & SKIP_DRAW) == 0) { - // punch a whole in the view-hierarchy below us - canvas.drawColor(0, PorterDuff.Mode.CLEAR); + if (mWindowType != WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) { + // draw() is not called when SKIP_DRAW is set + if ((mPrivateFlags & SKIP_DRAW) == 0) { + // punch a whole in the view-hierarchy below us + canvas.drawColor(0, PorterDuff.Mode.CLEAR); + } } super.draw(canvas); } @Override protected void dispatchDraw(Canvas canvas) { - // if SKIP_DRAW is cleared, draw() has already punched a hole - if ((mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) { - // punch a whole in the view-hierarchy below us - canvas.drawColor(0, PorterDuff.Mode.CLEAR); + if (mWindowType != WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) { + // if SKIP_DRAW is cleared, draw() has already punched a hole + if ((mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) { + // punch a whole in the view-hierarchy below us + canvas.drawColor(0, PorterDuff.Mode.CLEAR); + } } // reposition ourselves where the surface is mHaveFrame = true; @@ -281,6 +289,22 @@ public class SurfaceView extends View { } /** + * Control whether the surface view's surface is placed on top of its + * window. Normally it is placed behind the window, to allow it to + * (for the most part) appear to composite with the views in the + * hierarchy. By setting this, you cause it to be placed above the + * window. This means that none of the contents of the window this + * SurfaceView is in will be visible on top of its surface. + * + * <p>Note that this must be set before the surface view's containing + * window is attached to the window manager. + */ + public void setOnTop(boolean onTop) { + mWindowType = onTop ? WindowManager.LayoutParams.TYPE_APPLICATION_PANEL + : WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA; + } + + /** * Hack to allow special layering of windows. The type is one of the * types in WindowManager.LayoutParams. This is a hack so: * @hide @@ -345,7 +369,9 @@ public class SurfaceView extends View { } mLayout.format = mRequestedFormat; - mLayout.flags |=WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS + mLayout.flags |=WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE + | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE + | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_SCALED | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |