Add SurfaceView API to put surface on top of window.
Change-Id: I9db84ee63a362e54ebc2f5b24a20ae5bdc3588bf
This commit is contained in:
@@ -150079,6 +150079,19 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</method>
|
</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>
|
||||||
<class name="TouchDelegate"
|
<class name="TouchDelegate"
|
||||||
extends="java.lang.Object"
|
extends="java.lang.Object"
|
||||||
|
|||||||
@@ -236,6 +236,10 @@ public class SurfaceView extends View {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean gatherTransparentRegion(Region region) {
|
public boolean gatherTransparentRegion(Region region) {
|
||||||
|
if (mWindowType == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
|
||||||
|
return super.gatherTransparentRegion(region);
|
||||||
|
}
|
||||||
|
|
||||||
boolean opaque = true;
|
boolean opaque = true;
|
||||||
if ((mPrivateFlags & SKIP_DRAW) == 0) {
|
if ((mPrivateFlags & SKIP_DRAW) == 0) {
|
||||||
// this view draws, remove it from the transparent region
|
// this view draws, remove it from the transparent region
|
||||||
@@ -259,20 +263,24 @@ public class SurfaceView extends View {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Canvas canvas) {
|
public void draw(Canvas canvas) {
|
||||||
// draw() is not called when SKIP_DRAW is set
|
if (mWindowType != WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
|
||||||
if ((mPrivateFlags & SKIP_DRAW) == 0) {
|
// draw() is not called when SKIP_DRAW is set
|
||||||
// punch a whole in the view-hierarchy below us
|
if ((mPrivateFlags & SKIP_DRAW) == 0) {
|
||||||
canvas.drawColor(0, PorterDuff.Mode.CLEAR);
|
// punch a whole in the view-hierarchy below us
|
||||||
|
canvas.drawColor(0, PorterDuff.Mode.CLEAR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
super.draw(canvas);
|
super.draw(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dispatchDraw(Canvas canvas) {
|
protected void dispatchDraw(Canvas canvas) {
|
||||||
// if SKIP_DRAW is cleared, draw() has already punched a hole
|
if (mWindowType != WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
|
||||||
if ((mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) {
|
// if SKIP_DRAW is cleared, draw() has already punched a hole
|
||||||
// punch a whole in the view-hierarchy below us
|
if ((mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) {
|
||||||
canvas.drawColor(0, PorterDuff.Mode.CLEAR);
|
// punch a whole in the view-hierarchy below us
|
||||||
|
canvas.drawColor(0, PorterDuff.Mode.CLEAR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// reposition ourselves where the surface is
|
// reposition ourselves where the surface is
|
||||||
mHaveFrame = true;
|
mHaveFrame = true;
|
||||||
@@ -280,6 +288,22 @@ public class SurfaceView extends View {
|
|||||||
super.dispatchDraw(canvas);
|
super.dispatchDraw(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* Hack to allow special layering of windows. The type is one of the
|
||||||
* types in WindowManager.LayoutParams. This is a hack so:
|
* types in WindowManager.LayoutParams. This is a hack so:
|
||||||
@@ -345,7 +369,9 @@ public class SurfaceView extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mLayout.format = mRequestedFormat;
|
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_SCALED
|
||||||
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
||||||
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
|
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
|
||||||
|
|||||||
Reference in New Issue
Block a user