diff options
| author | Dianne Hackborn <hackbod@google.com> | 2009-09-14 22:29:14 -0700 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2009-09-15 11:29:00 -0700 |
| commit | 1cd403eaac24e0e84619dea07e2d1d60e58e1fd2 (patch) | |
| tree | 8fd14791f029cdb5b808fc6b166b3a372b9c0d86 /core/java/android/view | |
| parent | d583a015bcbac8718cbf5ed8a1c40d074c65a226 (diff) | |
| download | frameworks_base-1cd403eaac24e0e84619dea07e2d1d60e58e1fd2.zip frameworks_base-1cd403eaac24e0e84619dea07e2d1d60e58e1fd2.tar.gz frameworks_base-1cd403eaac24e0e84619dea07e2d1d60e58e1fd2.tar.bz2 | |
Add SurfaceView API to put surface on top of window.
Change-Id: I9db84ee63a362e54ebc2f5b24a20ae5bdc3588bf
Diffstat (limited to 'core/java/android/view')
| -rw-r--r-- | core/java/android/view/SurfaceView.java | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index 1426aef..356f55a 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 |
