Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1cd403ea authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Add SurfaceView API to put surface on top of window.

Change-Id: I9db84ee63a362e54ebc2f5b24a20ae5bdc3588bf
parent d583a015
Loading
Loading
Loading
Loading
+13 −0
Original line number Original line Diff line number Diff line
@@ -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"
+35 −9
Original line number Original line Diff line number Diff line
@@ -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,27 +263,47 @@ public class SurfaceView extends View {


    @Override
    @Override
    public void draw(Canvas canvas) {
    public void draw(Canvas canvas) {
        if (mWindowType != WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
            // draw() is not called when SKIP_DRAW is set
            // draw() is not called when SKIP_DRAW is set
            if ((mPrivateFlags & SKIP_DRAW) == 0) {
            if ((mPrivateFlags & SKIP_DRAW) == 0) {
                // punch a whole in the view-hierarchy below us
                // punch a whole in the view-hierarchy below us
                canvas.drawColor(0, PorterDuff.Mode.CLEAR);
                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 (mWindowType != WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
            // if SKIP_DRAW is cleared, draw() has already punched a hole
            // if SKIP_DRAW is cleared, draw() has already punched a hole
            if ((mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) {
            if ((mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) {
                // punch a whole in the view-hierarchy below us
                // punch a whole in the view-hierarchy below us
                canvas.drawColor(0, PorterDuff.Mode.CLEAR);
                canvas.drawColor(0, PorterDuff.Mode.CLEAR);
            }
            }
        }
        // reposition ourselves where the surface is 
        // reposition ourselves where the surface is 
        mHaveFrame = true;
        mHaveFrame = true;
        updateWindow(false);
        updateWindow(false);
        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